Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -2,12 +2,35 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using static CultMath.math;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class CapacitorData : BehaviorData
|
||||
{
|
||||
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Capacity = new PerformanceStat();
|
||||
|
||||
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
|
||||
public PerformanceStat Efficiency = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new Capacitor(this, item);
|
||||
}
|
||||
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new Capacitor(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class Capacitor : Behavior
|
||||
{
|
||||
private readonly PerformanceStat _capacity;
|
||||
private readonly PerformanceStat _efficiency;
|
||||
private CapacitorData _data;
|
||||
|
||||
public float Charge { get; private set; }
|
||||
public float Capacity { get; private set; }
|
||||
|
|
@ -19,33 +42,20 @@ public class Capacitor : Behavior
|
|||
AddHeat(abs(charge) * (1-Efficiency));
|
||||
}
|
||||
|
||||
public Capacitor(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
public Capacitor(CapacitorData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_capacity = definition.PerformanceStat(1, new PerformanceStat());
|
||||
_efficiency = definition.PerformanceStat(2, new PerformanceStat());
|
||||
RegisterPerformanceStat(nameof(Capacity), _capacity);
|
||||
RegisterPerformanceStat(nameof(Efficiency), _efficiency);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public Capacitor(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
public Capacitor(CapacitorData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_capacity = definition.PerformanceStat(1, new PerformanceStat());
|
||||
_efficiency = definition.PerformanceStat(2, new PerformanceStat());
|
||||
RegisterPerformanceStat(nameof(Capacity), _capacity);
|
||||
RegisterPerformanceStat(nameof(Efficiency), _efficiency);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
Capacity = Evaluate(_capacity);
|
||||
Efficiency = Evaluate(_efficiency);
|
||||
Capacity = Evaluate(_data.Capacity);
|
||||
Efficiency = Evaluate(_data.Efficiency);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void RestoreRuntimeState(float charge, float capacity, float efficiency)
|
||||
{
|
||||
Charge = clamp(charge, 0, capacity);
|
||||
Capacity = capacity;
|
||||
Efficiency = efficiency;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue