Entity Properties & Thermal Regulation
Entities such as colonies and ships can now be clicked on to reveal their properties or context menus Orbital Colony loadout now has a new item (thermostatic heater) which itself has a new behavior type (Thermotoggle) allowing it to regulate its temperature for more agreeable living conditions Fixed stat modifiers for hull stats (e.g. Hull Expansion) Widened property label in DB inspector
This commit is contained in:
parent
110ff883b8
commit
698263ce63
15 changed files with 143 additions and 33 deletions
|
|
@ -87,6 +87,8 @@ public abstract class PersistentBehaviorData
|
|||
Union(20, typeof(SwitchData)),
|
||||
Union(21, typeof(TriggerData)),
|
||||
Union(22, typeof(VisibilityData)),
|
||||
Union(23, typeof(ThermotoggleData)),
|
||||
Union(24, typeof(EnergyDrawData)),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
|
||||
public abstract class BehaviorData
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ public class Radiator : IBehavior
|
|||
public GameContext Context { get; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
public float Emissivity;
|
||||
|
||||
private RadiatorData _data;
|
||||
|
||||
|
|
@ -35,7 +37,8 @@ public class Radiator : IBehavior
|
|||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
var rad = pow(Entity.Temperature, Context.GlobalData.HeatRadiationPower) * Context.GlobalData.HeatRadiationMultiplier;
|
||||
Emissivity = Context.Evaluate(_data.Emissivity, Item, Entity);
|
||||
var rad = pow(Entity.Temperature, Context.GlobalData.HeatRadiationPower) * Context.GlobalData.HeatRadiationMultiplier * Emissivity;
|
||||
Entity.Temperature -= rad * delta;
|
||||
Entity.VisibilitySources[this] = rad;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ public class Reactor : IBehavior
|
|||
public GameContext Context { get; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
public float Capacitance;
|
||||
|
||||
public Reactor(GameContext context, ReactorData data, Entity entity, Gear item)
|
||||
{
|
||||
|
|
@ -45,17 +46,17 @@ public class Reactor : IBehavior
|
|||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
var cap = Context.Evaluate(_data.Capacitance, Item, Entity);
|
||||
Capacitance = Context.Evaluate(_data.Capacitance, Item, Entity);
|
||||
var charge = Context.Evaluate(_data.Charge, Item, Entity) * delta;
|
||||
var efficiency = Context.Evaluate(_data.Efficiency, Item, Entity);
|
||||
|
||||
Entity.AddHeat(charge / efficiency);
|
||||
Entity.Energy += charge;
|
||||
|
||||
if (Entity.Energy > cap)
|
||||
if (Entity.Energy > Capacitance)
|
||||
{
|
||||
Entity.AddHeat(-(Entity.Energy - cap) / efficiency * (1 - 1 / Context.Evaluate(_data.UnderloadRecovery, Item, Entity)));
|
||||
Entity.Energy = cap;
|
||||
Entity.AddHeat(-(Entity.Energy - Capacitance) / efficiency * (1 - 1 / Context.Evaluate(_data.UnderloadRecovery, Item, Entity)));
|
||||
Entity.Energy = Capacitance;
|
||||
}
|
||||
|
||||
if (Entity.Energy < 0)
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ public class StatModifier : IBehavior, IInitializableBehavior, IDisposableBehavi
|
|||
if (statField != null)
|
||||
{
|
||||
if (typeof(EquippableItemData).IsAssignableFrom(targetType))
|
||||
_stats = Entity.EquippedItems
|
||||
_stats = Entity.EquippedItems.Append(Entity.Hull)
|
||||
.Select(id => Context.Cache.Get<Gear>(id))
|
||||
.Where(gear => _data.RequireBehavior == null || gear.ItemData.Behaviors.Any(behavior => behavior.GetType() == _data.RequireBehavior))
|
||||
.Where(gear => gear.ItemData.GetType() == targetType)
|
||||
.Select(gear => statField.GetValue(gear.ItemData) as PerformanceStat)
|
||||
.ToArray();
|
||||
else
|
||||
_stats = Entity.EquippedItems
|
||||
_stats = Entity.EquippedItems.Append(Entity.Hull)
|
||||
.Select(id => Context.Cache.Get<Gear>(id))
|
||||
.Where(gear => _data.RequireBehavior == null || gear.ItemData.Behaviors.Any(behavior => behavior.GetType() == _data.RequireBehavior))
|
||||
.SelectMany(gear => gear.ItemData.Behaviors)
|
||||
|
|
|
|||
43
Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs
Normal file
43
Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
|
||||
public class ThermotoggleData : BehaviorData
|
||||
{
|
||||
[TemperatureInspectable, JsonProperty("targetTemp"), Key(1)]
|
||||
public float TargetTemperature;
|
||||
|
||||
[InspectableField, JsonProperty("perSecond"), Key(2)]
|
||||
public bool HighPass;
|
||||
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
{
|
||||
return new Thermotoggle(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Thermotoggle : IBehavior
|
||||
{
|
||||
private ThermotoggleData _data;
|
||||
|
||||
private Entity Entity { get; }
|
||||
private Gear Item { get; }
|
||||
private GameContext Context { get; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
public Thermotoggle(GameContext context, ThermotoggleData data, Entity entity, Gear item)
|
||||
{
|
||||
_data = data;
|
||||
Entity = entity;
|
||||
Item = item;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
return Entity.Temperature < _data.TargetTemperature ^ _data.HighPass;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8e461bdbde38ffb4486490d7998d62af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue