diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index 0d2152bf1e..cabfeadaf3 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -1,15 +1,16 @@ using System.Numerics; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Random.Helpers; using Content.Shared.Storage; using Content.Shared.Storage.Components; -using Robust.Shared.Random; +using Robust.Shared.Timing; namespace Content.Shared.Placeable; public sealed partial class PlaceableSurfaceSystem : EntitySystem { - [Dependency] private IRobustRandom _random = default!; + [Dependency] private IGameTiming _timing = default!; [Dependency] private SharedHandsSystem _handsSystem = default!; [Dependency] private SharedTransformSystem _transformSystem = default!; @@ -109,7 +110,8 @@ public sealed partial class PlaceableSurfaceSystem : EntitySystem foreach (var entity in args.DumpQueue) { - _transformSystem.SetWorldPositionRotation(entity, targetPos + _random.NextVector2Box() / 4, targetRot); + var rand = SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(entity)); + _transformSystem.SetWorldPositionRotation(entity, targetPos + rand.NextVector2Box() / 4, targetRot); } } } diff --git a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs index f682687e92..0f3b3a7741 100644 --- a/Content.Shared/Storage/EntitySystems/DumpableSystem.cs +++ b/Content.Shared/Storage/EntitySystems/DumpableSystem.cs @@ -2,17 +2,18 @@ using System.Linq; using Content.Shared.DoAfter; using Content.Shared.Interaction; using Content.Shared.Item; +using Content.Shared.Random.Helpers; using Content.Shared.Storage.Components; using Content.Shared.Verbs; using Robust.Shared.Audio.Systems; -using Robust.Shared.Random; +using Robust.Shared.Timing; using Robust.Shared.Utility; namespace Content.Shared.Storage.EntitySystems; public sealed partial class DumpableSystem : EntitySystem { - [Dependency] private IRobustRandom _random = default!; + [Dependency] private IGameTiming _timing = default!; [Dependency] private SharedAudioSystem _audio = default!; [Dependency] private SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private SharedTransformSystem _transformSystem = default!; @@ -64,7 +65,7 @@ public sealed partial class DumpableSystem : EntitySystem StartDoAfter(uid, args.Target, args.User, dumpable);//Had multiplier of 0.6f }, Text = Loc.GetString("dump-verb-name"), - Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/drop.svg.192dpi.png")), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/drop.svg.192dpi.png")), }; args.Verbs.Add(verb); } @@ -113,7 +114,7 @@ public sealed partial class DumpableSystem : EntitySystem delay += itemSize.Weight; } - delay *= (float) dumpable.DelayPerItem.TotalSeconds * dumpable.Multiplier; + delay *= (float)dumpable.DelayPerItem.TotalSeconds * dumpable.Multiplier; _doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, userUid, delay, new DumpableDoAfterEvent(), storageUid, target: targetUid, used: storageUid) { @@ -127,7 +128,8 @@ public sealed partial class DumpableSystem : EntitySystem if (args.Handled || args.Cancelled || !TryComp(uid, out var storage) || storage.Container.ContainedEntities.Count == 0 || args.Args.Target is not { } target) return; - var dumpQueue = new Queue(storage.Container.ContainedEntities); + // TODO: Remove OrderBy when this issue is fixed in RT https://github.com/space-wizards/RobustToolbox/issues/6241 + var dumpQueue = new Queue(storage.Container.ContainedEntities.OrderBy(e => GetNetEntity(e))); var evt = new DumpEvent(dumpQueue, args.Args.User, false, false); RaiseLocalEvent(target, ref evt); @@ -139,7 +141,8 @@ public sealed partial class DumpableSystem : EntitySystem foreach (var entity in dumpQueue) { var transform = Transform(entity); - _transformSystem.SetWorldPositionRotation(entity, targetPos + _random.NextVector2Box() / 4, _random.NextAngle(), transform); + var rand = SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(entity)); + _transformSystem.SetWorldPositionRotation(entity, targetPos + rand.NextVector2Box() / 4, rand.NextAngle(), transform); } return; diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 0f8ee7f63a..3af0c381e6 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -568,7 +568,8 @@ public abstract partial class SharedStorageSystem : EntitySystem _entityLookupSystem.GetEntitiesInRange(args.ClickLocation, storageComp.AreaInsertRadius, _entSet, LookupFlags.Dynamic | LookupFlags.Sundries); var delay = 0f; - foreach (var entity in _entSet) + // TODO: Remove OrderBy when this issue is fixed in RT https://github.com/space-wizards/RobustToolbox/issues/6241 + foreach (var entity in _entSet.OrderBy(e => GetNetEntity(e))) { if (entity == args.User || !_itemQuery.TryGetComponent(entity, out var itemComp) // Need comp to get item size to get weight @@ -1009,7 +1010,8 @@ public abstract partial class SharedStorageSystem : EntitySystem || Resolve(target, ref targetLock, false) && targetLock.Locked) return; - foreach (var entity in entities.ToArray()) + // TODO: Remove OrderBy when this issue is fixed in RT https://github.com/space-wizards/RobustToolbox/issues/6241 + foreach (var entity in entities.ToArray().OrderBy(e => GetNetEntity(e))) { Insert(target, entity, out _, user: user, targetComp, playSound: false); } @@ -1208,7 +1210,8 @@ public abstract partial class SharedStorageSystem : EntitySystem var toInsertCount = insertStack.Count; - foreach (var ent in storageComp.Container.ContainedEntities) + // TODO: Remove OrderBy when this issue is fixed in RT https://github.com/space-wizards/RobustToolbox/issues/6241 + foreach (var ent in storageComp.Container.ContainedEntities.OrderBy(e => GetNetEntity(e))) { if (!_stackQuery.TryGetComponent(ent, out var containedStack)) continue;