Restore behavior runtime state from typed Continue
This commit is contained in:
parent
c8b58fa44f
commit
01fc810eb4
23 changed files with 406 additions and 13 deletions
|
|
@ -135,4 +135,18 @@ public class AetherDrive : Behavior
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
float3 axis,
|
||||
float3 thrust,
|
||||
float3 rpm,
|
||||
float maximumRpm,
|
||||
float2 thrustDirection)
|
||||
{
|
||||
Axis = axis;
|
||||
Thrust = thrust;
|
||||
Rpm = rpm;
|
||||
MaximumRpm = maximumRpm;
|
||||
ThrustDirection = thrustDirection;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,11 @@ public class Capacitor : Behavior
|
|||
Efficiency = Evaluate(_efficiency);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float charge, float capacity, float efficiency)
|
||||
{
|
||||
Charge = clamp(charge, 0, capacity);
|
||||
Capacity = capacity;
|
||||
Efficiency = efficiency;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,5 +168,29 @@ public class ChargedWeapon : InstantWeapon
|
|||
_charging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
bool firing,
|
||||
int ammo,
|
||||
int burstRemaining,
|
||||
float burstTimer,
|
||||
float burstInterval,
|
||||
float cooldownProgress,
|
||||
bool coolingDown,
|
||||
bool charging,
|
||||
bool charged,
|
||||
float charge)
|
||||
{
|
||||
base.RestoreRuntimeState(
|
||||
firing,
|
||||
ammo,
|
||||
burstRemaining,
|
||||
burstTimer,
|
||||
burstInterval,
|
||||
cooldownProgress,
|
||||
coolingDown);
|
||||
_charging = charging;
|
||||
_charged = charged;
|
||||
_charge = charge;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,4 +134,18 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
OnStopFiring?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
bool firing,
|
||||
int ammo,
|
||||
float ammoIntervalProgress,
|
||||
float reloadProgress,
|
||||
bool reloading)
|
||||
{
|
||||
base.RestoreRuntimeState(firing);
|
||||
_ammo = ammo;
|
||||
_ammoInterval = ammoIntervalProgress;
|
||||
_reload = reloadProgress;
|
||||
_reloading = reloading;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,4 +194,22 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
Trigger();
|
||||
base.Activate();
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
bool firing,
|
||||
int ammo,
|
||||
int burstRemaining,
|
||||
float burstTimer,
|
||||
float burstInterval,
|
||||
float cooldownProgress,
|
||||
bool coolingDown)
|
||||
{
|
||||
base.RestoreRuntimeState(firing);
|
||||
_ammo = ammo;
|
||||
_burstRemaining = burstRemaining;
|
||||
_burstTimer = burstTimer;
|
||||
_burstInterval = burstInterval;
|
||||
_cooldown = cooldownProgress;
|
||||
_coolingDown = coolingDown;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,5 +93,28 @@ public class LockWeapon : InstantWeapon
|
|||
|
||||
return base.Execute(dt);
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
bool firing,
|
||||
int ammo,
|
||||
int burstRemaining,
|
||||
float burstTimer,
|
||||
float burstInterval,
|
||||
float cooldownProgress,
|
||||
bool coolingDown,
|
||||
float lockProgress,
|
||||
Entity lockTarget)
|
||||
{
|
||||
base.RestoreRuntimeState(
|
||||
firing,
|
||||
ammo,
|
||||
burstRemaining,
|
||||
burstTimer,
|
||||
burstInterval,
|
||||
cooldownProgress,
|
||||
coolingDown);
|
||||
_lock = lockProgress;
|
||||
_target = lockTarget;
|
||||
_locking = lockTarget != null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,11 @@ public class MiningTool : Behavior
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(Guid asteroidBelt, int asteroid, float range)
|
||||
{
|
||||
AsteroidBelt = asteroidBelt;
|
||||
Asteroid = asteroid;
|
||||
Range = range;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,4 +90,18 @@ public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
|
|||
{
|
||||
RadiatorTemperature = Temperature;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
float radiatorTemperature,
|
||||
float emissivity,
|
||||
float pumpedHeat,
|
||||
float wasteHeat,
|
||||
float energyUsage)
|
||||
{
|
||||
RadiatorTemperature = radiatorTemperature;
|
||||
Emissivity = emissivity;
|
||||
PumpedHeat = pumpedHeat;
|
||||
WasteHeat = wasteHeat;
|
||||
EnergyUsage = energyUsage;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,4 +141,10 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
|
|||
foreach(var sub in _subscriptions)
|
||||
sub.Dispose();
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float draw, float currentLoadRatio)
|
||||
{
|
||||
Draw = draw;
|
||||
CurrentLoadRatio = currentLoadRatio;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,4 +93,20 @@ public class ResourceScanner : Behavior, IAlwaysUpdatedBehavior
|
|||
MinimumDensity = Evaluate(_minimumDensity);
|
||||
ScanDuration = Evaluate(_scanDuration);
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
Guid scanTarget,
|
||||
int asteroid,
|
||||
float scanTime,
|
||||
float range,
|
||||
float minimumDensity,
|
||||
float scanDuration)
|
||||
{
|
||||
_scanTarget = scanTarget;
|
||||
Asteroid = asteroid;
|
||||
_scanTime = scanTime;
|
||||
Range = range;
|
||||
MinimumDensity = minimumDensity;
|
||||
ScanDuration = scanDuration;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,4 +151,17 @@ public class Sensor : Behavior, IEventBehavior
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(
|
||||
bool pinging,
|
||||
float pingCooldown,
|
||||
float pingLerp,
|
||||
float pingRadius)
|
||||
{
|
||||
_pinging = pinging;
|
||||
_pingCooldown = pingCooldown;
|
||||
_pingLerp = pingLerp;
|
||||
_pingRadius = pingRadius;
|
||||
_pingedEntities.Clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,10 @@ public class Shield : Behavior, IProgressBehavior
|
|||
}
|
||||
|
||||
public virtual float Progress => Item.ThermalPerformance;
|
||||
|
||||
public void RestoreRuntimeState(float efficiency, float energyUsage)
|
||||
{
|
||||
Efficiency = efficiency;
|
||||
EnergyUsage = energyUsage;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,17 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa
|
|||
RemoveModifier();
|
||||
_executed = false;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(bool applied, bool executed)
|
||||
{
|
||||
if (_stats == null)
|
||||
Initialize();
|
||||
if (applied && !_applied)
|
||||
ApplyModifier();
|
||||
if (!applied && _applied)
|
||||
RemoveModifier();
|
||||
_executed = executed;
|
||||
}
|
||||
}
|
||||
|
||||
public enum StatModifierType
|
||||
|
|
|
|||
|
|
@ -76,4 +76,10 @@ public class Thruster : Behavior, IAnalogBehavior
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float axis, float thrust)
|
||||
{
|
||||
Axis = axis;
|
||||
Thrust = thrust;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,9 @@ public class Trigger : Behavior, IActivatedBehavior
|
|||
public void Deactivate()
|
||||
{
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(bool pulled)
|
||||
{
|
||||
_pulled = pulled;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,4 +84,10 @@ public class TurretController : Behavior, IInitializableBehavior
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float shotSpeed, bool predictShots)
|
||||
{
|
||||
_shotSpeed = shotSpeed;
|
||||
_predictShots = predictShots;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,9 @@ public class VelocityLimit : Behavior
|
|||
Entity.Velocity = normalize(Entity.Velocity) * Limit;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float limit)
|
||||
{
|
||||
Limit = limit;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,6 +172,11 @@ public abstract class Weapon : Behavior, IActivatedBehavior
|
|||
_firing = false;
|
||||
}
|
||||
|
||||
public virtual void RestoreRuntimeState(bool firing)
|
||||
{
|
||||
_firing = firing;
|
||||
}
|
||||
|
||||
public float EvaluateRange()
|
||||
{
|
||||
return Evaluate(_range);
|
||||
|
|
|
|||
Loading…
Reference in a new issue