2026-06-13 04:56:50 +01:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2020-12-22 03:13:43 +00:00
|
|
|
* 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;
|
2020-05-21 01:53:06 +01:00
|
|
|
using System.Linq;
|
|
|
|
|
using MessagePack;
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, MessagePackObject, Order(-20), RuntimeInspectable]
|
2020-05-21 01:53:06 +01:00
|
|
|
public class EnergyDrawData : BehaviorData
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, Key(1), RuntimeInspectable]
|
2021-01-14 23:47:08 +00:00
|
|
|
public PerformanceStat EnergyDraw = new PerformanceStat();
|
2026-06-13 04:56:50 +01:00
|
|
|
|
|
|
|
|
[Inspectable, Key(2)]
|
2020-05-21 01:53:06 +01:00
|
|
|
public bool PerSecond;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(EquippedItem item)
|
|
|
|
|
{
|
|
|
|
|
return new EnergyDraw(this, item);
|
|
|
|
|
}
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(ConsumableItemEffect item)
|
2020-05-21 01:53:06 +01:00
|
|
|
{
|
2021-04-12 04:20:52 +01:00
|
|
|
return new EnergyDraw(this, item);
|
2020-05-21 01:53:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public class EnergyDraw : Behavior
|
2020-05-21 01:53:06 +01:00
|
|
|
{
|
|
|
|
|
private EnergyDrawData _data;
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public EnergyDraw(EnergyDrawData data, EquippedItem item) : base(data, item)
|
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
2020-05-21 01:53:06 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public EnergyDraw(EnergyDrawData data, ConsumableItemEffect item) : base(data, item)
|
2020-05-21 01:53:06 +01:00
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override bool Execute(float dt)
|
2020-05-21 01:53:06 +01:00
|
|
|
{
|
2021-04-18 05:13:20 +01:00
|
|
|
return Entity.TryConsumeEnergy(Evaluate(_data.EnergyDraw) * (_data.PerSecond ? dt : 1));
|
2020-05-21 01:53:06 +01:00
|
|
|
}
|
|
|
|
|
}
|