Files
tbd-station-14/Content.Server/Cooldown/ItemCooldownSystem.cs
2022-02-16 18:23:23 +11:00

35 lines
999 B
C#

using System;
using Content.Shared.Cooldown;
using Robust.Shared.GameObjects;
namespace Content.Server.Cooldown
{
public sealed class ItemCooldownSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ItemCooldownComponent, RefreshItemCooldownEvent>(OnItemCooldownRefreshed);
}
public void OnItemCooldownRefreshed(EntityUid uid, ItemCooldownComponent comp, RefreshItemCooldownEvent args)
{
comp.CooldownStart = args.LastAttackTime;
comp.CooldownEnd = args.CooldownEnd;
}
}
public sealed class RefreshItemCooldownEvent : EntityEventArgs
{
public TimeSpan LastAttackTime { get; }
public TimeSpan CooldownEnd { get; }
public RefreshItemCooldownEvent(TimeSpan lastAttackTime, TimeSpan cooldownEnd)
{
LastAttackTime = lastAttackTime;
CooldownEnd = cooldownEnd;
}
}
}