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,28 +2,43 @@
|
|||
* 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 MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
|
||||
public class VelocityConversionData : BehaviorData
|
||||
{
|
||||
[Inspectable, JsonProperty("lambda"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat Lambda = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new VelocityConversion(this, item);
|
||||
}
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new VelocityConversion(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class VelocityConversion : Behavior
|
||||
{
|
||||
private readonly PerformanceStat _lambda;
|
||||
private VelocityConversionData _data;
|
||||
|
||||
public VelocityConversion(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
public VelocityConversion(VelocityConversionData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_lambda = definition.PerformanceStat(1, new PerformanceStat());
|
||||
RegisterPerformanceStat("Lambda", _lambda);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public VelocityConversion(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
public VelocityConversion(VelocityConversionData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_lambda = definition.PerformanceStat(1, new PerformanceStat());
|
||||
RegisterPerformanceStat("Lambda", _lambda);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
var velocity = Entity.CultVelocity;
|
||||
Entity.CultVelocity = AetheriaMath.Damp(velocity, Entity.CultDirection * length(velocity), Evaluate(_lambda), dt);
|
||||
Entity.Velocity = AetheriaMath.Damp(Entity.Velocity, Entity.Direction * length(Entity.Velocity), Evaluate(_data.Lambda), dt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue