mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-02-15 03:31:38 +01:00
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using Content.Shared._CorvaxGoob.OfferItem;
|
|
using Content.Shared.Alert;
|
|
using Content.Server.Hands.Systems;
|
|
using Content.Shared.Hands.Components;
|
|
|
|
namespace Content.Server._CorvaxGoob.OfferItem;
|
|
|
|
public sealed class OfferItemSystem : SharedOfferItemSystem
|
|
{
|
|
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
|
|
[Dependency] private readonly HandsSystem _hands = default!;
|
|
|
|
private float _offerAcc = 0;
|
|
private const float OfferAccMax = 3f;
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
_offerAcc += frameTime;
|
|
|
|
if (_offerAcc >= OfferAccMax)
|
|
_offerAcc -= OfferAccMax;
|
|
else
|
|
return;
|
|
|
|
var query = EntityQueryEnumerator<OfferItemComponent, HandsComponent>();
|
|
while (query.MoveNext(out var uid, out var offerItem, out var hands))
|
|
{
|
|
if (hands.ActiveHandId is null)
|
|
continue;
|
|
|
|
if (offerItem.Hand is not null && _hands.GetActiveItem(uid) is null)
|
|
if (offerItem.Target is not null)
|
|
{
|
|
UnReceive(offerItem.Target.Value, offerItem: offerItem);
|
|
offerItem.IsInOfferMode = false;
|
|
Dirty(uid, offerItem);
|
|
}
|
|
else
|
|
UnOffer(uid, offerItem);
|
|
|
|
if (!offerItem.IsInReceiveMode)
|
|
{
|
|
_alertsSystem.ClearAlert(uid, OfferAlert);
|
|
continue;
|
|
}
|
|
|
|
_alertsSystem.ShowAlert(uid, OfferAlert);
|
|
}
|
|
}
|
|
}
|