These are the easy ones anything else gets slightly spicier.
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!;
{
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
- else if (_net.IsServer)
- QueueDel(uid);
+ else
+ PredictedQueueDel(uid);
}
private void OnUnequipHand(EntityUid uid, UnremoveableComponent item, GotUnequippedHandEvent args)
{
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
- else if (_net.IsServer)
- QueueDel(uid);
+ else
+ PredictedQueueDel(uid);
}
private void OnDropped(EntityUid uid, UnremoveableComponent item, DroppedEvent args)
{
if (!item.DeleteOnDrop)
RemCompDeferred<UnremoveableComponent>(uid);
- else if (_net.IsServer)
- QueueDel(uid);
+ else
+ PredictedQueueDel(uid);
}
private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
/// </summary>
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)
/// <param name="slotName">Set this param if you have the name of the slot, it avoids unnecessary queries</param>
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))
/// <param name="virtualItem">The virtual item, if spawned</param>
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<VirtualItemComponent>(virtualItem.Value);
virtualItemComp.BlockingEntity = blockingEnt;
Dirty(virtualItem.Value, virtualItemComp);
return;
_transformSystem.DetachEntity(item, Transform(item));
- if (_netManager.IsServer)
- QueueDel(item);
+ PredictedQueueDel(item);
}
}
_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);
}
}
}
_popup.PopupClient(Loc.GetString("tech-disk-inserted"), target, args.User);
- if (_net.IsServer)
- QueueDel(ent);
+ PredictedQueueDel(ent);
args.Handled = true;
}
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;
_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<EntityUid>();
+ for (var i = 0; i < component.FreeHandsRequired; i++)
{
- var virtuals = new List<EntityUid>();
- 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);
- }
+ virtuals.Add(virtualItem.Value);
+ continue;
+ }
- return false;
+ foreach (var existingVirtual in virtuals)
+ {
+ QueueDel(existingVirtual);
}
+
+ return false;
}
var selfMessage = Loc.GetString("wieldable-component-successful-wield", ("item", used));