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
55
Assets/Scripts/ServerShared/Behaviors/Trigger.cs
Normal file
55
Assets/Scripts/ServerShared/Behaviors/Trigger.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class TriggerData : BehaviorData
|
||||
{
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
{
|
||||
return new Trigger(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
[UpdateOrder(-20)]
|
||||
public class Trigger : IBehavior
|
||||
{
|
||||
private TriggerData _data;
|
||||
|
||||
private Entity Entity { get; }
|
||||
private Gear Item { get; }
|
||||
private GameContext Context { get; }
|
||||
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
public bool _pulled;
|
||||
|
||||
public void Pull()
|
||||
{
|
||||
_pulled = true;
|
||||
}
|
||||
|
||||
public Trigger(GameContext context, TriggerData data, Entity entity, Gear item)
|
||||
{
|
||||
_data = data;
|
||||
Entity = entity;
|
||||
Item = item;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Update(float delta)
|
||||
{
|
||||
if (_pulled)
|
||||
{
|
||||
_pulled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue