Behavior Canceling & Grouping

Behaviors are now grouped, behaviors within a group can cancel execution of the rest of the group
This commit is contained in:
hyperion51 2020-05-11 01:17:10 +01:00
commit fc94531566
35 changed files with 613 additions and 190 deletions

View file

@ -6,7 +6,7 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class VelocityLimitData : BehaviorData
{
[InspectableField, JsonProperty("topSpeed"), Key(0)]
[InspectableField, JsonProperty("topSpeed"), Key(1)]
public PerformanceStat TopSpeed = new PerformanceStat();
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
@ -40,10 +40,15 @@ public class VelocityLimit : IBehavior
{
}
public void Update(float delta)
public bool Update(float delta)
{
Limit = Context.Evaluate(_data.TopSpeed, Item, Entity);
if (length(Entity.Velocity) > Limit)
Entity.Velocity = normalize(Entity.Velocity) * Limit;
return true;
}
public void Remove()
{
}
}