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 Unity.Mathematics;
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
2026-06-14 10:23:09 +01:00
|
|
|
[Inspectable, Order(1000)]
|
2026-06-14 21:48:43 +01:00
|
|
|
public class WearConfig : RuntimeBehaviorConfig
|
2021-03-04 03:58:46 +00:00
|
|
|
{
|
2026-06-14 22:39:44 +01:00
|
|
|
[InspectableTemperature]
|
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
|
|
|
{
|
2026-06-14 21:48:43 +01:00
|
|
|
private WearConfig _data;
|
2021-03-04 03:58:46 +00:00
|
|
|
|
2026-06-14 21:48:43 +01:00
|
|
|
public Wear(WearConfig data, EquippedItem item) : base(data, item)
|
2021-04-18 05:13:20 +01:00
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
2026-06-14 21:48:43 +01:00
|
|
|
public Wear(WearConfig 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;
|
|
|
|
|
}
|
|
|
|
|
}
|