2020-04-09 10:33:16 +01:00
|
|
|
using MessagePack;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
2020-05-31 03:10:11 +01:00
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
2020-05-06 04:56:36 +01:00
|
|
|
public class RadiatorData : BehaviorData
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
2020-05-31 03:10:11 +01:00
|
|
|
[InspectableField, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
|
2020-04-09 10:33:16 +01:00
|
|
|
public PerformanceStat Emissivity = new PerformanceStat();
|
|
|
|
|
|
2020-12-10 23:20:38 +00:00
|
|
|
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
|
|
|
|
return new Radiator(context, this, entity, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Radiator : IBehavior
|
|
|
|
|
{
|
|
|
|
|
public Entity Entity { get; }
|
2020-12-10 23:20:38 +00:00
|
|
|
public EquippedItem Item { get; }
|
|
|
|
|
public ItemManager Context { get; }
|
2020-04-09 10:33:16 +01:00
|
|
|
|
2020-05-06 04:56:36 +01:00
|
|
|
public BehaviorData Data => _data;
|
2020-05-26 01:12:06 +01:00
|
|
|
|
|
|
|
|
public float Emissivity;
|
2020-04-09 10:33:16 +01:00
|
|
|
|
|
|
|
|
private RadiatorData _data;
|
|
|
|
|
|
2020-12-10 23:20:38 +00:00
|
|
|
public Radiator(ItemManager context, RadiatorData data, Entity entity, EquippedItem item)
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
|
|
|
|
Context = context;
|
|
|
|
|
_data = data;
|
|
|
|
|
Entity = entity;
|
|
|
|
|
Item = item;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
public bool Update(float delta)
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
2020-12-10 23:20:38 +00:00
|
|
|
Emissivity = Context.Evaluate(_data.Emissivity, Item.EquippableItem, Entity);
|
|
|
|
|
var rad = pow(Item.Temperature, Context.GameplaySettings.HeatRadiationExponent) * Context.GameplaySettings.HeatRadiationMultiplier * Emissivity;
|
|
|
|
|
Item.Temperature -= rad * delta;
|
2020-04-09 10:33:16 +01:00
|
|
|
Entity.VisibilitySources[this] = rad;
|
2020-05-11 01:17:10 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-04-09 10:33:16 +01:00
|
|
|
}
|