Stop simple behaviors retaining configs
This commit is contained in:
parent
26148829bd
commit
fa7217fcc8
6 changed files with 27 additions and 15 deletions
Binary file not shown.
|
|
@ -179,6 +179,9 @@ identity owners or a public behavior API. Stat modifiers ask live behavior
|
|||
instances for target stats instead of reading behavior config objects directly;
|
||||
base `Behavior` captures a runtime stat table at construction and no longer
|
||||
retains the config object for later reflection.
|
||||
Heat, EnergyDraw, and Cooldown behavior instances now copy their constructor
|
||||
stat/scalar inputs into explicit runtime fields and no longer retain their
|
||||
config subclasses after construction.
|
||||
`ItemManager` currently owns the explicit typed-payload-to-config bridge.
|
||||
Typed name-file documents are `aetheria.name_file.v2` records. They carry the
|
||||
legacy ID, display name, count, compact sample names for surfaces, and the full
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class CooldownConfig : RuntimeBehaviorConfig
|
|||
|
||||
public class Cooldown : Behavior, IAlwaysUpdatedBehavior, IProgressBehavior
|
||||
{
|
||||
private CooldownConfig _data;
|
||||
private readonly PerformanceStat _cooldownDuration;
|
||||
|
||||
private float _cooldown; // Normalized
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ public class Cooldown : Behavior, IAlwaysUpdatedBehavior, IProgressBehavior
|
|||
|
||||
public Cooldown(CooldownConfig data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_cooldownDuration = data.Cooldown;
|
||||
}
|
||||
|
||||
public Cooldown(CooldownConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_cooldownDuration = data.Cooldown;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
|
|
@ -55,6 +55,6 @@ public class Cooldown : Behavior, IAlwaysUpdatedBehavior, IProgressBehavior
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
_cooldown -= delta / Evaluate(_data.Cooldown);
|
||||
_cooldown -= delta / Evaluate(_cooldownDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,20 +26,23 @@ public class EnergyDrawConfig : RuntimeBehaviorConfig
|
|||
|
||||
public class EnergyDraw : Behavior
|
||||
{
|
||||
private EnergyDrawConfig _data;
|
||||
private readonly PerformanceStat _energyDraw;
|
||||
private readonly bool _perSecond;
|
||||
|
||||
public EnergyDraw(EnergyDrawConfig data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_energyDraw = data.EnergyDraw;
|
||||
_perSecond = data.PerSecond;
|
||||
}
|
||||
|
||||
public EnergyDraw(EnergyDrawConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_energyDraw = data.EnergyDraw;
|
||||
_perSecond = data.PerSecond;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
return Entity.TryConsumeEnergy(Evaluate(_data.EnergyDraw) * (_data.PerSecond ? dt : 1));
|
||||
return Entity.TryConsumeEnergy(Evaluate(_energyDraw) * (_perSecond ? dt : 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,21 +26,24 @@ public class HeatConfig : RuntimeBehaviorConfig
|
|||
|
||||
public class Heat : Behavior
|
||||
{
|
||||
private HeatConfig _data;
|
||||
private readonly PerformanceStat _heat;
|
||||
private readonly bool _perSecond;
|
||||
|
||||
public Heat(HeatConfig data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_heat = data.Heat;
|
||||
_perSecond = data.PerSecond;
|
||||
}
|
||||
public Heat(HeatConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_heat = data.Heat;
|
||||
_perSecond = data.PerSecond;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
AddHeat(Evaluate(_data.Heat) * (_data.PerSecond ? dt : 1));
|
||||
AddHeat(Evaluate(_heat) * (_perSecond ? dt : 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
not have to reselect behavior identity from the old class graph.
|
||||
Base `Behavior` now captures a runtime performance-stat table during
|
||||
construction and no longer retains the config object for later stat lookup.
|
||||
Heat, EnergyDraw, and Cooldown behavior instances now copy constructor
|
||||
stat/scalar inputs into explicit runtime fields and no longer retain their
|
||||
config subclasses after construction.
|
||||
`StatModifier` behavior requirements and behavior-stat targets compare typed
|
||||
behavior kinds on the live equipped behavior instances through
|
||||
`AetheriaRuntimeBehaviorMetadataCatalog` instead of scanning config
|
||||
|
|
|
|||
Loading…
Reference in a new issue