2021-06-05 00:20:52 -07:00
|
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Cooldown;
|
2021-06-05 00:20:52 -07:00
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Cooldown
|
2021-06-05 00:20:52 -07:00
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class ItemCooldownSystem : EntitySystem
|
2021-06-05 00:20:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class RefreshItemCooldownEvent : EntityEventArgs
|
2021-06-05 00:20:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
public TimeSpan LastAttackTime { get; }
|
|
|
|
|
|
public TimeSpan CooldownEnd { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public RefreshItemCooldownEvent(TimeSpan lastAttackTime, TimeSpan cooldownEnd)
|
|
|
|
|
|
{
|
|
|
|
|
|
LastAttackTime = lastAttackTime;
|
|
|
|
|
|
CooldownEnd = cooldownEnd;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|