Misc implant fixes (#17172)

This commit is contained in:
Leon Friedrich
2023-06-07 15:53:11 +12:00
committed by GitHub
parent 1a3f8f2c2c
commit 677ef07aa2
8 changed files with 132 additions and 79 deletions

View File

@@ -70,12 +70,12 @@ public sealed partial class StoreSystem : EntitySystem
if (args.Handled || !args.CanReach)
return;
if (args.Target == null || !TryComp<StoreComponent>(args.Target, out var store))
if (!TryComp<StoreComponent>(args.Target, out var store))
return;
// if the store can be locked, it must be unlocked first before inserting currency
var user = args.User;
if (TryComp<RingerUplinkComponent>(args.Target, out var uplink) && !uplink.Unlocked)
var ev = new CurrencyInsertAttemptEvent(args.User, args.Target.Value, args.Used, store);
RaiseLocalEvent(args.Target.Value, ev);
if (ev.Cancelled)
return;
args.Handled = TryAddCurrency(GetCurrencyValue(uid, component), args.Target.Value, store);
@@ -189,3 +189,19 @@ public sealed partial class StoreSystem : EntitySystem
}
}
}
public sealed class CurrencyInsertAttemptEvent : CancellableEntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Target;
public readonly EntityUid Used;
public readonly StoreComponent Store;
public CurrencyInsertAttemptEvent(EntityUid user, EntityUid target, EntityUid used, StoreComponent store)
{
User = user;
Target = target;
Used = used;
Store = store;
}
}