Skip to content

Commit

Permalink
predict redeeming properly
Browse files Browse the repository at this point in the history
  • Loading branch information
deltanedas committed Dec 22, 2024
1 parent ebe926e commit 3cf41ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Content.Shared/DeltaV/Salvage/Systems/MiningVoucherSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
using Content.Shared.Power.EntitySystems;
using Content.Shared.Whitelist;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Shared.DeltaV.Salvage.Systems;

public sealed class MiningVoucherSystem : EntitySystem
{
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
Expand Down Expand Up @@ -50,7 +54,10 @@ private void OnAfterInteract(Entity<MiningVoucherComponent> ent, ref AfterIntera
return;
}

_audio.PlayPvs(ent.Comp.RedeemSound, target);
if (!_timing.IsFirstTimePredicted)
return;

_audio.PlayPredicted(ent.Comp.RedeemSound, target, user);
Redeem(ent, index, user);
}

Expand All @@ -71,6 +78,9 @@ private void OnSelect(Entity<MiningVoucherComponent> ent, ref MiningVoucherSelec

public void Redeem(Entity<MiningVoucherComponent> ent, int index, EntityUid user)
{
if (_net.IsClient)
return;

var kit = _proto.Index(ent.Comp.Kits[index]);
var xform = Transform(ent);
foreach (var id in kit.Content)
Expand Down

0 comments on commit 3cf41ef

Please sign in to comment.