2020-12-22 03:13:43 +00:00
|
|
|
|
/* 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;
|
2020-05-12 01:42:13 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
2020-05-31 03:10:11 +01:00
|
|
|
|
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10), Inspectable]
|
2020-05-12 01:42:13 +01:00
|
|
|
|
public class HeatData : BehaviorData
|
|
|
|
|
|
{
|
2020-05-31 03:10:11 +01:00
|
|
|
|
[InspectableField, JsonProperty("heat"), Key(1), RuntimeInspectable]
|
2020-05-12 01:42:13 +01:00
|
|
|
|
public PerformanceStat Heat = new PerformanceStat();
|
|
|
|
|
|
|
2020-05-21 01:53:06 +01:00
|
|
|
|
[InspectableField, JsonProperty("perSecond"), Key(2)]
|
|
|
|
|
|
public bool PerSecond;
|
|
|
|
|
|
|
2020-12-10 23:20:38 +00:00
|
|
|
|
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
2020-05-12 01:42:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
return new Heat(context, this, entity, item);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class Heat : IBehavior
|
|
|
|
|
|
{
|
|
|
|
|
|
private HeatData _data;
|
|
|
|
|
|
|
|
|
|
|
|
private Entity Entity { get; }
|
2020-12-10 23:20:38 +00:00
|
|
|
|
private EquippedItem Item { get; }
|
|
|
|
|
|
private ItemManager Context { get; }
|
2020-05-12 01:42:13 +01:00
|
|
|
|
|
|
|
|
|
|
public BehaviorData Data => _data;
|
|
|
|
|
|
|
2020-12-10 23:20:38 +00:00
|
|
|
|
public Heat(ItemManager context, HeatData data, Entity entity, EquippedItem item)
|
2020-05-12 01:42:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
_data = data;
|
|
|
|
|
|
Entity = entity;
|
|
|
|
|
|
Item = item;
|
|
|
|
|
|
Context = context;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-01-10 03:59:47 +00:00
|
|
|
|
public bool Execute(float delta)
|
2020-05-12 01:42:13 +01:00
|
|
|
|
{
|
2021-03-04 03:58:46 +00:00
|
|
|
|
Item.AddHeat(Context.Evaluate(_data.Heat, Item) * (_data.PerSecond ? delta : 1));
|
2020-12-27 22:18:22 +00:00
|
|
|
|
|
2020-05-12 01:42:13 +01:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|