Stop simple behaviors retaining configs
This commit is contained in:
parent
26148829bd
commit
fa7217fcc8
6 changed files with 27 additions and 15 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue