Massive Item Behavior Refactoring
Item behaviors are now separated into more granular units, allowing designers to create more interesting items by combining behaviors
This commit is contained in:
parent
fc94531566
commit
8cd4ea3dc5
40 changed files with 822 additions and 445 deletions
42
Assets/Scripts/ServerShared/Behaviors/Heat.cs
Normal file
42
Assets/Scripts/ServerShared/Behaviors/Heat.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class HeatData : BehaviorData
|
||||
{
|
||||
[InspectableField, JsonProperty("heat"), Key(1)]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
{
|
||||
return new Heat(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
[UpdateOrder(10)]
|
||||
public class Heat : IBehavior
|
||||
{
|
||||
private HeatData _data;
|
||||
|
||||
private Entity Entity { get; }
|
||||
private Gear Item { get; }
|
||||
private GameContext Context { get; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
public Heat(GameContext context, HeatData data, Entity entity, Gear item)
|
||||
{
|
||||
_data = data;
|
||||
Entity = entity;
|
||||
Item = item;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
Entity.AddHeat(Context.Evaluate(_data.Heat, Item, Entity));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue