Gear Schematic HUD

Created in-flight equipment HUD & schematic display
This commit is contained in:
Reinier Vens 2020-12-31 19:53:16 +00:00
commit 1e273d691e
253 changed files with 19369 additions and 6296 deletions

View file

@ -45,6 +45,11 @@ public interface IAlwaysUpdatedBehavior
void AlwaysUpdate(float delta);
}
public interface IProgressBehavior
{
float Progress { get; }
}
public interface IOrderedBehavior
{
int Order { get; }
@ -111,6 +116,7 @@ public abstract class PersistentBehaviorData
Union(30, typeof(HaulingControllerData)),
Union(31, typeof(CapacitorData)),
Union(32, typeof(CockpitData)),
Union(33, typeof(HeatsinkData)),
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
public abstract class BehaviorData
{

View file

@ -26,6 +26,8 @@ public class Cockpit : IBehavior
public ItemManager Context { get; }
public BehaviorData Data => _data;
public float Heatstroke { get; private set; }
public Cockpit(ItemManager context, CockpitData data, Entity entity, EquippedItem item)
{
@ -33,10 +35,22 @@ public class Cockpit : IBehavior
_data = data;
Entity = entity;
Item = item;
Heatstroke = 0;
}
public bool Update(float delta)
{
return true;
if (Item.Temperature > Context.GameplaySettings.HeatstrokeTemperature)
{
Heatstroke = saturate(
Heatstroke +
pow(Item.Temperature - Context.GameplaySettings.HeatstrokeTemperature, Context.GameplaySettings.HeatstrokeExponent) *
Context.GameplaySettings.HeatstrokeMultiplier * delta);
}
else
{
Heatstroke = saturate(Heatstroke - Context.GameplaySettings.HeatstrokeRecoverySpeed * delta);
}
return Heatstroke < Context.GameplaySettings.HeatstrokeControlLimit;
}
}

View file

@ -6,6 +6,8 @@ using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
public class CooldownData : BehaviorData
@ -19,7 +21,7 @@ public class CooldownData : BehaviorData
}
}
public class Cooldown : IBehavior, IAlwaysUpdatedBehavior
public class Cooldown : IBehavior, IAlwaysUpdatedBehavior, IProgressBehavior
{
private CooldownData _data;
public BehaviorData Data => _data;
@ -30,6 +32,8 @@ public class Cooldown : IBehavior, IAlwaysUpdatedBehavior
private float _cooldown; // Normalized
public float Progress => saturate(_cooldown);
public Cooldown(ItemManager context, CooldownData data, Entity entity, EquippedItem item)
{
_data = data;

View file

@ -0,0 +1,42 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class HeatsinkData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
{
return new Heatsink(context, this, entity, item);
}
}
public class Heatsink : IBehavior
{
private HeatsinkData _data;
public Entity Entity { get; }
public EquippedItem Item { get; }
public ItemManager Context { get; }
public BehaviorData Data => _data;
public Heatsink(ItemManager context, HeatsinkData data, Entity entity, EquippedItem item)
{
Context = context;
_data = data;
Entity = entity;
Item = item;
}
public bool Update(float delta)
{
return true;
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0933c645c44822441a0d2d8e06c8d343
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -38,6 +38,8 @@ public class Reactor : IBehavior, IOrderedBehavior
public Entity Entity { get; }
public EquippedItem Item { get; }
public ItemManager Context { get; }
public float Surplus { get; private set; }
public int Order => 100;
@ -67,6 +69,8 @@ public class Reactor : IBehavior, IOrderedBehavior
Item.AddHeat(charge / efficiency);
Entity.Energy += charge;
Surplus = Entity.Energy;
// We have an energy deficit, try to get some energy out of our capacitors first
if (Entity.Energy < 0)