2021-03-04 03:58:46 +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.Collections.Generic;
|
|
|
|
|
using MessagePack;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, MessagePackObject, Order(1000), RuntimeInspectable]
|
2021-03-04 03:58:46 +00:00
|
|
|
public class WearData : BehaviorData
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[InspectableTemperature, Key(1)]
|
2021-03-05 14:31:18 +00:00
|
|
|
public bool PerSecond = true;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(EquippedItem item)
|
|
|
|
|
{
|
|
|
|
|
return new Wear(this, item);
|
|
|
|
|
}
|
|
|
|
|
public override Behavior CreateInstance(ConsumableItemEffect item)
|
2021-03-04 03:58:46 +00:00
|
|
|
{
|
2021-04-12 04:20:52 +01:00
|
|
|
return new Wear(this, item);
|
2021-03-04 03:58:46 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public class Wear : Behavior
|
2021-03-04 03:58:46 +00:00
|
|
|
{
|
|
|
|
|
private WearData _data;
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public Wear(WearData data, EquippedItem item) : base(data, item)
|
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
|
|
|
|
public Wear(WearData data, ConsumableItemEffect item) : base(data, item)
|
2021-03-04 03:58:46 +00:00
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override bool Execute(float dt)
|
2021-03-04 03:58:46 +00:00
|
|
|
{
|
2021-04-18 05:13:20 +01:00
|
|
|
CauseWearDamage(_data.PerSecond ? dt : 1);
|
2021-03-04 03:58:46 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|