Aetheria/Assets/Scripts/ServerShared/Behaviors/Wear.cs

43 lines
1.1 KiB
C#
Raw Normal View History

/* 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;
[Inspectable, Order(1000)]
2026-06-14 21:48:43 +01:00
public class WearConfig : RuntimeBehaviorConfig
{
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
public override Behavior CreateInstance(EquippedItem item)
{
return new Wear(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Wear(this, item);
}
}
public class Wear : Behavior
{
2026-06-14 21:48:43 +01:00
private WearConfig _data;
2026-06-14 21:48:43 +01:00
public Wear(WearConfig data, EquippedItem item) : base(data, item)
{
_data = data;
}
2026-06-14 21:48:43 +01:00
public Wear(WearConfig data, ConsumableItemEffect item) : base(data, item)
{
_data = data;
}
public override bool Execute(float dt)
{
CauseWearDamage(_data.PerSecond ? dt : 1);
return true;
}
}