Skip to content

Commit

Permalink
Fix uplink (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: Doublechest <[email protected]>
  • Loading branch information
doublechest0 and Doublechest authored Sep 25, 2024
1 parent e908535 commit cffb706
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Content.Server/Store/Systems/StoreSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System.Linq;
using Robust.Shared.Timing;

namespace Content.Server.Store.Systems;

Expand All @@ -19,6 +20,7 @@ namespace Content.Server.Store.Systems;
/// </summary>
public sealed partial class StoreSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;

Expand Down Expand Up @@ -87,6 +89,13 @@ private void OnAfterInteract(EntityUid uid, CurrencyComponent component, AfterIn
if (!TryComp<StoreComponent>(args.Target, out var store))
return;

var curTime = _gameTiming.CurTime;

if (curTime < store.LastCurrencyInsertTime + store.CurrencyInsertDelay)
return;

store.LastCurrencyInsertTime = curTime;

var ev = new CurrencyInsertAttemptEvent(args.User, args.Target.Value, args.Used, store);
RaiseLocalEvent(args.Target.Value, ev);
if (ev.Cancelled)
Expand Down
17 changes: 16 additions & 1 deletion Content.Shared/Implants/SharedSubdermalImplantSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly SharedInteractionSystem _interaction = default!;

public const string BaseStorageId = "storagebase";

Expand All @@ -27,7 +28,7 @@ public override void Initialize()
SubscribeLocalEvent<SubdermalImplantComponent, EntGotRemovedFromContainerMessage>(OnRemove);

SubscribeLocalEvent<ImplantedComponent, MobStateChangedEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, AfterInteractUsingEvent>(RelayToImplantEvent);
SubscribeLocalEvent<ImplantedComponent, AfterInteractUsingEvent>(RelayToImplantInteractEvent);
SubscribeLocalEvent<ImplantedComponent, SuicideEvent>(RelayToImplantEvent);
}

Expand Down Expand Up @@ -159,6 +160,20 @@ public void WipeImplants(EntityUid target)
_container.CleanContainer(implantContainer);
}

private void RelayToImplantInteractEvent(EntityUid uid, ImplantedComponent component, AfterInteractUsingEvent args)
{
if (args.Handled)
return;

if (!_container.TryGetContainer(uid, ImplanterComponent.ImplantSlotId, out var implantContainer))
return;

foreach (var implant in implantContainer.ContainedEntities)
{
args.Handled = _interaction.InteractDoAfter(args.User, args.Used, implant, args.ClickLocation, args.CanReach);
}
}

//Relays from the implanted to the implant
private void RelayToImplantEvent<T>(EntityUid uid, ImplantedComponent component, T args) where T : notnull
{
Expand Down
7 changes: 7 additions & 0 deletions Content.Shared/Store/Components/StoreComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ namespace Content.Shared.Store.Components;
[RegisterComponent, NetworkedComponent]
public sealed partial class StoreComponent : Component
{
[DataField("insertDelay")]
[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan CurrencyInsertDelay = TimeSpan.FromSeconds(1.0);

[ViewVariables(VVAccess.ReadWrite)]
public TimeSpan LastCurrencyInsertTime;

[DataField]
public LocId Name = "store-ui-default-title";

Expand Down

0 comments on commit cffb706

Please sign in to comment.