diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index eeb961537b..494fbdf032 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -51,7 +51,6 @@ namespace Content.Shared.Interaction public abstract partial class SharedInteractionSystem : EntitySystem { [Dependency] private readonly IGameTiming _gameTiming = default!; - [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; @@ -223,24 +222,24 @@ namespace Content.Shared.Interaction { if (!item.DeleteOnDrop) RemCompDeferred(uid); - else if (_net.IsServer) - QueueDel(uid); + else + PredictedQueueDel(uid); } private void OnUnequipHand(EntityUid uid, UnremoveableComponent item, GotUnequippedHandEvent args) { if (!item.DeleteOnDrop) RemCompDeferred(uid); - else if (_net.IsServer) - QueueDel(uid); + else + PredictedQueueDel(uid); } private void OnDropped(EntityUid uid, UnremoveableComponent item, DroppedEvent args) { if (!item.DeleteOnDrop) RemCompDeferred(uid); - else if (_net.IsServer) - QueueDel(uid); + else + PredictedQueueDel(uid); } private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid) diff --git a/Content.Shared/Inventory/VirtualItem/SharedVirtualItemSystem.cs b/Content.Shared/Inventory/VirtualItem/SharedVirtualItemSystem.cs index 9eac60adc4..393a4c09eb 100644 --- a/Content.Shared/Inventory/VirtualItem/SharedVirtualItemSystem.cs +++ b/Content.Shared/Inventory/VirtualItem/SharedVirtualItemSystem.cs @@ -157,11 +157,6 @@ public abstract class SharedVirtualItemSystem : EntitySystem /// public void DeleteInHandsMatching(EntityUid user, EntityUid matching) { - // Client can't currently predict deleting networked entities so we use this workaround, another - // problem can popup when the hands leave PVS for example and this avoids that too - if (_netManager.IsClient) - return; - foreach (var hand in _handsSystem.EnumerateHands(user)) { if (TryComp(hand.HeldEntity, out VirtualItemComponent? virt) && virt.BlockingEntity == matching) @@ -206,11 +201,6 @@ public abstract class SharedVirtualItemSystem : EntitySystem /// Set this param if you have the name of the slot, it avoids unnecessary queries public void DeleteInSlotMatching(EntityUid user, EntityUid matching, string? slotName = null) { - // Client can't currently predict deleting networked entities so we use this workaround, another - // problem can popup when the hands leave PVS for example and this avoids that too - if (_netManager.IsClient) - return; - if (slotName != null) { if (!_inventorySystem.TryGetSlotEntity(user, slotName, out var slotEnt)) @@ -244,14 +234,8 @@ public abstract class SharedVirtualItemSystem : EntitySystem /// The virtual item, if spawned public bool TrySpawnVirtualItem(EntityUid blockingEnt, EntityUid user, [NotNullWhen(true)] out EntityUid? virtualItem) { - if (_netManager.IsClient) - { - virtualItem = null; - return false; - } - var pos = Transform(user).Coordinates; - virtualItem = Spawn(VirtualItem, pos); + virtualItem = PredictedSpawnAttachedTo(VirtualItem, pos); var virtualItemComp = Comp(virtualItem.Value); virtualItemComp.BlockingEntity = blockingEnt; Dirty(virtualItem.Value, virtualItemComp); @@ -273,7 +257,6 @@ public abstract class SharedVirtualItemSystem : EntitySystem return; _transformSystem.DetachEntity(item, Transform(item)); - if (_netManager.IsServer) - QueueDel(item); + PredictedQueueDel(item); } } diff --git a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs index 9ddcb423b4..e63c6ac7b7 100644 --- a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs +++ b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs @@ -58,13 +58,7 @@ public sealed partial class EncryptionKeySystem : EntitySystem _hands.PickupOrDrop(args.User, ent, dropNear: true); } - if (!_timing.IsFirstTimePredicted) - return; - - // TODO add predicted pop-up overrides. - if (_net.IsServer) - _popup.PopupEntity(Loc.GetString("encryption-keys-all-extracted"), uid, args.User); - + _popup.PopupPredicted(Loc.GetString("encryption-keys-all-extracted"), uid, args.User); _audio.PlayPredicted(component.KeyExtractionSound, uid, args.User); } diff --git a/Content.Shared/Research/TechnologyDisk/Systems/TechnologyDiskSystem.cs b/Content.Shared/Research/TechnologyDisk/Systems/TechnologyDiskSystem.cs index 93c7c22471..4ca4728681 100644 --- a/Content.Shared/Research/TechnologyDisk/Systems/TechnologyDiskSystem.cs +++ b/Content.Shared/Research/TechnologyDisk/Systems/TechnologyDiskSystem.cs @@ -74,8 +74,7 @@ public sealed class TechnologyDiskSystem : EntitySystem } } _popup.PopupClient(Loc.GetString("tech-disk-inserted"), target, args.User); - if (_net.IsServer) - QueueDel(ent); + PredictedQueueDel(ent); args.Handled = true; } diff --git a/Content.Shared/Wieldable/SharedWieldableSystem.cs b/Content.Shared/Wieldable/SharedWieldableSystem.cs index b4a6144405..d3b8c4e4c6 100644 --- a/Content.Shared/Wieldable/SharedWieldableSystem.cs +++ b/Content.Shared/Wieldable/SharedWieldableSystem.cs @@ -21,6 +21,7 @@ using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Systems; using Content.Shared.Wieldable.Components; using Robust.Shared.Audio.Systems; +using Robust.Shared.Collections; using Robust.Shared.Network; using Robust.Shared.Timing; @@ -260,26 +261,21 @@ public abstract class SharedWieldableSystem : EntitySystem _audio.PlayPredicted(component.WieldSound, used, user); //This section handles spawning the virtual item(s) to occupy the required additional hand(s). - //Since the client can't currently predict entity spawning, only do this if this is running serverside. - //Remove this check if TrySpawnVirtualItem in SharedVirtualItemSystem is allowed to complete clientside. - if (_netManager.IsServer) + var virtuals = new ValueList(); + for (var i = 0; i < component.FreeHandsRequired; i++) { - var virtuals = new List(); - for (var i = 0; i < component.FreeHandsRequired; i++) + if (_virtualItem.TrySpawnVirtualItemInHand(used, user, out var virtualItem, true)) { - if (_virtualItem.TrySpawnVirtualItemInHand(used, user, out var virtualItem, true)) - { - virtuals.Add(virtualItem.Value); - continue; - } - - foreach (var existingVirtual in virtuals) - { - QueueDel(existingVirtual); - } - - return false; + virtuals.Add(virtualItem.Value); + continue; } + + foreach (var existingVirtual in virtuals) + { + QueueDel(existingVirtual); + } + + return false; } var selfMessage = Loc.GetString("wieldable-component-successful-wield", ("item", used));