Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -1,30 +1,48 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 System;
|
||||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
|
||||
public class EnergyDrawData : BehaviorData
|
||||
{
|
||||
[Inspectable, JsonProperty("draw"), Key(1), RuntimeInspectable]
|
||||
public PerformanceStat EnergyDraw = new PerformanceStat();
|
||||
|
||||
[Inspectable, JsonProperty("perSecond"), Key(2)]
|
||||
public bool PerSecond;
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new EnergyDraw(this, item);
|
||||
}
|
||||
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new EnergyDraw(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class EnergyDraw : Behavior
|
||||
{
|
||||
private readonly PerformanceStat _energyDraw;
|
||||
private readonly bool _perSecond;
|
||||
private EnergyDrawData _data;
|
||||
|
||||
public EnergyDraw(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
public EnergyDraw(EnergyDrawData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_energyDraw = definition.PerformanceStat(1, new PerformanceStat());
|
||||
_perSecond = definition.Bool(2);
|
||||
RegisterPerformanceStat(nameof(EnergyDraw), _energyDraw);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public EnergyDraw(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
public EnergyDraw(EnergyDrawData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_energyDraw = definition.PerformanceStat(1, new PerformanceStat());
|
||||
_perSecond = definition.Bool(2);
|
||||
RegisterPerformanceStat(nameof(EnergyDraw), _energyDraw);
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
return Entity.TryConsumeEnergy(Evaluate(_energyDraw) * (_perSecond ? dt : 1));
|
||||
return Entity.TryConsumeEnergy(Evaluate(_data.EnergyDraw) * (_data.PerSecond ? dt : 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue