From 733a3d24349ac2117e74eb8bcbd0bf339957a583 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Mon, 18 Mar 2024 11:49:24 -0400 Subject: [PATCH 1/4] Replaced uses of Dirty(Component) with Dirty(Uid, Component) Modified some systems (notably pulling-related) to use uids. --- Content.Client/Weather/WeatherSystem.cs | 2 +- .../Systems/AdminVerbSystem.Smites.cs | 6 +- Content.Server/Alert/Click/StopBeingPulled.cs | 2 +- Content.Server/Alert/Click/StopPulling.cs | 2 +- .../EntitySystems/AtmosphereSystem.Map.cs | 6 +- .../Atmos/EntitySystems/GasAnalyzerSystem.cs | 8 +- .../EntitySystems/GasTileOverlaySystem.cs | 12 +- .../BarSign/Systems/BarSignSystem.cs | 2 +- .../Systems/ChameleonClothingSystem.cs | 4 +- Content.Server/Decals/DecalSystem.cs | 5 +- .../Systems/NetworkConfiguratorSystem.cs | 2 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 8 +- Content.Server/Dragon/DragonRiftSystem.cs | 2 +- .../Ensnaring/EnsnareableSystem.Ensnaring.cs | 6 +- Content.Server/Ensnaring/EnsnareableSystem.cs | 2 +- Content.Server/Gravity/GravitySystem.cs | 4 +- Content.Server/Hands/Systems/HandsSystem.cs | 27 +-- Content.Server/HotPotato/HotPotatoSystem.cs | 4 +- .../HumanoidAppearanceSystem.Modifier.cs | 6 +- .../Systems/HumanoidAppearanceSystem.cs | 10 +- .../Instruments/SwappableInstrumentSystem.cs | 2 +- .../EntitySystems/RotatingLightSystem.cs | 2 +- .../Materials/MaterialReclaimerSystem.cs | 2 +- Content.Server/Mech/Systems/MechSystem.cs | 10 +- .../NameIdentifier/NameIdentifierSystem.cs | 2 +- .../Physics/Controllers/ConveyorController.cs | 4 +- .../Physics/Controllers/PullController.cs | 24 ++- Content.Server/Pinpointer/NavMapSystem.cs | 20 +- .../PowerCell/PowerCellSystem.Draw.cs | 4 +- Content.Server/Pulling/PullingSystem.cs | 4 +- .../Research/Systems/ResearchSystem.Server.cs | 8 +- .../Systems/ResearchSystem.Technology.cs | 8 +- .../Shuttles/Systems/ShuttleConsoleSystem.cs | 2 +- Content.Server/Silicons/Borgs/BorgSystem.cs | 4 +- Content.Server/Sprite/RandomSpriteSystem.cs | 2 +- .../Traits/Assorted/ParacusiaSystem.cs | 6 +- .../Ranged/Systems/GunSystem.Battery.cs | 2 +- .../Ranged/Systems/GunSystem.Revolver.cs | 2 +- .../Systems/RandomInstrumentArtifactSystem.cs | 2 +- .../ArtifactInteractionTriggerSystem.cs | 2 +- .../Zombies/ZombieSystem.Transform.cs | 2 +- .../Administration/AdminFrozenSystem.cs | 5 +- .../Buckle/SharedBuckleSystem.Buckle.cs | 13 +- .../Buckle/SharedBuckleSystem.Strap.cs | 20 +- .../EntitySystems/AnchorableSystem.cs | 8 +- .../Containers/ItemSlot/ItemSlotsSystem.cs | 6 +- .../Damage/Systems/StaminaSystem.cs | 8 +- Content.Shared/Decals/SharedDecalSystem.cs | 2 +- Content.Shared/Dice/SharedDiceSystem.cs | 2 +- .../SharedElectrocutionSystem.cs | 2 +- Content.Shared/Emoting/EmoteSystem.cs | 2 +- .../Friction/TileFrictionController.cs | 2 +- .../Gravity/SharedFloatingVisualizerSystem.cs | 2 +- .../Gravity/SharedGravitySystem.Shake.cs | 4 +- .../SharedHumanoidAppearanceSystem.cs | 18 +- .../Implants/SharedImplanterSystem.cs | 4 +- .../Instruments/SharedInstrumentSystem.cs | 4 +- .../Interaction/SharedInteractionSystem.cs | 4 +- .../Light/SharedHandheldLightSystem.cs | 2 +- .../Light/SharedRgbLightControllerSystem.cs | 6 +- .../Mech/EntitySystems/SharedMechSystem.cs | 6 +- .../Systems/SpeedModifierContactsSystem.cs | 2 +- .../Nutrition/EntitySystems/HungerSystem.cs | 4 +- .../Controllers/SharedConveyorController.cs | 4 +- ...omponent.cs => SharedPullableComponent.cs} | 10 +- .../Components/SharedPullerComponent.cs | 2 +- .../Pulling/Events/PullAttemptEvent.cs | 11 +- Content.Shared/Pulling/Events/PullMessage.cs | 16 +- .../Pulling/Events/PullStartedMessage.cs | 13 +- .../Pulling/Events/PullStoppedMessage.cs | 13 +- .../Pulling/Events/StartPullAttemptEvent.cs | 23 +-- .../Pulling/Systems/SharedPullableSystem.cs | 5 +- .../Pulling/Systems/SharedPullerSystem.cs | 49 ++--- .../SharedPullingStateManagementSystem.cs | 189 ++++++++++-------- .../Systems/SharedPullingSystem.Actions.cs | 150 +++++++------- .../Pulling/Systems/SharedPullingSystem.cs | 103 ++++++---- Content.Shared/RCD/Systems/RCDAmmoSystem.cs | 4 +- Content.Shared/RCD/Systems/RCDSystem.cs | 2 +- .../Systems/DeployableBarrierSystem.cs | 2 +- .../EntitySystems/SharedEventHorizonSystem.cs | 8 +- Content.Shared/Stacks/SharedStackSystem.cs | 6 +- .../Standing/StandingStateSystem.cs | 2 +- .../StationRecordKeyStorageSystem.cs | 2 +- .../StatusEffect/StatusEffectsSystem.cs | 12 +- .../Storage/EntitySystems/BinSystem.cs | 6 +- Content.Shared/Stunnable/SharedStunSystem.cs | 32 ++- .../SubFloor/SharedTrayScannerSystem.cs | 2 +- .../Systems/LinkedEntitySystem.cs | 6 +- .../Systems/SharedPortalSystem.cs | 8 +- Content.Shared/Throwing/ThrownItemSystem.cs | 4 +- .../Marker/SharedDamageMarkerSystem.cs | 4 +- .../Weapons/Misc/SharedTetherGunSystem.cs | 22 +- .../Systems/RechargeBasicEntityAmmoSystem.cs | 8 +- .../Ranged/Systems/RechargeCycleAmmoSystem.cs | 2 +- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 2 +- Content.Shared/Weather/SharedWeatherSystem.cs | 6 +- 96 files changed, 537 insertions(+), 551 deletions(-) rename Content.Shared/Pulling/Components/{PullableComponent.cs => SharedPullableComponent.cs} (87%) diff --git a/Content.Client/Weather/WeatherSystem.cs b/Content.Client/Weather/WeatherSystem.cs index 24de0bc8c4c405..f1d490dcb24385 100644 --- a/Content.Client/Weather/WeatherSystem.cs +++ b/Content.Client/Weather/WeatherSystem.cs @@ -164,7 +164,7 @@ private void OnWeatherHandleState(EntityUid uid, WeatherComponent component, ref continue; // New weather - StartWeather(component, ProtoMan.Index(proto), weather.EndTime); + StartWeather(uid, component, ProtoMan.Index(proto), weather.EndTime); } } } diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index 8a819f59420c97..1047b4c9debfcd 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -638,13 +638,13 @@ private void AddSmiteVerbs(GetVerbsEvent args) { Text = "Remove gravity", Category = VerbCategory.Smite, - Icon = new SpriteSpecifier.Rsi(new ("/Textures/Structures/Machines/gravity_generator.rsi"), "off"), + Icon = new SpriteSpecifier.Rsi(new("/Textures/Structures/Machines/gravity_generator.rsi"), "off"), Act = () => { var grav = EnsureComp(args.Target); grav.Weightless = true; - Dirty(grav); + Dirty(args.Target, grav); }, Impact = LogImpact.Extreme, Message = Loc.GetString("admin-smite-remove-gravity-description"), @@ -741,7 +741,7 @@ private void AddSmiteVerbs(GetVerbsEvent args) var movementSpeed = EnsureComp(args.Target); (movementSpeed.BaseSprintSpeed, movementSpeed.BaseWalkSpeed) = (movementSpeed.BaseWalkSpeed, movementSpeed.BaseSprintSpeed); - Dirty(movementSpeed); + Dirty(args.Target, movementSpeed); _popupSystem.PopupEntity(Loc.GetString("admin-smite-run-walk-swap-prompt"), args.Target, args.Target, PopupType.LargeCaution); diff --git a/Content.Server/Alert/Click/StopBeingPulled.cs b/Content.Server/Alert/Click/StopBeingPulled.cs index 2cf076fbeed236..f8026fc5a39680 100644 --- a/Content.Server/Alert/Click/StopBeingPulled.cs +++ b/Content.Server/Alert/Click/StopBeingPulled.cs @@ -22,7 +22,7 @@ public void AlertClicked(EntityUid player) if (entityManager.TryGetComponent(player, out SharedPullableComponent? playerPullable)) { - entityManager.System().TryStopPull(playerPullable); + entityManager.System().TryStopPull(player, playerPullable); } } } diff --git a/Content.Server/Alert/Click/StopPulling.cs b/Content.Server/Alert/Click/StopPulling.cs index 00a4149598517e..ffaac2fe33d49f 100644 --- a/Content.Server/Alert/Click/StopPulling.cs +++ b/Content.Server/Alert/Click/StopPulling.cs @@ -20,7 +20,7 @@ public void AlertClicked(EntityUid player) var playerTarget = ps.GetPulled(player); if (playerTarget != default && entManager.TryGetComponent(playerTarget, out SharedPullableComponent? playerPullable)) { - ps.TryStopPull(playerPullable); + ps.TryStopPull(playerTarget, playerPullable); } } } diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Map.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Map.cs index 916191cb050960..ab59aab7e96818 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Map.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Map.cs @@ -58,7 +58,7 @@ public void SetMapAtmosphere(EntityUid uid, bool space, GasMixture mixture, MapA component.Space = space; component.Mixture = mixture; - Dirty(component); + Dirty(uid, component); } public void SetMapGasMixture(EntityUid uid, GasMixture? mixture, MapAtmosphereComponent? component = null) @@ -67,7 +67,7 @@ public void SetMapGasMixture(EntityUid uid, GasMixture? mixture, MapAtmosphereCo return; component.Mixture = mixture; - Dirty(component); + Dirty(uid, component); } public void SetMapSpace(EntityUid uid, bool space, MapAtmosphereComponent? component = null) @@ -76,6 +76,6 @@ public void SetMapSpace(EntityUid uid, bool space, MapAtmosphereComponent? compo return; component.Space = space; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs index 6a2c8f0a7e519d..d5563c170cca08 100644 --- a/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasAnalyzerSystem.cs @@ -93,9 +93,9 @@ private void ActivateAnalyzer(EntityUid uid, GasAnalyzerComponent component, Ent else component.LastPosition = null; component.Enabled = true; - Dirty(component); + Dirty(uid, component); UpdateAppearance(uid, component); - if(!HasComp(uid)) + if (!HasComp(uid)) AddComp(uid); UpdateAnalyzer(uid, component); } @@ -105,7 +105,7 @@ private void ActivateAnalyzer(EntityUid uid, GasAnalyzerComponent component, Ent /// private void OnDropped(EntityUid uid, GasAnalyzerComponent component, DroppedEvent args) { - if(args.User is var userId && component.Enabled) + if (args.User is var userId && component.Enabled) _popup.PopupEntity(Loc.GetString("gas-analyzer-shutoff"), userId, userId); DisableAnalyzer(uid, component, args.User); } @@ -122,7 +122,7 @@ private void DisableAnalyzer(EntityUid uid, GasAnalyzerComponent? component = nu _userInterface.TryClose(uid, GasAnalyzerUiKey.Key, actor.PlayerSession); component.Enabled = false; - Dirty(component); + Dirty(uid, component); UpdateAppearance(uid, component); RemCompDeferred(uid); } diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index 8ae9517379e8d4..94e095892a37e8 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -118,10 +118,11 @@ private void OnPvsToggle(bool value) } // PVS was turned off, ensure data gets sent to all clients. - foreach (var (grid, meta) in EntityQuery(true)) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var grid, out var meta)) { grid.ForceTick = _gameTiming.CurTick; - Dirty(grid, meta); + Dirty(uid, grid, meta); } } @@ -264,9 +265,10 @@ private bool UpdateChunkTile(GridAtmosphereComponent gridAtmosphere, GasOverlayC private void UpdateOverlayData(GameTick curTick) { // TODO parallelize? - foreach (var (overlay, gam, meta) in EntityQuery(true)) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var overlay, out var gam, out var meta)) { - bool changed = false; + var changed = false; foreach (var index in overlay.InvalidTiles) { var chunkIndex = GetGasChunkIndices(index); @@ -278,7 +280,7 @@ private void UpdateOverlayData(GameTick curTick) } if (changed) - Dirty(overlay, meta); + Dirty(uid, overlay, meta); overlay.InvalidTiles.Clear(); } diff --git a/Content.Server/BarSign/Systems/BarSignSystem.cs b/Content.Server/BarSign/Systems/BarSignSystem.cs index 4a481408452b5e..e42394f5a30441 100644 --- a/Content.Server/BarSign/Systems/BarSignSystem.cs +++ b/Content.Server/BarSign/Systems/BarSignSystem.cs @@ -34,7 +34,7 @@ private void OnMapInit(EntityUid uid, BarSignComponent component, MapInitEvent a _metaData.SetEntityDescription(uid, Loc.GetString(newPrototype.Description), meta); component.Current = newPrototype.ID; - Dirty(component); + Dirty(uid, component); } } } diff --git a/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs b/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs index 6fbfd9f3673717..23b772d99c0df6 100644 --- a/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs +++ b/Content.Server/Clothing/Systems/ChameleonClothingSystem.cs @@ -39,7 +39,7 @@ private void OnVerb(EntityUid uid, ChameleonClothingComponent component, GetVerb args.Verbs.Add(new InteractionVerb() { Text = Loc.GetString("chameleon-component-verb-text"), - Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")), + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")), Act = () => TryOpenUi(uid, args.User, component) }); } @@ -91,7 +91,7 @@ public void SetSelectedPrototype(EntityUid uid, string? protoId, bool forceUpdat UpdateIdentityBlocker(uid, component, proto); UpdateVisuals(uid, component); UpdateUi(uid, component); - Dirty(component); + Dirty(uid, component); } private void UpdateIdentityBlocker(EntityUid uid, ChameleonClothingComponent component, EntityPrototype proto) diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index ad225afe2247d8..0e6c1d5cebb9b4 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -89,10 +89,11 @@ private void OnPvsToggle(bool value) playerData.Clear(); } - foreach (var (grid, meta) in EntityQuery(true)) + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var grid, out var meta)) { grid.ForceTick = _timing.CurTick; - Dirty(grid, meta); + Dirty(uid, grid, meta); } } diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index 9a038f1c78a5b3..02c65381584649 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -255,7 +255,7 @@ private void SetMode(EntityUid configuratorUid, NetworkConfiguratorComponent con /// private void UpdateModeAppearance(EntityUid userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator) { - Dirty(configurator); + Dirty(configuratorUid, configurator); _appearanceSystem.SetData(configuratorUid, NetworkConfiguratorVisuals.Mode, configurator.LinkModeActive); var pitch = configurator.LinkModeActive ? 1 : 0.8f; diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 6938792315ce67..cfe69c0ca9222a 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -340,7 +340,7 @@ private void OnPowerChange(EntityUid uid, SharedDisposalUnitComponent component, if (!args.Powered) { component.NextFlush = null; - Dirty(component); + Dirty(uid, component); return; } @@ -396,7 +396,7 @@ private void UpdateState(EntityUid uid, DisposalsPressureState state, SharedDisp component.State = state; UpdateVisualState(uid, component); UpdateInterface(uid, component, component.Powered); - Dirty(component, metadata); + Dirty(uid, component, metadata); if (state == DisposalsPressureState.Ready) { @@ -477,7 +477,7 @@ private void Update(EntityUid uid, SharedDisposalUnitComponent component, MetaDa } if (count != component.RecentlyEjected.Count) - Dirty(component, metadata); + Dirty(uid, component, metadata); } public bool TryInsert(EntityUid unitId, EntityUid toInsertId, EntityUid? userId, DisposalUnitComponent? unit = null) @@ -784,7 +784,7 @@ public void QueueAutomaticEngage(EntityUid uid, SharedDisposalUnitComponent comp var flushTime = TimeSpan.FromSeconds(Math.Min((component.NextFlush ?? TimeSpan.MaxValue).TotalSeconds, automaticTime.TotalSeconds)); component.NextFlush = flushTime; - Dirty(component); + Dirty(uid, component); } public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null, bool doInsert = false) diff --git a/Content.Server/Dragon/DragonRiftSystem.cs b/Content.Server/Dragon/DragonRiftSystem.cs index f7d5cd783d45a6..7143280900cd92 100644 --- a/Content.Server/Dragon/DragonRiftSystem.cs +++ b/Content.Server/Dragon/DragonRiftSystem.cs @@ -67,7 +67,7 @@ public override void Update(float frameTime) if (comp.State < DragonRiftState.AlmostFinished && comp.Accumulator > comp.MaxAccumulator / 2f) { comp.State = DragonRiftState.AlmostFinished; - Dirty(comp); + Dirty(uid, comp); var location = xform.LocalPosition; _chat.DispatchGlobalAnnouncement(Loc.GetString("carp-rift-warning", ("location", location)), playSound: false, colorOverride: Color.Red); diff --git a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs index 169daca07aca1d..3781a159ba6ff8 100644 --- a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs +++ b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs @@ -93,7 +93,7 @@ public void TryEnsnare(EntityUid target, EntityUid ensnare, EnsnaringComponent c component.Ensnared = target; _container.Insert(ensnare, ensnareable.Container); ensnareable.IsEnsnared = true; - Dirty(ensnareable); + Dirty(target, ensnareable); UpdateAlert(target, ensnareable); var ev = new EnsnareEvent(component.WalkSpeed, component.SprintSpeed); @@ -107,7 +107,7 @@ public void TryEnsnare(EntityUid target, EntityUid ensnare, EnsnaringComponent c /// The entity that is freeing the target /// The entity used to ensnare /// The ensnaring component - public void TryFree(EntityUid target, EntityUid user, EntityUid ensnare, EnsnaringComponent component) + public void TryFree(EntityUid target, EntityUid user, EntityUid ensnare, EnsnaringComponent component) { //Don't do anything if they don't have the ensnareable component. if (!HasComp(target)) @@ -149,7 +149,7 @@ public void ForceFree(EntityUid ensnare, EnsnaringComponent component) _container.Remove(ensnare, ensnareable.Container, force: true); ensnareable.IsEnsnared = ensnareable.Container.ContainedEntities.Count > 0; - Dirty(ensnareable); + Dirty(component.Ensnared.Value, ensnareable); component.Ensnared = null; UpdateAlert(target, ensnareable); diff --git a/Content.Server/Ensnaring/EnsnareableSystem.cs b/Content.Server/Ensnaring/EnsnareableSystem.cs index f939e087e029c1..d732c5f3a39d61 100644 --- a/Content.Server/Ensnaring/EnsnareableSystem.cs +++ b/Content.Server/Ensnaring/EnsnareableSystem.cs @@ -45,7 +45,7 @@ private void OnDoAfter(EntityUid uid, EnsnareableComponent component, DoAfterEve } component.IsEnsnared = component.Container.ContainedEntities.Count > 0; - Dirty(component); + Dirty(uid, component); ensnaring.Ensnared = null; _hands.PickupOrDrop(args.Args.User, args.Args.Used.Value); diff --git a/Content.Server/Gravity/GravitySystem.cs b/Content.Server/Gravity/GravitySystem.cs index 5e0332ae491d7a..ea62d4a81954bc 100644 --- a/Content.Server/Gravity/GravitySystem.cs +++ b/Content.Server/Gravity/GravitySystem.cs @@ -41,7 +41,7 @@ public void RefreshGravity(EntityUid uid, GravityComponent? gravity = null) gravity.Enabled = enabled; var ev = new GravityChangedEvent(uid, enabled); RaiseLocalEvent(uid, ref ev, true); - Dirty(gravity); + Dirty(uid, gravity); if (HasComp(uid)) { @@ -71,7 +71,7 @@ public void EnableGravity(EntityUid uid, GravityComponent? gravity = null) gravity.Enabled = true; var ev = new GravityChangedEvent(uid, true); RaiseLocalEvent(uid, ref ev, true); - Dirty(gravity); + Dirty(uid, gravity); if (HasComp(uid)) { diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 62278064b685a2..4f1e7cbe517019 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -10,16 +10,12 @@ using Content.Shared.Explosion; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; -using Content.Shared.IdentityManagement; using Content.Shared.Input; using Content.Shared.Inventory.VirtualItem; using Content.Shared.Physics.Pull; -using Content.Shared.Popups; using Content.Shared.Pulling.Components; using Content.Shared.Stacks; using Content.Shared.Throwing; -using Robust.Shared.Audio; -using Robust.Shared.Audio.Systems; using Robust.Shared.GameStates; using Robust.Shared.Input.Binding; using Robust.Shared.Map; @@ -43,7 +39,7 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnDisarmed, before: new[] {typeof(StunSystem), typeof(StaminaSystem)}); + SubscribeLocalEvent(OnDisarmed, before: [typeof(StunSystem), typeof(StaminaSystem)]); SubscribeLocalEvent(HandlePullStarted); SubscribeLocalEvent(HandlePullStopped); @@ -88,9 +84,8 @@ private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent a return; // Break any pulls - if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled && - TryComp(pulled, out SharedPullableComponent? pullable)) - _pullingSystem.TryStopPull(pullable); + if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled) + _pullingSystem.TryStopPull(pulled); if (!_handsSystem.TryDrop(uid, component.ActiveHand!, null, checkActionBlocker: false)) return; @@ -130,13 +125,13 @@ private void HandleBodyPartRemoved(EntityUid uid, HandsComponent component, ref private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) { - if (args.Puller.Owner != uid) + if (args.Puller != uid) return; - if (TryComp(args.Puller.Owner, out var pullerComp) && !pullerComp.NeedsHands) + if (TryComp(args.Puller, out var pullerComp) && !pullerComp.NeedsHands) return; - if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid)) + if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled, uid)) { DebugTools.Assert("Unable to find available hand when starting pulling??"); } @@ -144,7 +139,7 @@ private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStar private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) { - if (args.Puller.Owner != uid) + if (args.Puller != uid) return; // Try find hand that is doing this pull. @@ -153,7 +148,7 @@ private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStop { if (hand.HeldEntity == null || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem) - || virtualItem.BlockingEntity != args.Pulled.Owner) + || virtualItem.BlockingEntity != args.Pulled) continue; QueueDel(hand.HeldEntity.Value); @@ -167,7 +162,7 @@ private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStop private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity) { - if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player)) + if (playerSession?.AttachedEntity is not { Valid: true } player || !Exists(player)) return false; return ThrowHeldItem(player, coordinates); @@ -192,7 +187,7 @@ hands.ActiveHandEntity is not { } throwEnt || { var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent(player).Coordinates, stack); - if (splitStack is not {Valid: true}) + if (splitStack is not { Valid: true }) return false; throwEnt = splitStack.Value; @@ -204,7 +199,7 @@ hands.ActiveHandEntity is not { } throwEnt || var length = direction.Length(); var distance = Math.Clamp(length, minDistance, hands.ThrowRange); - direction *= distance/length; + direction *= distance / length; var throwStrength = hands.ThrowForceMultiplier; diff --git a/Content.Server/HotPotato/HotPotatoSystem.cs b/Content.Server/HotPotato/HotPotatoSystem.cs index 8091eea6fdd329..115a7b6cb7664e 100644 --- a/Content.Server/HotPotato/HotPotatoSystem.cs +++ b/Content.Server/HotPotato/HotPotatoSystem.cs @@ -29,7 +29,7 @@ private void OnActiveTimer(EntityUid uid, HotPotatoComponent comp, ref ActiveTim comp.CanTransfer = false; _ambientSound.SetAmbience(uid, true); _damageOnHolding.SetEnabled(uid, true); - Dirty(comp); + Dirty(uid, comp); } private void OnMeleeHit(EntityUid uid, HotPotatoComponent comp, MeleeHitEvent args) @@ -56,6 +56,6 @@ private void OnMeleeHit(EntityUid uid, HotPotatoComponent comp, MeleeHitEvent ar break; } comp.CanTransfer = false; - Dirty(comp); + Dirty(uid, comp); } } diff --git a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs index 05a8b0622216f8..336116e78b0ec9 100644 --- a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs +++ b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.Modifier.cs @@ -29,7 +29,7 @@ private void OnVerbsRequest(EntityUid uid, HumanoidAppearanceComponent component { Text = "Modify markings", Category = VerbCategory.Tricks, - Icon = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"), + Icon = new SpriteSpecifier.Rsi(new("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"), Act = () => { _uiSystem.TryOpen(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession); @@ -63,7 +63,7 @@ private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent componen component.CustomBaseLayers[message.Layer] = message.Info.Value; } - Dirty(component); + Dirty(uid, component); if (message.ResendState) { @@ -88,7 +88,7 @@ private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component, } component.MarkingSet = message.MarkingSet; - Dirty(component); + Dirty(uid, component); if (message.ResendState) { diff --git a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs index 039128e32f64f5..89d28e51022dab 100644 --- a/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs +++ b/Content.Server/Humanoid/Systems/HumanoidAppearanceSystem.cs @@ -64,7 +64,7 @@ public void CloneAppearance(EntityUid source, EntityUid target, HumanoidAppearan grammar.Gender = sourceHumanoid.Gender; } - Dirty(targetHumanoid); + Dirty(target, targetHumanoid); } /// @@ -85,7 +85,7 @@ public void RemoveMarking(EntityUid uid, string marking, bool sync = true, Human humanoid.MarkingSet.Remove(prototype.MarkingCategory, marking); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -106,7 +106,7 @@ public void RemoveMarking(EntityUid uid, MarkingCategories category, int index, } humanoid.MarkingSet.Remove(category, index); - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -135,7 +135,7 @@ public void SetMarkingId(EntityUid uid, MarkingCategories category, int index, s } humanoid.MarkingSet.Replace(category, index, marking); - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -162,7 +162,7 @@ public void SetMarkingColor(EntityUid uid, MarkingCategories category, int index markings[index].SetColor(i, colors[i]); } - Dirty(humanoid); + Dirty(uid, humanoid); } /// diff --git a/Content.Server/Instruments/SwappableInstrumentSystem.cs b/Content.Server/Instruments/SwappableInstrumentSystem.cs index 3f3cfb9e6dba0d..9aef875cd65f25 100644 --- a/Content.Server/Instruments/SwappableInstrumentSystem.cs +++ b/Content.Server/Instruments/SwappableInstrumentSystem.cs @@ -35,7 +35,7 @@ private void AddStyleVerb(EntityUid uid, SwappableInstrumentComponent component, Priority = priority, Act = () => { - _sharedInstrument.SetInstrumentProgram(instrument, entry.Value.Item1, entry.Value.Item2); + _sharedInstrument.SetInstrumentProgram(uid, instrument, entry.Value.Item1, entry.Value.Item2); _popup.PopupEntity(Loc.GetString("swappable-instrument-component-style-set", ("style", entry.Key)), args.User, args.User); } diff --git a/Content.Server/Light/EntitySystems/RotatingLightSystem.cs b/Content.Server/Light/EntitySystems/RotatingLightSystem.cs index dd72b3a43e844b..7ef1357dc311e5 100644 --- a/Content.Server/Light/EntitySystems/RotatingLightSystem.cs +++ b/Content.Server/Light/EntitySystems/RotatingLightSystem.cs @@ -19,6 +19,6 @@ private void OnLightToggle(EntityUid uid, RotatingLightComponent comp, PointLigh return; comp.Enabled = args.Enabled; - Dirty(comp); + Dirty(uid, comp); } } diff --git a/Content.Server/Materials/MaterialReclaimerSystem.cs b/Content.Server/Materials/MaterialReclaimerSystem.cs index 8920daf60d0185..ae4444e059b164 100644 --- a/Content.Server/Materials/MaterialReclaimerSystem.cs +++ b/Content.Server/Materials/MaterialReclaimerSystem.cs @@ -130,7 +130,7 @@ public override bool TryFinishProcessItem(EntityUid uid, MaterialReclaimerCompon return false; Container.Remove(item, active.ReclaimingContainer); - Dirty(component); + Dirty(uid, component); // scales the output if the process was interrupted. var completion = 1f - Math.Clamp((float) Math.Round((active.EndTime - Timing.CurTime) / active.Duration), diff --git a/Content.Server/Mech/Systems/MechSystem.cs b/Content.Server/Mech/Systems/MechSystem.cs index 1012b9727df4f3..de8940c87637f6 100644 --- a/Content.Server/Mech/Systems/MechSystem.cs +++ b/Content.Server/Mech/Systems/MechSystem.cs @@ -110,7 +110,7 @@ private void OnInsertBattery(EntityUid uid, MechComponent component, EntInserted component.Energy = battery.CurrentCharge; component.MaxEnergy = battery.MaxCharge; - Dirty(component); + Dirty(uid, component); _actionBlocker.UpdateCanMove(uid); } @@ -140,7 +140,7 @@ private void OnMapInit(EntityUid uid, MechComponent component, MapInitEvent args component.Energy = component.MaxEnergy; _actionBlocker.UpdateCanMove(uid); - Dirty(component); + Dirty(uid, component); } private void OnRemoveEquipmentMessage(EntityUid uid, MechComponent component, MechEquipmentRemoveMessage args) @@ -341,7 +341,7 @@ public override bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, MechCompo { Log.Debug($"Battery charge was not equal to mech charge. Battery {batteryComp.CurrentCharge}. Mech {component.Energy}"); component.Energy = batteryComp.CurrentCharge; - Dirty(component); + Dirty(uid, component); } _actionBlocker.UpdateCanMove(uid); return true; @@ -361,7 +361,7 @@ public void InsertBattery(EntityUid uid, EntityUid toInsert, MechComponent? comp _actionBlocker.UpdateCanMove(uid); - Dirty(component); + Dirty(uid, component); UpdateUserInterface(uid, component); } @@ -376,7 +376,7 @@ public void RemoveBattery(EntityUid uid, MechComponent? component = null) _actionBlocker.UpdateCanMove(uid); - Dirty(component); + Dirty(uid, component); UpdateUserInterface(uid, component); } diff --git a/Content.Server/NameIdentifier/NameIdentifierSystem.cs b/Content.Server/NameIdentifier/NameIdentifierSystem.cs index 87953d518b3a1f..eefd4357cb3325 100644 --- a/Content.Server/NameIdentifier/NameIdentifierSystem.cs +++ b/Content.Server/NameIdentifier/NameIdentifierSystem.cs @@ -113,7 +113,7 @@ private void OnMapInit(EntityUid uid, NameIdentifierComponent component, MapInit _metaData.SetEntityName(uid, group.FullName ? uniqueName : $"{meta.EntityName} ({uniqueName})", meta); - Dirty(component); + Dirty(uid, component); } private void InitialSetupPrototypes() diff --git a/Content.Server/Physics/Controllers/ConveyorController.cs b/Content.Server/Physics/Controllers/ConveyorController.cs index 42279bb7496ee3..b3508025cb94f3 100644 --- a/Content.Server/Physics/Controllers/ConveyorController.cs +++ b/Content.Server/Physics/Controllers/ConveyorController.cs @@ -67,7 +67,7 @@ private void OnPowerChanged(EntityUid uid, ConveyorComponent component, ref Powe { component.Powered = args.Powered; UpdateAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } private void UpdateAppearance(EntityUid uid, ConveyorComponent component) @@ -106,7 +106,7 @@ private void SetState(EntityUid uid, ConveyorState state, ConveyorComponent? com _materialReclaimer.SetReclaimerEnabled(uid, component.State != ConveyorState.Off); UpdateAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } /// diff --git a/Content.Server/Physics/Controllers/PullController.cs b/Content.Server/Physics/Controllers/PullController.cs index 8f58f807aaee53..98c6f10e710261 100644 --- a/Content.Server/Physics/Controllers/PullController.cs +++ b/Content.Server/Physics/Controllers/PullController.cs @@ -81,7 +81,7 @@ private void OnPullerMove(EntityUid uid, SharedPullerComponent component, ref Mo if (TryComp(pullable, out var physics)) PhysicsSystem.WakeBody(pullable, body: physics); - _pullableSystem.StopMoveTo(pullableComponent); + _pullableSystem.StopMoveTo((pullable, pullableComponent)); } private void UpdatePulledRotation(EntityUid puller, EntityUid pulled) @@ -131,30 +131,32 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) // This can include if leaving the Moving set due to not being pulled anymore, // or due to being deleted. - if (pullable.Deleted) + if (!TryComp(pullable, out var pullableComp)) continue; - if (pullable.MovingTo == null) + if (pullableComp.Deleted) continue; - if (pullable.Puller is not {Valid: true} puller) + if (pullableComp.MovingTo == null) continue; - var pullableEnt = pullable.Owner; - var pullableXform = Transform(pullableEnt); + if (pullableComp.Puller is not { Valid: true } puller) + continue; + + var pullableXform = Transform(pullable); var pullerXform = Transform(puller); // Now that's over with... var pullerPosition = pullerXform.MapPosition; - var movingTo = pullable.MovingTo.Value.ToMap(EntityManager, _transform); + var movingTo = pullableComp.MovingTo.Value.ToMap(EntityManager, _transform); if (movingTo.MapId != pullerPosition.MapId) { _pullableSystem.StopMoveTo(pullable); continue; } - if (!TryComp(pullableEnt, out var physics) || + if (!TryComp(pullable, out var physics) || physics.BodyType == BodyType.Static || movingTo.MapId != pullableXform.MapID) { @@ -170,7 +172,7 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) if (diffLength < MaximumSettleDistance && physics.LinearVelocity.Length() < MaximumSettleVelocity) { - PhysicsSystem.SetLinearVelocity(pullableEnt, Vector2.Zero, body: physics); + PhysicsSystem.SetLinearVelocity(pullable, Vector2.Zero, body: physics); _pullableSystem.StopMoveTo(pullable); continue; } @@ -188,10 +190,10 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) accel -= physics.LinearVelocity * SettleShutdownMultiplier * scaling; } - PhysicsSystem.WakeBody(pullableEnt, body: physics); + PhysicsSystem.WakeBody(pullable, body: physics); var impulse = accel * physics.Mass * frameTime; - PhysicsSystem.ApplyLinearImpulse(pullableEnt, impulse, body: physics); + PhysicsSystem.ApplyLinearImpulse(pullable, impulse, body: physics); // if the puller is weightless or can't move, then we apply the inverse impulse (Newton's third law). // doing it under gravity produces an unsatisfying wiggling when pulling. diff --git a/Content.Server/Pinpointer/NavMapSystem.cs b/Content.Server/Pinpointer/NavMapSystem.cs index bf3a3b29988806..36fb39975e54d1 100644 --- a/Content.Server/Pinpointer/NavMapSystem.cs +++ b/Content.Server/Pinpointer/NavMapSystem.cs @@ -54,7 +54,7 @@ public override void Initialize() private void OnStationInit(StationGridAddedEvent ev) { var comp = EnsureComp(ev.GridId); - RefreshGrid(comp, Comp(ev.GridId)); + RefreshGrid(ev.GridId, comp, Comp(ev.GridId)); } private void OnNavMapBeaconStartup(EntityUid uid, NavMapBeaconComponent component, ComponentStartup args) @@ -164,7 +164,7 @@ private void OnNavMapStartup(EntityUid uid, NavMapComponent component, Component if (!TryComp(uid, out var grid)) return; - RefreshGrid(component, grid); + RefreshGrid(uid, component, grid); } private void OnNavMapSplit(ref GridSplitEvent args) @@ -177,13 +177,13 @@ private void OnNavMapSplit(ref GridSplitEvent args) foreach (var grid in args.NewGrids) { var newComp = EnsureComp(grid); - RefreshGrid(newComp, gridQuery.GetComponent(grid)); + RefreshGrid(grid, newComp, gridQuery.GetComponent(grid)); } - RefreshGrid(comp, gridQuery.GetComponent(args.Grid)); + RefreshGrid(args.Grid, comp, gridQuery.GetComponent(args.Grid)); } - private void RefreshGrid(NavMapComponent component, MapGridComponent grid) + private void RefreshGrid(EntityUid uid, NavMapComponent component, MapGridComponent grid) { component.Chunks.Clear(); @@ -199,7 +199,7 @@ private void RefreshGrid(NavMapComponent component, MapGridComponent grid) component.Chunks[chunkOrigin] = chunk; } - RefreshTile(grid, component, chunk, tile.Value.GridIndices); + RefreshTile(uid, grid, component, chunk, tile.Value.GridIndices); } } @@ -291,7 +291,7 @@ private void OnReAnchor(ref ReAnchorEvent ev) if (navMap.Chunks.TryGetValue(chunkOrigin, out var chunk)) { - RefreshTile(oldGrid, navMap, chunk, ev.TilePos); + RefreshTile(ev.OldGrid, oldGrid, navMap, chunk, ev.TilePos); } } @@ -318,10 +318,10 @@ private void HandleAnchor(TransformComponent xform) navMap.Chunks[chunkOrigin] = chunk; } - RefreshTile(grid, navMap, chunk, tile); + RefreshTile(xform.GridUid.Value, grid, navMap, chunk, tile); } - private void RefreshTile(MapGridComponent grid, NavMapComponent component, NavMapChunk chunk, Vector2i tile) + private void RefreshTile(EntityUid uid, MapGridComponent grid, NavMapComponent component, NavMapChunk chunk, Vector2i tile) { var relative = SharedMapSystem.GetChunkRelative(tile, ChunkSize); var existing = chunk.TileData; @@ -356,7 +356,7 @@ private void RefreshTile(MapGridComponent grid, NavMapComponent component, NavMa if (existing == chunk.TileData) return; - Dirty(component); + Dirty(uid, component); } /// diff --git a/Content.Server/PowerCell/PowerCellSystem.Draw.cs b/Content.Server/PowerCell/PowerCellSystem.Draw.cs index 8e960357b7a0a3..4155a4f6becf38 100644 --- a/Content.Server/PowerCell/PowerCellSystem.Draw.cs +++ b/Content.Server/PowerCell/PowerCellSystem.Draw.cs @@ -67,7 +67,7 @@ private void OnDrawChargeChanged(EntityUid uid, PowerCellDrawComponent component { component.CanDraw = canDraw; component.CanUse = canUse; - Dirty(component); + Dirty(uid, component); } } @@ -80,7 +80,7 @@ private void OnDrawCellChanged(EntityUid uid, PowerCellDrawComponent component, { component.CanDraw = canDraw; component.CanUse = canUse; - Dirty(component); + Dirty(uid, component); } } } diff --git a/Content.Server/Pulling/PullingSystem.cs b/Content.Server/Pulling/PullingSystem.cs index 69bb7c93704ede..512d221dab6f7b 100644 --- a/Content.Server/Pulling/PullingSystem.cs +++ b/Content.Server/Pulling/PullingSystem.cs @@ -27,7 +27,7 @@ public override void Initialize() private void HandleReleasePulledObject(ICommonSession? session) { - if (session?.AttachedEntity is not {Valid: true} player) + if (session?.AttachedEntity is not { Valid: true } player) { return; } @@ -42,7 +42,7 @@ private void HandleReleasePulledObject(ICommonSession? session) return; } - TryStopPull(pullable); + TryStopPull((pulled.Value, pullable)); } } } diff --git a/Content.Server/Research/Systems/ResearchSystem.Server.cs b/Content.Server/Research/Systems/ResearchSystem.Server.cs index 2a802a91a321eb..09ca7ed15c27a2 100644 --- a/Content.Server/Research/Systems/ResearchSystem.Server.cs +++ b/Content.Server/Research/Systems/ResearchSystem.Server.cs @@ -18,7 +18,7 @@ private void OnServerStartup(EntityUid uid, ResearchServerComponent component, C var unusedId = EntityQuery(true) .Max(s => s.Id) + 1; component.Id = unusedId; - Dirty(component); + Dirty(uid, component); } private void OnServerShutdown(EntityUid uid, ResearchServerComponent component, ComponentShutdown args) @@ -74,7 +74,7 @@ public void RegisterClient(EntityUid client, EntityUid server, ResearchClientCom SyncClientWithServer(client, clientComponent: clientComponent); if (dirtyServer) - Dirty(serverComponent); + Dirty(server, serverComponent); var ev = new ResearchRegistrationChangedEvent(server); RaiseLocalEvent(client, ref ev); @@ -117,7 +117,7 @@ public void UnregisterClient(EntityUid client, EntityUid server, ResearchClientC if (dirtyServer) { - Dirty(serverComponent); + Dirty(server, serverComponent); } var ev = new ResearchRegistrationChangedEvent(null); @@ -167,6 +167,6 @@ public void ModifyServerPoints(EntityUid uid, int points, ResearchServerComponen { RaiseLocalEvent(client, ref ev); } - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Server/Research/Systems/ResearchSystem.Technology.cs b/Content.Server/Research/Systems/ResearchSystem.Technology.cs index 107d51ccd8ca19..9bd71cf7c6ec85 100644 --- a/Content.Server/Research/Systems/ResearchSystem.Technology.cs +++ b/Content.Server/Research/Systems/ResearchSystem.Technology.cs @@ -21,7 +21,7 @@ public void Sync(EntityUid primaryUid, EntityUid otherUid, TechnologyDatabaseCom primaryDb.UnlockedTechnologies = otherDb.UnlockedTechnologies; primaryDb.UnlockedRecipes = otherDb.UnlockedRecipes; - Dirty(primaryDb); + Dirty(primaryUid, primaryDb); var ev = new TechnologyDatabaseModifiedEvent(); RaiseLocalEvent(primaryUid, ref ev); @@ -125,7 +125,7 @@ public void AddTechnology(EntityUid uid, TechnologyPrototype technology, Technol continue; component.UnlockedRecipes.Add(unlock); } - Dirty(component); + Dirty(uid, component); var ev = new TechnologyDatabaseModifiedEvent(); RaiseLocalEvent(uid, ref ev); @@ -144,7 +144,7 @@ public void AddLatheRecipe(EntityUid uid, string recipe, TechnologyDatabaseCompo return; component.UnlockedRecipes.Add(recipe); - Dirty(component); + Dirty(uid, component); var ev = new TechnologyDatabaseModifiedEvent(); RaiseLocalEvent(uid, ref ev); @@ -185,6 +185,6 @@ private void OnDatabaseRegistrationChanged(EntityUid uid, TechnologyDatabaseComp component.SupportedDisciplines = new List(); component.UnlockedTechnologies = new List(); component.UnlockedRecipes = new List(); - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs index c47c519d5de214..f0368ed3a95cb7 100644 --- a/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleConsoleSystem.cs @@ -318,7 +318,7 @@ public void AddPilot(EntityUid uid, EntityUid entity, ShuttleConsoleComponent co pilotComponent.Console = uid; ActionBlockerSystem.UpdateCanMove(entity); pilotComponent.Position = EntityManager.GetComponent(entity).Coordinates; - Dirty(pilotComponent); + Dirty(entity, pilotComponent); } public void RemovePilot(EntityUid pilotUid, PilotComponent pilotComponent) diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 869c2797047ddf..0f14fef0ed6ae4 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -281,7 +281,7 @@ public void EnableBorgAbilities(EntityUid uid, BorgChassisComponent component, P component.Activated = true; InstallAllModules(uid, component); - Dirty(component); + Dirty(uid, component); _movementSpeedModifier.RefreshMovementSpeedModifiers(uid); } @@ -295,7 +295,7 @@ public void DisableBorgAbilities(EntityUid uid, BorgChassisComponent component) component.Activated = false; DisableAllModules(uid, component); - Dirty(component); + Dirty(uid, component); _movementSpeedModifier.RefreshMovementSpeedModifiers(uid); } diff --git a/Content.Server/Sprite/RandomSpriteSystem.cs b/Content.Server/Sprite/RandomSpriteSystem.cs index 5d04dd2f5a6ebc..7f81f4bdd45f99 100644 --- a/Content.Server/Sprite/RandomSpriteSystem.cs +++ b/Content.Server/Sprite/RandomSpriteSystem.cs @@ -63,7 +63,7 @@ private void OnMapInit(EntityUid uid, RandomSpriteComponent component, MapInitEv } } - Dirty(component); + Dirty(uid, component); } private void OnGetState(EntityUid uid, RandomSpriteComponent component, ref ComponentGetState args) diff --git a/Content.Server/Traits/Assorted/ParacusiaSystem.cs b/Content.Server/Traits/Assorted/ParacusiaSystem.cs index 4b0205ff536a1b..fbbeb9f1a70208 100644 --- a/Content.Server/Traits/Assorted/ParacusiaSystem.cs +++ b/Content.Server/Traits/Assorted/ParacusiaSystem.cs @@ -12,7 +12,7 @@ public void SetSounds(EntityUid uid, SoundSpecifier sounds, ParacusiaComponent? return; } component.Sounds = sounds; - Dirty(component); + Dirty(uid, component); } public void SetTime(EntityUid uid, float minTime, float maxTime, ParacusiaComponent? component = null) @@ -23,7 +23,7 @@ public void SetTime(EntityUid uid, float minTime, float maxTime, ParacusiaCompon } component.MinTimeBetweenIncidents = minTime; component.MaxTimeBetweenIncidents = maxTime; - Dirty(component); + Dirty(uid, component); } public void SetDistance(EntityUid uid, float maxSoundDistance, ParacusiaComponent? component = null) @@ -33,6 +33,6 @@ public void SetDistance(EntityUid uid, float maxSoundDistance, ParacusiaComponen return; } component.MaxSoundDistance = maxSoundDistance; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs index 25010b22333a32..0dcd92f94170f3 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.Battery.cs @@ -51,7 +51,7 @@ private void UpdateShots(EntityUid uid, BatteryAmmoProviderComponent component, if (component.Shots != shots || component.Capacity != maxShots) { - Dirty(component); + Dirty(uid, component); } component.Shots = shots; diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.Revolver.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.Revolver.cs index 6ff47507299f06..59e53f1f72a0ae 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.Revolver.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.Revolver.cs @@ -13,6 +13,6 @@ protected override void SpinRevolver(EntityUid revolverUid, RevolverAmmoProvider return; component.CurrentIndex = index; - Dirty(component); + Dirty(revolverUid, component); } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs index 8945b867954aed..118bc396a72ce1 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RandomInstrumentArtifactSystem.cs @@ -18,6 +18,6 @@ public override void Initialize() private void OnStartup(EntityUid uid, RandomInstrumentArtifactComponent component, ComponentStartup args) { var instrument = EnsureComp(uid); - _instrument.SetInstrumentProgram(instrument, (byte) _random.Next(0, 127), 0); + _instrument.SetInstrumentProgram(uid, instrument, (byte) _random.Next(0, 127), 0); } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs index 239b6741608171..d4605b561bc142 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs @@ -22,7 +22,7 @@ private void OnPull(EntityUid uid, ArtifactInteractionTriggerComponent component if (!component.PullActivation) return; - _artifactSystem.TryActivateArtifact(uid, args.Puller.Owner); + _artifactSystem.TryActivateArtifact(uid, args.Puller); } private void OnAttack(EntityUid uid, ArtifactInteractionTriggerComponent component, AttackedEvent args) diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index 8ae10d7383449d..2615ad688ff3c2 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -186,7 +186,7 @@ public void ZombifyEntity(EntityUid target, MobStateComponent? mobState = null) Dirty(target, pryComp); } - Dirty(melee); + Dirty(target, melee); //The zombie gets the assigned damage weaknesses and strengths _damageable.SetDamageModifierSetId(target, "Zombie"); diff --git a/Content.Shared/Administration/AdminFrozenSystem.cs b/Content.Shared/Administration/AdminFrozenSystem.cs index 14438cc59120cc..6725ab6290aeb0 100644 --- a/Content.Shared/Administration/AdminFrozenSystem.cs +++ b/Content.Shared/Administration/AdminFrozenSystem.cs @@ -1,13 +1,10 @@ using Content.Shared.ActionBlocker; using Content.Shared.Interaction.Events; using Content.Shared.Item; -using Content.Shared.Movement; using Content.Shared.Movement.Events; using Content.Shared.Physics.Pull; using Content.Shared.Pulling; using Content.Shared.Pulling.Components; -using Content.Shared.Pulling.Events; -using Content.Shared.Stunnable; using Content.Shared.Throwing; namespace Content.Shared.Administration; @@ -47,7 +44,7 @@ private void OnStartup(EntityUid uid, AdminFrozenComponent component, ComponentS { if (TryComp(uid, out var pullable)) { - _pulling.TryStopPull(pullable); + _pulling.TryStopPull((uid, pullable)); } UpdateCanMove(uid, component, args); diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index b58bdf83e4929a..087b441682caac 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -54,7 +54,7 @@ private void OnBuckleComponentShutdown(EntityUid uid, BuckleComponent component, private void OnBuckleMove(EntityUid uid, BuckleComponent component, ref MoveEvent ev) { - if (component.BuckledTo is not {} strapUid) + if (component.BuckledTo is not { } strapUid) return; if (!TryComp(strapUid, out var strapComp)) @@ -85,7 +85,7 @@ private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsE { Act = () => TryUnbuckle(uid, args.User, buckleComp: component), Text = Loc.GetString("verb-categories-unbuckle"), - Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/unbuckle.svg.192dpi.png")) + Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/unbuckle.svg.192dpi.png")) }; if (args.Target == args.User && args.Using == null) @@ -191,7 +191,7 @@ private void SetBuckledTo(EntityUid buckleUid, EntityUid? strapUid, StrapCompone ActionBlocker.UpdateCanMove(buckleUid); UpdateBuckleStatus(buckleUid, buckleComp, strapComp); - Dirty(buckleComp); + Dirty(buckleUid, buckleComp); } /// @@ -352,7 +352,7 @@ public bool TryBuckle(EntityUid buckleUid, EntityUid userUid, EntityUid strapUid { if (ownerPullable.Puller != null) { - _pulling.TryStopPull(ownerPullable); + _pulling.TryStopPull(buckleUid, ownerPullable); } } @@ -366,7 +366,7 @@ public bool TryBuckle(EntityUid buckleUid, EntityUid userUid, EntityUid strapUid if (toPullable.Puller == buckleUid) { // can't pull it and buckle to it at the same time - _pulling.TryStopPull(toPullable); + _pulling.TryStopPull(strapUid, toPullable); } } @@ -468,8 +468,7 @@ public bool TryUnbuckle(EntityUid buckleUid, EntityUid userUid, bool force = fal if (strapComp.BuckledEntities.Remove(buckleUid)) { strapComp.OccupiedSize -= buckleComp.Size; - //Dirty(strapUid); - Dirty(strapComp); + Dirty(strapUid, strapComp); } _joints.RefreshRelay(buckleUid); diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs index 7be54360741acb..147af42e728578 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Strap.cs @@ -20,22 +20,22 @@ private void InitializeStrap() { SubscribeLocalEvent(OnStrapStartup); SubscribeLocalEvent(OnStrapShutdown); - SubscribeLocalEvent((_, c, _) => StrapRemoveAll(c)); + SubscribeLocalEvent((e, c, _) => StrapRemoveAll(e, c)); SubscribeLocalEvent(OnStrapEntModifiedFromContainer); SubscribeLocalEvent(OnStrapEntModifiedFromContainer); SubscribeLocalEvent>(AddStrapVerbs); SubscribeLocalEvent(OnStrapContainerGettingInsertedAttempt); SubscribeLocalEvent(OnStrapInteractHand); - SubscribeLocalEvent((_,c,_) => StrapRemoveAll(c)); - SubscribeLocalEvent((_, c, _) => StrapRemoveAll(c)); + SubscribeLocalEvent((e, c, _) => StrapRemoveAll(e, c)); + SubscribeLocalEvent((e, c, _) => StrapRemoveAll(e, c)); SubscribeLocalEvent(OnStrapDragDropTarget); SubscribeLocalEvent(OnCanDropTarget); SubscribeLocalEvent(OnAttemptFold); SubscribeLocalEvent(OnStrapMoveEvent); - SubscribeLocalEvent((_, c, _) => StrapRemoveAll(c)); + SubscribeLocalEvent((e, c, _) => StrapRemoveAll(e, c)); } private void OnStrapStartup(EntityUid uid, StrapComponent component, ComponentStartup args) @@ -48,7 +48,7 @@ private void OnStrapShutdown(EntityUid uid, StrapComponent component, ComponentS if (LifeStage(uid) > EntityLifeStage.MapInitialized) return; - StrapRemoveAll(component); + StrapRemoveAll(uid, component); } private void OnStrapEntModifiedFromContainer(EntityUid uid, StrapComponent component, ContainerModifiedMessage message) @@ -153,7 +153,7 @@ private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetVerbsEven } // If the user is currently holding/pulling an entity that can be buckled, add a verb for that. - if (args.Using is {Valid: true} @using && + if (args.Using is { Valid: true } @using && TryComp(@using, out var usingBuckle) && StrapHasSpace(uid, usingBuckle, component) && _interaction.InRangeUnobstructed(@using, args.Target, range: usingBuckle.Range)) @@ -232,7 +232,7 @@ private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveE } ReAttach(buckledEntity, uid, buckled, component); - Dirty(buckled); + Dirty(buckledEntity, buckled); } } @@ -258,7 +258,7 @@ private bool StrapCanDragDropOn( /// /// Remove everything attached to the strap /// - private void StrapRemoveAll(StrapComponent strapComp) + private void StrapRemoveAll(EntityUid uid, StrapComponent strapComp) { foreach (var entity in strapComp.BuckledEntities.ToArray()) { @@ -267,7 +267,7 @@ private void StrapRemoveAll(StrapComponent strapComp) strapComp.BuckledEntities.Clear(); strapComp.OccupiedSize = 0; - Dirty(strapComp); + Dirty(uid, strapComp); } private bool StrapHasSpace(EntityUid strapUid, BuckleComponent buckleComp, StrapComponent? strapComp = null) @@ -313,6 +313,6 @@ public void StrapSetEnabled(EntityUid strapUid, bool enabled, StrapComponent? st strapComp.Enabled = enabled; if (!enabled) - StrapRemoveAll(strapComp); + StrapRemoveAll(strapUid, strapComp); } } diff --git a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs index 70bcfbab43f496..35f5f7814a01cc 100644 --- a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs +++ b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs @@ -9,13 +9,11 @@ using Content.Shared.Popups; using Content.Shared.Pulling; using Content.Shared.Pulling.Components; -using Content.Shared.Tools; using Content.Shared.Tools.Components; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics.Components; using Content.Shared.Tag; -using Robust.Shared.Player; using Robust.Shared.Serialization; using Robust.Shared.Utility; using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem; @@ -30,7 +28,7 @@ public sealed partial class AnchorableSystem : EntitySystem [Dependency] private readonly SharedPullingSystem _pulling = default!; [Dependency] private readonly SharedToolSystem _tool = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; - [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; private EntityQuery _physicsQuery; private EntityQuery _tagQuery; @@ -133,9 +131,7 @@ private void OnAnchorComplete(EntityUid uid, AnchorableComponent component, TryA xform.LocalRotation = Math.Round(rot / (Math.PI / 2)) * (Math.PI / 2); if (TryComp(uid, out var pullable) && pullable.Puller != null) - { - _pulling.TryStopPull(pullable); - } + _pulling.TryStopPull((uid, pullable)); // TODO: Anchoring snaps rn anyway! if (component.Snap) diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index fb50803596edbb..3463be2e717790 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -89,7 +89,7 @@ private void Oninitialize(EntityUid uid, ItemSlotsComponent itemSlots, Component /// public void AddItemSlot(EntityUid uid, string id, ItemSlot slot, ItemSlotsComponent? itemSlots = null) { - itemSlots ??= EntityManager.EnsureComponent(uid); + itemSlots ??= EnsureComp(uid); DebugTools.AssertOwner(uid, itemSlots); if (itemSlots.Slots.TryGetValue(id, out var existing)) @@ -103,7 +103,7 @@ public void AddItemSlot(EntityUid uid, string id, ItemSlot slot, ItemSlotsCompon slot.ContainerSlot = _containers.EnsureContainer(uid, id); itemSlots.Slots[id] = slot; - Dirty(itemSlots); + Dirty(uid, itemSlots); } /// @@ -127,7 +127,7 @@ public void RemoveItemSlot(EntityUid uid, ItemSlot slot, ItemSlotsComponent? ite if (itemSlots.Slots.Count == 0) EntityManager.RemoveComponent(uid, itemSlots); else - Dirty(itemSlots); + Dirty(uid, itemSlots); } public bool TryGetSlot(EntityUid uid, string slotId, [NotNullWhen(true)] out ItemSlot? itemSlot, ItemSlotsComponent? component = null) diff --git a/Content.Shared/Damage/Systems/StaminaSystem.cs b/Content.Shared/Damage/Systems/StaminaSystem.cs index b8ea953f25243e..840b2e0431183e 100644 --- a/Content.Shared/Damage/Systems/StaminaSystem.cs +++ b/Content.Shared/Damage/Systems/StaminaSystem.cs @@ -285,7 +285,7 @@ public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? comp } EnsureComp(uid); - Dirty(component); + Dirty(uid, component); if (value <= 0) return; @@ -345,7 +345,7 @@ public override void Update(float frameTime) comp.NextUpdate += TimeSpan.FromSeconds(1f); TakeStaminaDamage(uid, -comp.Decay, comp); - Dirty(comp); + Dirty(uid, comp); } } @@ -368,7 +368,7 @@ private void EnterStamCrit(EntityUid uid, StaminaComponent? component = null) // Give them buffer before being able to be re-stunned component.NextUpdate = _timing.CurTime + component.StunTime + StamCritBufferTime; EnsureComp(uid); - Dirty(component); + Dirty(uid, component); _adminLogger.Add(LogType.Stamina, LogImpact.Medium, $"{ToPrettyString(uid):user} entered stamina crit"); } @@ -385,7 +385,7 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null) component.NextUpdate = _timing.CurTime; SetStaminaAlert(uid, component); RemComp(uid); - Dirty(component); + Dirty(uid, component); _adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit"); } } diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index 76fa9d64dba6da..0665ccbf84b3c9 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -69,7 +69,7 @@ private void OnCompStartup(EntityUid uid, DecalGridComponent component, Componen // This **shouldn't** be required, but just in case we ever get entity prototypes that have decal grids, we // need to ensure that we send an initial full state to players. - Dirty(component); + Dirty(uid, component); } protected Dictionary? ChunkCollection(EntityUid gridEuid, DecalGridComponent? comp = null) diff --git a/Content.Shared/Dice/SharedDiceSystem.cs b/Content.Shared/Dice/SharedDiceSystem.cs index defb3d5f0e3ec1..8e2868e791ddfc 100644 --- a/Content.Shared/Dice/SharedDiceSystem.cs +++ b/Content.Shared/Dice/SharedDiceSystem.cs @@ -59,7 +59,7 @@ public void SetCurrentSide(EntityUid uid, int side, DiceComponent? die = null) } die.CurrentValue = (side - die.Offset) * die.Multiplier; - Dirty(die); + Dirty(uid, die); UpdateVisuals(uid, die); } diff --git a/Content.Shared/Electrocution/SharedElectrocutionSystem.cs b/Content.Shared/Electrocution/SharedElectrocutionSystem.cs index 5031d8a911551d..b228a987af4af6 100644 --- a/Content.Shared/Electrocution/SharedElectrocutionSystem.cs +++ b/Content.Shared/Electrocution/SharedElectrocutionSystem.cs @@ -20,7 +20,7 @@ public void SetInsulatedSiemensCoefficient(EntityUid uid, float siemensCoefficie return; insulated.Coefficient = siemensCoefficient; - Dirty(insulated); + Dirty(uid, insulated); } /// Entity being electrocuted. diff --git a/Content.Shared/Emoting/EmoteSystem.cs b/Content.Shared/Emoting/EmoteSystem.cs index fd6361245b19ab..1e06d7e982b034 100644 --- a/Content.Shared/Emoting/EmoteSystem.cs +++ b/Content.Shared/Emoting/EmoteSystem.cs @@ -19,7 +19,7 @@ public void SetEmoting(EntityUid uid, bool value, EmotingComponent? component = if (component.Enabled == value) return; - Dirty(component); + Dirty(uid, component); } private void OnEmoteAttempt(EmoteAttemptEvent args) diff --git a/Content.Shared/Friction/TileFrictionController.cs b/Content.Shared/Friction/TileFrictionController.cs index ba4d9fc24f8b40..28b1604c842432 100644 --- a/Content.Shared/Friction/TileFrictionController.cs +++ b/Content.Shared/Friction/TileFrictionController.cs @@ -211,7 +211,7 @@ public void SetModifier(EntityUid entityUid, float value, TileFrictionModifierCo return; friction.Modifier = value; - Dirty(friction); + Dirty(entityUid, friction); } } } diff --git a/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs b/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs index 57136116caae78..6ca974f2ed34c7 100644 --- a/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs +++ b/Content.Shared/Gravity/SharedFloatingVisualizerSystem.cs @@ -33,7 +33,7 @@ protected bool CanFloat(EntityUid uid, FloatingVisualsComponent component, Trans return false; component.CanFloat = GravitySystem.IsWeightless(uid, xform: transform); - Dirty(component); + Dirty(uid, component); return component.CanFloat; } diff --git a/Content.Shared/Gravity/SharedGravitySystem.Shake.cs b/Content.Shared/Gravity/SharedGravitySystem.Shake.cs index ad2e0e3ad57613..41cf616cc4b511 100644 --- a/Content.Shared/Gravity/SharedGravitySystem.Shake.cs +++ b/Content.Shared/Gravity/SharedGravitySystem.Shake.cs @@ -24,7 +24,7 @@ private void UpdateShake() ShakeGrid(uid, gravity); comp.ShakeTimes--; comp.NextShake += TimeSpan.FromSeconds(ShakeCooldown); - Dirty(comp); + Dirty(uid, comp); } } } @@ -44,7 +44,7 @@ public void StartGridShake(EntityUid uid, GravityComponent? gravity = null) } shake.ShakeTimes = 10; - Dirty(shake); + Dirty(uid, shake); } protected virtual void ShakeGrid(EntityUid uid, GravityComponent? comp = null) {} diff --git a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs index 597afcbda2ae19..b7ef784d00219d 100644 --- a/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs +++ b/Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs @@ -99,7 +99,7 @@ public void SetLayersVisibility(EntityUid uid, IEnumerable } if (dirty) - Dirty(humanoid); + Dirty(uid, humanoid); } protected virtual void SetLayerVisibility( @@ -147,7 +147,7 @@ public void SetSpecies(EntityUid uid, string species, bool sync = true, Humanoid humanoid.MarkingSet = new(oldMarkings, prototype.MarkingPoints, _markingManager, _prototypeManager); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -177,7 +177,7 @@ public virtual void SetSkinColor(EntityUid uid, Color skinColor, bool sync = tru humanoid.SkinColor = skinColor; if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -201,7 +201,7 @@ public void SetBaseLayerId(EntityUid uid, HumanoidVisualLayers layer, string? id humanoid.CustomBaseLayers[layer] = new(id); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -222,7 +222,7 @@ public void SetBaseLayerColor(EntityUid uid, HumanoidVisualLayers layer, Color? humanoid.CustomBaseLayers[layer] = new(null, color); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -244,7 +244,7 @@ public void SetSex(EntityUid uid, Sex sex, bool sync = true, HumanoidAppearanceC if (sync) { - Dirty(humanoid); + Dirty(uid, humanoid); } } @@ -329,7 +329,7 @@ public virtual void LoadProfile(EntityUid uid, HumanoidCharacterProfile profile, humanoid.Age = profile.Age; - Dirty(humanoid); + Dirty(uid, humanoid); } /// @@ -362,7 +362,7 @@ public void AddMarking(EntityUid uid, string marking, Color? color = null, bool humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } private void EnsureDefaultMarkings(EntityUid uid, HumanoidAppearanceComponent? humanoid) @@ -396,6 +396,6 @@ public void AddMarking(EntityUid uid, string marking, IReadOnlyList color humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject); if (sync) - Dirty(humanoid); + Dirty(uid, humanoid); } } diff --git a/Content.Shared/Implants/SharedImplanterSystem.cs b/Content.Shared/Implants/SharedImplanterSystem.cs index 36a31bac1d28a4..d78522b56ccf8d 100644 --- a/Content.Shared/Implants/SharedImplanterSystem.cs +++ b/Content.Shared/Implants/SharedImplanterSystem.cs @@ -77,7 +77,7 @@ public void Implant(EntityUid user, EntityUid target, EntityUid implanter, Impla var ev = new TransferDnaEvent { Donor = target, Recipient = implanter }; RaiseLocalEvent(target, ref ev); - Dirty(component); + Dirty(implanter, component); } public bool CanImplant( @@ -156,7 +156,7 @@ public void Draw(EntityUid implanter, EntityUid user, EntityUid target, Implante if (component.CurrentMode == ImplanterToggleMode.Draw && !component.ImplantOnly && !permanentFound) ImplantMode(implanter, component); - Dirty(component); + Dirty(implanter, component); } } diff --git a/Content.Shared/Instruments/SharedInstrumentSystem.cs b/Content.Shared/Instruments/SharedInstrumentSystem.cs index 87e3a69489c468..23bcf67de0e39a 100644 --- a/Content.Shared/Instruments/SharedInstrumentSystem.cs +++ b/Content.Shared/Instruments/SharedInstrumentSystem.cs @@ -12,10 +12,10 @@ public virtual void EndRenderer(EntityUid uid, bool fromStateChange, SharedInstr { } - public void SetInstrumentProgram(SharedInstrumentComponent component, byte program, byte bank) + public void SetInstrumentProgram(EntityUid uid, SharedInstrumentComponent component, byte program, byte bank) { component.InstrumentBank = bank; component.InstrumentProgram = program; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 7d5e390b6f01ef..8649181e00b6a2 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -185,10 +185,10 @@ private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coor if (!InRangeUnobstructed(userEntity.Value, uid, popup: true)) return false; - if (!TryComp(uid, out SharedPullableComponent? pull)) + if (!HasComp(uid)) return false; - _pullSystem.TogglePull(userEntity.Value, pull); + _pullSystem.TogglePull(userEntity.Value, uid); return false; } diff --git a/Content.Shared/Light/SharedHandheldLightSystem.cs b/Content.Shared/Light/SharedHandheldLightSystem.cs index 2fa15800a312ee..9bec37a3140e91 100644 --- a/Content.Shared/Light/SharedHandheldLightSystem.cs +++ b/Content.Shared/Light/SharedHandheldLightSystem.cs @@ -29,7 +29,7 @@ private void OnInit(EntityUid uid, HandheldLightComponent component, ComponentIn UpdateVisuals(uid, component); // Want to make sure client has latest data on level so battery displays properly. - Dirty(component); + Dirty(uid, component); } private void OnHandleState(EntityUid uid, HandheldLightComponent component, ref ComponentHandleState args) diff --git a/Content.Shared/Light/SharedRgbLightControllerSystem.cs b/Content.Shared/Light/SharedRgbLightControllerSystem.cs index 1bba91c5e7b88c..7d4928f5bc11d5 100644 --- a/Content.Shared/Light/SharedRgbLightControllerSystem.cs +++ b/Content.Shared/Light/SharedRgbLightControllerSystem.cs @@ -17,13 +17,13 @@ private void OnGetState(EntityUid uid, RgbLightControllerComponent component, re args.State = new RgbLightControllerState(component.CycleRate, component.Layers); } - public void SetLayers(EntityUid uid, List? layers, RgbLightControllerComponent? rgb = null) + public void SetLayers(EntityUid uid, List? layers, RgbLightControllerComponent? rgb = null) { if (!Resolve(uid, ref rgb)) return; rgb.Layers = layers; - Dirty(rgb); + Dirty(uid, rgb); } public void SetCycleRate(EntityUid uid, float rate, RgbLightControllerComponent? rgb = null) @@ -32,6 +32,6 @@ public void SetCycleRate(EntityUid uid, float rate, RgbLightControllerComponent? return; rgb.CycleRate = Math.Clamp(0.01f, rate, 1); // lets not give people seizures - Dirty(rgb); + Dirty(uid, rgb); } } diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index 7e44dea5078bfa..b4f1ae9a268def 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -194,7 +194,7 @@ public void CycleEquipment(EntityUid uid, MechComponent? component = null) if (_net.IsServer) _popup.PopupEntity(popupString, uid); - Dirty(component); + Dirty(uid, component); } /// @@ -278,7 +278,7 @@ public virtual bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, MechCompon return false; component.Energy = FixedPoint2.Clamp(component.Energy + delta, 0, component.MaxEnergy); - Dirty(component); + Dirty(uid, component); UpdateUserInterface(uid, component); return true; } @@ -306,7 +306,7 @@ public void SetIntegrity(EntityUid uid, FixedPoint2 value, MechComponent? compon UpdateAppearance(uid, component); } - Dirty(component); + Dirty(uid, component); UpdateUserInterface(uid, component); } diff --git a/Content.Shared/Movement/Systems/SpeedModifierContactsSystem.cs b/Content.Shared/Movement/Systems/SpeedModifierContactsSystem.cs index f9f6b82bb182b9..400a675cd253c9 100644 --- a/Content.Shared/Movement/Systems/SpeedModifierContactsSystem.cs +++ b/Content.Shared/Movement/Systems/SpeedModifierContactsSystem.cs @@ -58,7 +58,7 @@ public void ChangeModifiers(EntityUid uid, float walkSpeed, float sprintSpeed, S } component.WalkSpeedModifier = walkSpeed; component.SprintSpeedModifier = sprintSpeed; - Dirty(component); + Dirty(uid, component); _toUpdate.UnionWith(_physics.GetContactingEntities(uid)); } diff --git a/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs b/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs index d8808b6e4ab87c..89aae57074e891 100644 --- a/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/HungerSystem.cs @@ -85,7 +85,7 @@ public void SetHunger(EntityUid uid, float amount, HungerComponent? component = component.Thresholds[HungerThreshold.Dead], component.Thresholds[HungerThreshold.Overfed]); UpdateCurrentThreshold(uid, component); - Dirty(component); + Dirty(uid, component); } private void UpdateCurrentThreshold(EntityUid uid, HungerComponent? component = null) @@ -98,7 +98,7 @@ private void UpdateCurrentThreshold(EntityUid uid, HungerComponent? component = return; component.CurrentThreshold = calculatedHungerThreshold; DoHungerThresholdEffects(uid, component); - Dirty(component); + Dirty(uid, component); } private void DoHungerThresholdEffects(EntityUid uid, HungerComponent? component = null, bool force = false) diff --git a/Content.Shared/Physics/Controllers/SharedConveyorController.cs b/Content.Shared/Physics/Controllers/SharedConveyorController.cs index ec17df7a24f8c5..bbbfb47cd16c10 100644 --- a/Content.Shared/Physics/Controllers/SharedConveyorController.cs +++ b/Content.Shared/Physics/Controllers/SharedConveyorController.cs @@ -100,10 +100,10 @@ private void Convey(EntityUid uid, ConveyorComponent comp, EntityQuery /// Raised when a request is made to stop pulling an entity. /// - public sealed class StopPullingEvent : CancellableEntityEventArgs + public sealed class StopPullingEvent(EntityUid? uid = null) : CancellableEntityEventArgs { - public EntityUid? User { get; } - - public StopPullingEvent(EntityUid? uid = null) - { - User = uid; - } + public EntityUid? User { get; } = uid; } } diff --git a/Content.Shared/Pulling/Components/SharedPullerComponent.cs b/Content.Shared/Pulling/Components/SharedPullerComponent.cs index 57a86e7f7a842f..5f11bcbd89a165 100644 --- a/Content.Shared/Pulling/Components/SharedPullerComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullerComponent.cs @@ -17,7 +17,7 @@ public sealed partial class SharedPullerComponent : Component /// /// Does this entity need hands to be able to pull something? /// - [DataField("needsHands")] + [DataField] public bool NeedsHands = true; } } diff --git a/Content.Shared/Pulling/Events/PullAttemptEvent.cs b/Content.Shared/Pulling/Events/PullAttemptEvent.cs index 6296dc2f14f68c..53b4589be30d1a 100644 --- a/Content.Shared/Pulling/Events/PullAttemptEvent.cs +++ b/Content.Shared/Pulling/Events/PullAttemptEvent.cs @@ -1,11 +1,6 @@ -using Robust.Shared.Physics.Components; +namespace Content.Shared.Physics.Pull; -namespace Content.Shared.Physics.Pull +public sealed class PullAttemptEvent(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) { - public sealed class PullAttemptEvent : PullMessage - { - public PullAttemptEvent(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) { } - - public bool Cancelled { get; set; } - } + public bool Cancelled { get; set; } } diff --git a/Content.Shared/Pulling/Events/PullMessage.cs b/Content.Shared/Pulling/Events/PullMessage.cs index b11de7c1702610..91172fe0fa0c50 100644 --- a/Content.Shared/Pulling/Events/PullMessage.cs +++ b/Content.Shared/Pulling/Events/PullMessage.cs @@ -1,16 +1,8 @@ -using Robust.Shared.Physics.Components; - -namespace Content.Shared.Physics.Pull +namespace Content.Shared.Physics.Pull { - public abstract class PullMessage : EntityEventArgs + public abstract class PullMessage(EntityUid puller, EntityUid pulled) : EntityEventArgs { - public readonly PhysicsComponent Puller; - public readonly PhysicsComponent Pulled; - - protected PullMessage(PhysicsComponent puller, PhysicsComponent pulled) - { - Puller = puller; - Pulled = pulled; - } + public readonly EntityUid Puller = puller; + public readonly EntityUid Pulled = pulled; } } diff --git a/Content.Shared/Pulling/Events/PullStartedMessage.cs b/Content.Shared/Pulling/Events/PullStartedMessage.cs index 0ede284bb0cc3b..a308f1d29766dd 100644 --- a/Content.Shared/Pulling/Events/PullStartedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStartedMessage.cs @@ -1,12 +1,3 @@ -using Robust.Shared.Physics.Components; +namespace Content.Shared.Physics.Pull; -namespace Content.Shared.Physics.Pull -{ - public sealed class PullStartedMessage : PullMessage - { - public PullStartedMessage(PhysicsComponent puller, PhysicsComponent pulled) : - base(puller, pulled) - { - } - } -} +public sealed class PullStartedMessage(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) { } diff --git a/Content.Shared/Pulling/Events/PullStoppedMessage.cs b/Content.Shared/Pulling/Events/PullStoppedMessage.cs index afcbcb7074019b..95208dbc4a013e 100644 --- a/Content.Shared/Pulling/Events/PullStoppedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStoppedMessage.cs @@ -1,11 +1,2 @@ -using Robust.Shared.Physics.Components; - -namespace Content.Shared.Physics.Pull -{ - public sealed class PullStoppedMessage : PullMessage - { - public PullStoppedMessage(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) - { - } - } -} +namespace Content.Shared.Physics.Pull; +public sealed class PullStoppedMessage(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) { } diff --git a/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs index 9ef2ef3198cdd7..bb91214ecd4180 100644 --- a/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs +++ b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs @@ -1,17 +1,10 @@ -namespace Content.Shared.Pulling.Events -{ - /// - /// Directed event raised on the puller to see if it can start pulling something. - /// - public sealed class StartPullAttemptEvent : CancellableEntityEventArgs - { - public StartPullAttemptEvent(EntityUid puller, EntityUid pulled) - { - Puller = puller; - Pulled = pulled; - } +namespace Content.Shared.Pulling.Events; - public EntityUid Puller { get; } - public EntityUid Pulled { get; } - } +/// +/// Directed event raised on the puller to see if it can start pulling something. +/// +public sealed class StartPullAttemptEvent(EntityUid puller, EntityUid pulled) : CancellableEntityEventArgs +{ + public EntityUid Puller { get; } = puller; + public EntityUid Pulled { get; } = pulled; } diff --git a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs index 3dab476337b966..48b03704f0c543 100644 --- a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs @@ -17,12 +17,11 @@ public override void Initialize() SubscribeLocalEvent(OnRelayMoveInput); } - private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, ref MoveInputEvent args) + private void OnRelayMoveInput(Entity entity, ref MoveInputEvent args) { - var entity = args.Entity; if (_mobState.IsIncapacitated(entity) || !_blocker.CanMove(entity)) return; - _pullSystem.TryStopPull(component); + _pullSystem.TryStopPull((entity, entity.Comp)); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs index e388d7a57c6eb0..348bd101a61fdd 100644 --- a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs @@ -29,62 +29,55 @@ public override void Initialize() SubscribeLocalEvent(OnPullerShutdown); } - private void OnPullerShutdown(EntityUid uid, SharedPullerComponent component, ComponentShutdown args) + private void OnPullerShutdown(Entity entity, ref ComponentShutdown args) { - _why.ForceDisconnectPuller(component); + _why.ForceDisconnectPuller(entity, entity.Comp); } - private void OnVirtualItemDeleted(EntityUid uid, SharedPullerComponent component, VirtualItemDeletedEvent args) + private void OnVirtualItemDeleted(Entity entity, ref VirtualItemDeletedEvent args) { - if (component.Pulling == null) + if (entity.Comp.Pulling == null) return; - if (component.Pulling == args.BlockingEntity) + if (entity.Comp.Pulling == args.BlockingEntity) { - if (EntityManager.TryGetComponent(args.BlockingEntity, out var comp)) + if (TryComp(args.BlockingEntity, out var comp)) { - _pullSystem.TryStopPull(comp, uid); + _pullSystem.TryStopPull((args.BlockingEntity, comp), entity); } } } - private void PullerHandlePullStarted( - EntityUid uid, - SharedPullerComponent component, - PullStartedMessage args) + private void PullerHandlePullStarted(Entity entity, ref PullStartedMessage args) { - if (args.Puller.Owner != uid) + if (args.Puller != entity.Owner) return; - _alertsSystem.ShowAlert(component.Owner, AlertType.Pulling); + _alertsSystem.ShowAlert(entity, AlertType.Pulling); - RefreshMovementSpeed(component); + RefreshMovementSpeed(entity); } - private void PullerHandlePullStopped( - EntityUid uid, - SharedPullerComponent component, - PullStoppedMessage args) + private void PullerHandlePullStopped(Entity entity, ref PullStoppedMessage args) { - if (args.Puller.Owner != uid) + if (args.Puller != entity.Owner) return; - var euid = component.Owner; - if (_alertsSystem.IsShowingAlert(euid, AlertType.Pulling)) - _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(euid):user} stopped pulling {ToPrettyString(args.Pulled.Owner):target}"); - _alertsSystem.ClearAlert(euid, AlertType.Pulling); + if (_alertsSystem.IsShowingAlert(entity, AlertType.Pulling)) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(entity):user} stopped pulling {ToPrettyString(args.Pulled):target}"); + _alertsSystem.ClearAlert(entity, AlertType.Pulling); - RefreshMovementSpeed(component); + RefreshMovementSpeed(entity); } - private void OnRefreshMovespeed(EntityUid uid, SharedPullerComponent component, RefreshMovementSpeedModifiersEvent args) + private void OnRefreshMovespeed(Entity entity, ref RefreshMovementSpeedModifiersEvent args) { - args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier); + args.ModifySpeed(entity.Comp.WalkSpeedModifier, entity.Comp.SprintSpeedModifier); } - private void RefreshMovementSpeed(SharedPullerComponent component) + private void RefreshMovementSpeed(Entity entity) { - _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(component.Owner); + _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(entity); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 38ed8998898965..52f34b6a4aa125 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -27,56 +27,70 @@ public override void Initialize() SubscribeLocalEvent(OnShutdown); } - private void OnShutdown(EntityUid uid, SharedPullableComponent component, ComponentShutdown args) + private void OnShutdown(Entity entity, ref ComponentShutdown args) { - if (component.Puller != null) - ForceRelationship(null, component); + if (entity.Comp.Puller != null) + ForceRelationship(null, entity); } // A WARNING: // The following 2 functions are the most internal part of the pulling system's relationship management. // They do not expect to be cancellable. - private void ForceDisconnect(SharedPullerComponent puller, SharedPullableComponent pullable) + private void ForceDisconnect(Entity puller, Entity pullable) { - var pullerPhysics = EntityManager.GetComponent(puller.Owner); - var pullablePhysics = EntityManager.GetComponent(pullable.Owner); + if (!Resolve(puller, ref puller.Comp)) + return; + + if (!Resolve(pullable, ref pullable.Comp)) + return; // MovingTo shutdown ForceSetMovingTo(pullable, null); // Joint shutdown if (!_timing.ApplyingState && // During state-handling, joint component will handle its own state. - pullable.PullJointId != null && - TryComp(puller.Owner, out JointComponent? jointComp)) + pullable.Comp.PullJointId != null && + TryComp(puller, out JointComponent? jointComp)) { - if (jointComp.GetJoints.TryGetValue(pullable.PullJointId, out var j)) + if (jointComp.GetJoints.TryGetValue(pullable.Comp.PullJointId, out var j)) _jointSystem.RemoveJoint(j); } - pullable.PullJointId = null; + pullable.Comp.PullJointId = null; // State shutdown - puller.Pulling = null; - pullable.Puller = null; + puller.Comp.Pulling = null; + pullable.Comp.Puller = null; // Messaging - var message = new PullStoppedMessage(pullerPhysics, pullablePhysics); + var message = new PullStoppedMessage(puller, pullable); - RaiseLocalEvent(puller.Owner, message, broadcast: false); + RaiseLocalEvent(puller, message, broadcast: false); - if (Initialized(pullable.Owner)) - RaiseLocalEvent(pullable.Owner, message, true); + if (Initialized(pullable)) + RaiseLocalEvent(pullable, message, true); // Networking Dirty(puller); Dirty(pullable); } - public void ForceRelationship(SharedPullerComponent? puller, SharedPullableComponent? pullable) + private void ForceDisconnect(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) + { + ForceDisconnect((puller, pullerComp), (pullable, pullableComp)); + } + + public void ForceRelationship(EntityUid? pullerEnt, EntityUid? pullableEnt, SharedPullerComponent? puller = null, SharedPullableComponent? pullable = null) { if (_timing.ApplyingState) return; - ; - if (pullable != null && puller != null && (puller.Pulling == pullable.Owner)) + + if (pullerEnt != null && !Resolve(pullerEnt.Value, ref puller)) + return; + + if (pullableEnt != null && !Resolve(pullableEnt.Value, ref pullable)) + return; + + if (pullable != null && puller != null && puller.Pulling == pullableEnt) { // Already done return; @@ -84,113 +98,130 @@ public void ForceRelationship(SharedPullerComponent? puller, SharedPullableCompo // Start by disconnecting the pullable from whatever it is currently connected to. var pullableOldPullerE = pullable?.Puller; - if (pullableOldPullerE != null) - { - ForceDisconnect(EntityManager.GetComponent(pullableOldPullerE.Value), pullable!); - } + if (pullableOldPullerE != null && pullableEnt != null) + ForceDisconnect(pullableOldPullerE.Value, pullableEnt.Value); // Continue with the puller. var pullerOldPullableE = puller?.Pulling; - if (pullerOldPullableE != null) - { - ForceDisconnect(puller!, EntityManager.GetComponent(pullerOldPullableE.Value)); - } + if (pullerOldPullableE != null && pullerEnt != null) + ForceDisconnect(pullerEnt.Value!, pullerOldPullableE.Value); + + if (pullerEnt == null || !Resolve(pullerEnt.Value, ref puller)) + return; + + if (pullableEnt == null || !Resolve(pullableEnt.Value, ref pullable)) + return; // And now for the actual connection (if any). + var pullablePhysics = Comp(pullableEnt.Value); + pullable.PullJointId = $"pull-joint-{pullableEnt.Value}"; - if (puller != null && pullable != null) + // State startup + puller.Pulling = pullableEnt; + pullable.Puller = pullerEnt; + + // joint state handling will manage its own state + if (!_timing.ApplyingState) { - var pullerPhysics = EntityManager.GetComponent(puller.Owner); - var pullablePhysics = EntityManager.GetComponent(pullable.Owner); - pullable.PullJointId = $"pull-joint-{pullable.Owner}"; - - // State startup - puller.Pulling = pullable.Owner; - pullable.Puller = puller.Owner; - - // joint state handling will manage its own state - if (!_timing.ApplyingState) - { - // Joint startup - var union = _physics.GetHardAABB(puller.Owner).Union(_physics.GetHardAABB(pullable.Owner, body: pullablePhysics)); - var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f; - - var joint = _jointSystem.CreateDistanceJoint(pullablePhysics.Owner, pullerPhysics.Owner, id: pullable.PullJointId); - joint.CollideConnected = false; - // This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts. - joint.MaxLength = Math.Max(1.0f, length); - joint.Length = length * 0.75f; - joint.MinLength = 0f; - joint.Stiffness = 1f; - } - - // Messaging - var message = new PullStartedMessage(pullerPhysics, pullablePhysics); - - RaiseLocalEvent(puller.Owner, message, broadcast: false); - RaiseLocalEvent(pullable.Owner, message, true); - - // Networking - Dirty(puller); - Dirty(pullable); + // Joint startup + var union = _physics.GetHardAABB(pullerEnt.Value).Union(_physics.GetHardAABB(pullableEnt.Value, body: pullablePhysics)); + var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f; + + var joint = _jointSystem.CreateDistanceJoint(pullableEnt.Value, pullerEnt.Value, id: pullable.PullJointId); + joint.CollideConnected = false; + // This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts. + joint.MaxLength = Math.Max(1.0f, length); + joint.Length = length * 0.75f; + joint.MinLength = 0f; + joint.Stiffness = 1f; } + + // Messaging + var message = new PullStartedMessage(pullerEnt.Value, pullableEnt.Value); + + RaiseLocalEvent(pullerEnt.Value, message, broadcast: false); + RaiseLocalEvent(pullableEnt.Value, message, true); + + // Networking + Dirty(pullerEnt.Value, puller); + Dirty(pullableEnt.Value, pullable); + } + + public void ForceRelationship(Entity puller, Entity pullable) + { + ForceRelationship(puller, pullable, puller.Comp, pullable.Comp); } // For OnRemove use only. - public void ForceDisconnectPuller(SharedPullerComponent puller) + public void ForceDisconnectPuller(Entity puller) { // DO NOT ADD ADDITIONAL LOGIC IN THIS FUNCTION. Do it in ForceRelationship. ForceRelationship(puller, null); } + public void ForceDisconnectPuller(EntityUid puller, SharedPullerComponent? comp = null) + { + ForceDisconnectPuller((puller, comp)); + } + // For OnRemove use only. - public void ForceDisconnectPullable(SharedPullableComponent pullable) + public void ForceDisconnectPullable(Entity pullable) { // DO NOT ADD ADDITIONAL LOGIC IN THIS FUNCTION. Do it in ForceRelationship. ForceRelationship(null, pullable); } - public void ForceSetMovingTo(SharedPullableComponent pullable, EntityCoordinates? movingTo) + public void ForceDisconnectPullable(EntityUid pullable, SharedPullableComponent? comp = null) { + ForceDisconnectPullable((pullable, comp)); + } + + public void ForceSetMovingTo(Entity pullable, EntityCoordinates? movingTo) + { + if (!Resolve(pullable, ref pullable.Comp)) + return; + if (_timing.ApplyingState) return; - if (pullable.MovingTo == movingTo) - { + if (pullable.Comp.MovingTo == movingTo) return; - } // Don't allow setting a MovingTo if there's no puller. // The other half of this guarantee (shutting down a MovingTo if the puller goes away) is enforced in ForceRelationship. - if (pullable.Puller == null && movingTo != null) - { + if (pullable.Comp.Puller == null && movingTo != null) return; - } - pullable.MovingTo = movingTo; + pullable.Comp.MovingTo = movingTo; Dirty(pullable); if (movingTo == null) - { RaiseLocalEvent(pullable.Owner, new PullableStopMovingMessage(), true); - } else - { RaiseLocalEvent(pullable.Owner, new PullableMoveMessage(), true); - } + } + + public void ForceSetMovingTo(EntityUid pullable, EntityCoordinates? movingTo, SharedPullableComponent? comp = null) + { + ForceSetMovingTo((pullable, comp), movingTo); } /// /// Changes if the entity needs a hand in order to be able to pull objects. /// - public void ChangeHandRequirement(EntityUid uid, bool needsHands, SharedPullerComponent? comp) + public void ChangeHandRequirement(Entity entity, bool needsHands) { - if (!Resolve(uid, ref comp, false)) + if (!Resolve(entity, ref entity.Comp, false)) return; - comp.NeedsHands = needsHands; + entity.Comp.NeedsHands = needsHands; - Dirty(uid, comp); + Dirty(entity); + } + + public void ChangeHandRequirement(EntityUid uid, bool needsHands, SharedPullerComponent? comp = null) + { + ChangeHandRequirement((uid, comp), needsHands); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index 1e2bb90c61eb34..3ba13d335b246f 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -13,7 +13,6 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; -using Robust.Shared.Utility; namespace Content.Shared.Pulling { @@ -29,48 +28,32 @@ public abstract partial class SharedPullingSystem public bool CanPull(EntityUid puller, EntityUid pulled) { - if (!EntityManager.TryGetComponent(puller, out var comp)) - { + if (!TryComp(puller, out var comp)) return false; - } if (comp.NeedsHands && !_handsSystem.TryGetEmptyHand(puller, out _)) - { return false; - } if (!_blocker.CanInteract(puller, pulled)) - { return false; - } - if (!EntityManager.TryGetComponent(pulled, out var physics)) - { + if (!TryComp(pulled, out var physics)) return false; - } if (physics.BodyType == BodyType.Static) - { return false; - } if (puller == pulled) - { return false; - } - if(_containerSystem.IsEntityInContainer(puller) || _containerSystem.IsEntityInContainer(pulled)) - { + if (_containerSystem.IsEntityInContainer(puller) || _containerSystem.IsEntityInContainer(pulled)) return false; - } - if (EntityManager.TryGetComponent(puller, out BuckleComponent? buckle)) + if (TryComp(puller, out var buckle)) { // Prevent people pulling the chair they're on, etc. - if (buckle is { PullStrap: false, Buckled: true } && (buckle.LastEntityBuckledTo == pulled)) - { + if (buckle is { PullStrap: false, Buckled: true } && buckle.LastEntityBuckledTo == pulled) return false; - } } var getPulled = new BeingPulledAttemptEvent(puller, pulled); @@ -80,95 +63,100 @@ public bool CanPull(EntityUid puller, EntityUid pulled) return (!startPull.Cancelled && !getPulled.Cancelled); } - public bool TogglePull(EntityUid puller, SharedPullableComponent pullable) + public bool TogglePull(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) { - if (pullable.Puller == puller) - { + if (!Resolve(puller, ref pullerComp)) + return false; + + if (!Resolve(pullable, ref pullableComp)) + return false; + + return TogglePull((puller, pullerComp), (pullable, pullableComp)); + } + + public bool TogglePull(Entity puller, Entity pullable) + { + if (pullable.Comp?.Puller == puller) return TryStopPull(pullable); - } - return TryStartPull(puller, pullable.Owner); + + return TryStartPull(puller, pullable); } // -- Core attempted actions -- - public bool TryStopPull(SharedPullableComponent pullable, EntityUid? user = null) + public bool TryStopPull(EntityUid pullable, SharedPullableComponent? comp = null, EntityUid? user = null) { + return TryStopPull((pullable, comp), user); + } + + public bool TryStopPull(Entity pullable, EntityUid? user = null) + { + if (!Resolve(pullable, ref pullable.Comp)) + return false; + if (_timing.ApplyingState) return false; - if (!pullable.BeingPulled) + if (!pullable.Comp.BeingPulled) { return false; } var msg = new StopPullingEvent(user); - RaiseLocalEvent(pullable.Owner, msg, true); + RaiseLocalEvent(pullable, msg, true); if (msg.Cancelled) return false; // Stop pulling confirmed! - if (TryComp(pullable.Owner, out var pullablePhysics)) + if (TryComp(pullable, out var pullablePhysics)) { - _physics.SetFixedRotation(pullable.Owner, pullable.PrevFixedRotation, body: pullablePhysics); + _physics.SetFixedRotation(pullable, pullable.Comp.PrevFixedRotation, body: pullablePhysics); } _pullSm.ForceRelationship(null, pullable); return true; } - public bool TryStartPull(EntityUid puller, EntityUid pullable) + public bool TryStartPull(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) { - if (!EntityManager.TryGetComponent(puller, out SharedPullerComponent? pullerComp)) - { - return false; - } - if (!EntityManager.TryGetComponent(pullable, out SharedPullableComponent? pullableComp)) - { - return false; - } - return TryStartPull(pullerComp, pullableComp); + return TryStartPull((puller, pullerComp), (pullable, pullableComp)); } // The main "start pulling" function. - public bool TryStartPull(SharedPullerComponent puller, SharedPullableComponent pullable) + public bool TryStartPull(Entity puller, Entity pullable) { + if (!Resolve(puller, ref puller.Comp) || !Resolve(pullable, ref pullable.Comp)) + return false; + if (_timing.ApplyingState) return false; - if (puller.Pulling == pullable.Owner) + if (puller.Comp.Pulling == pullable) return true; // Pulling a new object : Perform sanity checks. - if (!CanPull(puller.Owner, pullable.Owner)) - { + if (!CanPull(puller, pullable)) return false; - } - if (!EntityManager.TryGetComponent(puller.Owner, out var pullerPhysics)) - { + if (!HasComp(puller)) return false; - } - if (!EntityManager.TryGetComponent(pullable.Owner, out var pullablePhysics)) - { + if (!TryComp(pullable, out var pullablePhysics)) return false; - } // Ensure that the puller is not currently pulling anything. // If this isn't done, then it happens too late, and the start/stop messages go out of order, // and next thing you know it thinks it's not pulling anything even though it is! - var oldPullable = puller.Pulling; + var oldPullable = puller.Comp.Pulling; if (oldPullable != null) { - if (EntityManager.TryGetComponent(oldPullable.Value, out SharedPullableComponent? oldPullableComp)) + if (TryComp(oldPullable.Value, out var oldPullableComp)) { - if (!TryStopPull(oldPullableComp)) - { + if (!TryStopPull(oldPullable.Value, oldPullableComp)) return false; - } } else { @@ -180,59 +168,69 @@ public bool TryStartPull(SharedPullerComponent puller, SharedPullableComponent p // Ensure that the pullable is not currently being pulled. // Same sort of reasons as before. - var oldPuller = pullable.Puller; + var oldPuller = pullable.Comp.Puller; if (oldPuller != null) { if (!TryStopPull(pullable)) - { return false; - } } // Continue with pulling process. - var pullAttempt = new PullAttemptEvent(pullerPhysics, pullablePhysics); + var pullAttempt = new PullAttemptEvent(puller.Owner, pullable); - RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false); + RaiseLocalEvent(puller, pullAttempt, broadcast: false); if (pullAttempt.Cancelled) { return false; } - RaiseLocalEvent(pullable.Owner, pullAttempt, true); + RaiseLocalEvent(pullable, pullAttempt, true); if (pullAttempt.Cancelled) return false; - _interaction.DoContactInteraction(pullable.Owner, puller.Owner); + _interaction.DoContactInteraction(pullable, puller); _pullSm.ForceRelationship(puller, pullable); - pullable.PrevFixedRotation = pullablePhysics.FixedRotation; - _physics.SetFixedRotation(pullable.Owner, pullable.FixedRotationOnPull, body: pullablePhysics); + pullable.Comp.PrevFixedRotation = pullablePhysics.FixedRotation; + _physics.SetFixedRotation(pullable, pullable.Comp.FixedRotationOnPull, body: pullablePhysics); _adminLogger.Add(LogType.Action, LogImpact.Low, - $"{ToPrettyString(puller.Owner):user} started pulling {ToPrettyString(pullable.Owner):target}"); + $"{ToPrettyString(puller):user} started pulling {ToPrettyString(pullable):target}"); return true; } - public bool TryMoveTo(SharedPullableComponent pullable, EntityCoordinates to) + public bool TryMoveTo(EntityUid pullable, EntityCoordinates to, SharedPullableComponent? component = null) { - if (pullable.Puller == null) - { + return TryMoveTo((pullable, component), to); + } + + public bool TryMoveTo(Entity pullable, EntityCoordinates to) + { + if (!Resolve(pullable, ref pullable.Comp)) return false; - } - if (!EntityManager.HasComponent(pullable.Owner)) - { + if (pullable.Comp.Puller == null) + return false; + + if (!HasComp(pullable)) return false; - } _pullSm.ForceSetMovingTo(pullable, to); return true; } - public void StopMoveTo(SharedPullableComponent pullable) + public void StopMoveTo(EntityUid pullable, SharedPullableComponent? comp = null) { + StopMoveTo((pullable, comp)); + } + + public void StopMoveTo(Entity pullable) + { + if (!Resolve(pullable, ref pullable.Comp)) + return; + _pullSm.ForceSetMovingTo(pullable, null); } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index 0c139ee9e35010..88e6ff6d82a734 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -26,13 +26,12 @@ public abstract partial class SharedPullingSystem : EntitySystem /// /// A mapping of pullers to the entity that they are pulling. /// - private readonly Dictionary _pullers = - new(); + private readonly Dictionary _pullers = []; - private readonly HashSet _moving = new(); - private readonly HashSet _stoppedMoving = new(); + private readonly HashSet _moving = []; + private readonly HashSet _stoppedMoving = []; - public IReadOnlySet Moving => _moving; + public IReadOnlySet Moving => _moving; public override void Initialize() { @@ -57,37 +56,37 @@ public override void Initialize() .Register(); } - private void OnPullableCollisionChange(EntityUid uid, SharedPullableComponent component, ref CollisionChangeEvent args) + private void OnPullableCollisionChange(Entity entity, ref CollisionChangeEvent args) { - if (component.PullJointId != null && !args.CanCollide) + if (entity.Comp.PullJointId != null && !args.CanCollide) { - _joints.RemoveJoint(uid, component.PullJointId); + _joints.RemoveJoint(entity, entity.Comp.PullJointId); } } - private void OnJointRemoved(EntityUid uid, SharedPullableComponent component, JointRemovedEvent args) + private void OnJointRemoved(Entity entity, ref JointRemovedEvent args) { - if (component.Puller != args.OtherEntity) + if (entity.Comp.Puller != args.OtherEntity) return; // Do we have some other join with our Puller? // or alternatively: // TODO track the relevant joint. - if (TryComp(uid, out JointComponent? joints)) + if (TryComp(entity, out JointComponent? joints)) { foreach (var jt in joints.GetJoints.Values) { - if (jt.BodyAUid == component.Puller || jt.BodyBUid == component.Puller) + if (jt.BodyAUid == entity.Comp.Puller.Value || jt.BodyBUid == entity.Comp.Puller.Value) return; } } // No more joints with puller -> force stop pull. - _pullSm.ForceDisconnectPullable(component); + _pullSm.ForceDisconnectPullable(entity.Owner, entity.Comp); } - private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetVerbsEvent args) + private void AddPullVerbs(Entity entity, ref GetVerbsEvent args) { if (!args.CanAccess || !args.CanInteract) return; @@ -97,22 +96,25 @@ private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetV return; //TODO VERB ICONS add pulling icon - if (component.Puller == args.User) + if (entity.Comp.Puller == args.User) { + var user = args.User; Verb verb = new() { Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling"), - Act = () => TryStopPull(component, args.User), + Act = () => TryStopPull(entity.Owner, entity.Comp, user), DoContactInteraction = false // pulling handle its own contact interaction. }; args.Verbs.Add(verb); } else if (CanPull(args.User, args.Target)) { + var user = args.User; + var target = args.Target; Verb verb = new() { Text = Loc.GetString("pulling-verb-get-data-text"), - Act = () => TryStartPull(args.User, args.Target), + Act = () => TryStartPull(user, target), DoContactInteraction = false // pulling handle its own contact interaction. }; args.Verbs.Add(verb); @@ -120,25 +122,25 @@ private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetV } // Raise a "you are being pulled" alert if the pulled entity has alerts. - private void PullableHandlePullStarted(EntityUid uid, SharedPullableComponent component, PullStartedMessage args) + private void PullableHandlePullStarted(Entity entity, ref PullStartedMessage args) { - if (args.Pulled.Owner != uid) + if (args.Pulled != entity.Owner) return; - _alertsSystem.ShowAlert(uid, AlertType.Pulled); + _alertsSystem.ShowAlert(entity, AlertType.Pulled); } - private void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args) + private void PullableHandlePullStopped(Entity entity, ref PullStoppedMessage args) { - if (args.Pulled.Owner != uid) + if (args.Pulled != entity.Owner) return; - _alertsSystem.ClearAlert(uid, AlertType.Pulled); + _alertsSystem.ClearAlert(entity, AlertType.Pulled); } - public bool IsPulled(EntityUid uid, SharedPullableComponent? component = null) + public bool IsPulled(Entity entity) { - return Resolve(uid, ref component, false) && component.BeingPulled; + return Resolve(entity, ref entity.Comp, false) && entity.Comp.BeingPulled; } public override void Update(float frameTime) @@ -158,22 +160,22 @@ public void Reset(RoundRestartCleanupEvent ev) private void OnPullStarted(PullStartedMessage message) { - SetPuller(message.Puller.Owner, message.Pulled.Owner); + SetPuller(message.Puller, message.Pulled); } private void OnPullStopped(PullStoppedMessage message) { - RemovePuller(message.Puller.Owner); + RemovePuller(message.Puller); } - protected void OnPullableMove(EntityUid uid, SharedPullableComponent component, PullableMoveMessage args) + protected void OnPullableMove(Entity entity, ref PullableMoveMessage args) { - _moving.Add(component); + _moving.Add(entity); } - protected void OnPullableStopMove(EntityUid uid, SharedPullableComponent component, PullableStopMovingMessage args) + protected void OnPullableStopMove(Entity entity, ref PullableStopMovingMessage args) { - _stoppedMoving.Add(component); + _stoppedMoving.Add(entity); } // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. @@ -181,7 +183,7 @@ private void HandleContainerInsert(EntInsertedIntoContainerMessage message) { if (TryComp(message.Entity, out SharedPullableComponent? pullable)) { - TryStopPull(pullable); + TryStopPull((message.Entity, pullable)); } if (TryComp(message.Entity, out SharedPullerComponent? puller)) @@ -191,7 +193,7 @@ private void HandleContainerInsert(EntInsertedIntoContainerMessage message) if (!TryComp(puller.Pulling.Value, out SharedPullableComponent? pulling)) return; - TryStopPull(pulling); + TryStopPull((puller.Pulling.Value, pulling)); } } @@ -201,7 +203,10 @@ private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates c !player.IsValid()) return false; - if (!TryGetPulled(player, out var pulled)) + if (!TryComp(player, out var pullerComp)) + return false; + + if (!TryGetPulled((player, pullerComp), out var pulled)) return false; if (!TryComp(pulled.Value, out SharedPullableComponent? pullable)) @@ -210,32 +215,50 @@ private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates c if (_containerSystem.IsEntityInContainer(player)) return false; - TryMoveTo(pullable, coords); + TryMoveTo((pulled.Value, pullable), coords); return false; } - private void SetPuller(EntityUid puller, EntityUid pulled) + private void SetPuller(Entity puller, Entity pulled) { _pullers[puller] = pulled; } - private bool RemovePuller(EntityUid puller) + private bool RemovePuller(Entity puller) { return _pullers.Remove(puller); } - public EntityUid GetPulled(EntityUid by) + public EntityUid GetPulled(EntityUid by, SharedPullerComponent? comp = null) + { + if (!Resolve(by, ref comp)) + return EntityUid.Invalid; + + return GetPulled((by, comp)); + } + public EntityUid GetPulled(Entity by) { return _pullers.GetValueOrDefault(by); } - public bool TryGetPulled(EntityUid by, [NotNullWhen(true)] out EntityUid? pulled) + public bool TryGetPulled(EntityUid by, [NotNullWhen(true)] out EntityUid? pulled, SharedPullerComponent? comp = null) + { + if (!Resolve(by, ref comp)) + { + pulled = default; + return false; + } + + return TryGetPulled((by, comp), out pulled); + } + + public bool TryGetPulled(Entity by, [NotNullWhen(true)] out EntityUid? pulled) { return (pulled = GetPulled(by)) != null; } - public bool IsPulling(EntityUid puller) + public bool IsPulling(Entity puller) { return _pullers.ContainsKey(puller); } diff --git a/Content.Shared/RCD/Systems/RCDAmmoSystem.cs b/Content.Shared/RCD/Systems/RCDAmmoSystem.cs index 9481d299aaa06c..9cb3c26485114e 100644 --- a/Content.Shared/RCD/Systems/RCDAmmoSystem.cs +++ b/Content.Shared/RCD/Systems/RCDAmmoSystem.cs @@ -36,7 +36,7 @@ private void OnAfterInteract(EntityUid uid, RCDAmmoComponent comp, AfterInteract if (args.Handled || !args.CanReach || !_timing.IsFirstTimePredicted) return; - if (args.Target is not {Valid: true} target || + if (args.Target is not { Valid: true } target || !HasComp(target) || !TryComp(target, out var charges)) return; @@ -53,7 +53,7 @@ private void OnAfterInteract(EntityUid uid, RCDAmmoComponent comp, AfterInteract _popup.PopupClient(Loc.GetString("rcd-ammo-component-after-interact-refilled"), target, user); _charges.AddCharges(target, count, charges); comp.Charges -= count; - Dirty(comp); + Dirty(uid, comp); // prevent having useless ammo with 0 charges if (comp.Charges <= 0) diff --git a/Content.Shared/RCD/Systems/RCDSystem.cs b/Content.Shared/RCD/Systems/RCDSystem.cs index 187c8d8a9d8475..5da55c5961912f 100644 --- a/Content.Shared/RCD/Systems/RCDSystem.cs +++ b/Content.Shared/RCD/Systems/RCDSystem.cs @@ -313,7 +313,7 @@ private void NextMode(EntityUid uid, RCDComponent comp, EntityUid user) var mode = (int) comp.Mode; mode = ++mode % RcdModeCount; comp.Mode = (RcdMode) mode; - Dirty(comp); + Dirty(uid, comp); var msg = Loc.GetString("rcd-component-change-mode", ("mode", comp.Mode.ToString())); _popup.PopupClient(msg, uid, user); diff --git a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs index 7b9ce841a9939b..c81527063bbcb0 100644 --- a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs @@ -55,7 +55,7 @@ private void ToggleBarrierDeploy(EntityUid uid, bool isDeployed, DeployableBarri } if (TryComp(uid, out SharedPullableComponent? pullable)) - _pulling.TryStopPull(pullable); + _pulling.TryStopPull(uid, pullable); SharedPointLightComponent? pointLight = null; if (_pointLight.ResolveLight(uid, ref pointLight)) diff --git a/Content.Shared/Singularity/EntitySystems/SharedEventHorizonSystem.cs b/Content.Shared/Singularity/EntitySystems/SharedEventHorizonSystem.cs index f31dd8776a4347..c2b52c5af356e6 100644 --- a/Content.Shared/Singularity/EntitySystems/SharedEventHorizonSystem.cs +++ b/Content.Shared/Singularity/EntitySystems/SharedEventHorizonSystem.cs @@ -66,7 +66,7 @@ public void SetRadius(EntityUid uid, float value, bool updateFixture = true, Eve return; eventHorizon.Radius = value; - Dirty(eventHorizon); + Dirty(uid, eventHorizon); if (updateFixture) UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon); } @@ -89,7 +89,7 @@ public void SetCanBreachContainment(EntityUid uid, bool value, bool updateFixtur return; eventHorizon.CanBreachContainment = value; - Dirty(eventHorizon); + Dirty(uid, eventHorizon); if (updateFixture) UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon); } @@ -112,7 +112,7 @@ public void SetColliderFixtureId(EntityUid uid, string? value, bool updateFixtur return; eventHorizon.ColliderFixtureId = value; - Dirty(eventHorizon); + Dirty(uid, eventHorizon); if (updateFixture) UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon); } @@ -135,7 +135,7 @@ public void SetConsumerFixtureId(EntityUid uid, string? value, bool updateFixtur return; eventHorizon.ConsumerFixtureId = value; - Dirty(eventHorizon); + Dirty(uid, eventHorizon); if (updateFixture) UpdateEventHorizonFixture(uid, eventHorizon: eventHorizon); } diff --git a/Content.Shared/Stacks/SharedStackSystem.cs b/Content.Shared/Stacks/SharedStackSystem.cs index 756c84cac55eed..e12edd323c72af 100644 --- a/Content.Shared/Stacks/SharedStackSystem.cs +++ b/Content.Shared/Stacks/SharedStackSystem.cs @@ -23,8 +23,8 @@ public abstract class SharedStackSystem : EntitySystem [Dependency] protected readonly SharedAppearanceSystem Appearance = default!; [Dependency] protected readonly SharedHandsSystem Hands = default!; [Dependency] protected readonly SharedTransformSystem Xform = default!; - [Dependency] private readonly EntityLookupSystem _entityLookup = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!; [Dependency] private readonly SharedStorageSystem _storage = default!; @@ -175,7 +175,7 @@ public virtual void SetCount(EntityUid uid, int amount, StackComponent? componen // Server-side override deletes the entity if count == 0 component.Count = amount; - Dirty(component); + Dirty(uid, component); Appearance.SetData(uid, StackVisuals.Actual, component.Count); RaiseLocalEvent(uid, new StackCountChangedEvent(old, component.Count)); diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/StandingStateSystem.cs index 517831b8a1b3a5..ed586e970dcd78 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/StandingStateSystem.cs @@ -56,7 +56,7 @@ public bool Down(EntityUid uid, bool playSound = true, bool dropHeldItems = true return false; standingState.Standing = false; - Dirty(standingState); + Dirty(uid, standingState); RaiseLocalEvent(uid, new DownedEvent(), false); // Seemed like the best place to put it diff --git a/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs b/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs index 05af0807f21ec3..e9d68721b63d25 100644 --- a/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs +++ b/Content.Shared/StationRecords/StationRecordKeyStorageSystem.cs @@ -58,7 +58,7 @@ public void AssignKey(EntityUid uid, StationRecordKey key, StationRecordKeyStora var key = keyStorage.Key; keyStorage.Key = null; - Dirty(keyStorage); + Dirty(uid, keyStorage); return key; } diff --git a/Content.Shared/StatusEffect/StatusEffectsSystem.cs b/Content.Shared/StatusEffect/StatusEffectsSystem.cs index 6aec3a8b3b4a0f..f3e3e12bd8cc77 100644 --- a/Content.Shared/StatusEffect/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffect/StatusEffectsSystem.cs @@ -207,7 +207,7 @@ public bool TryAddStatusEffect(EntityUid uid, string key, TimeSpan time, bool re _alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown1); } - Dirty(status); + Dirty(uid, status); RaiseLocalEvent(uid, new StatusEffectAddedEvent(uid, key)); return true; } @@ -283,7 +283,7 @@ public bool TryRemoveStatusEffect(EntityUid uid, string key, RemComp(uid); } - Dirty(status); + Dirty(uid, status); RaiseLocalEvent(uid, new StatusEffectEndedEvent(uid, key)); return true; } @@ -307,7 +307,7 @@ public bool TryRemoveAllStatusEffects(EntityUid uid, failed = true; } - Dirty(status); + Dirty(uid, status); return failed; } @@ -381,7 +381,7 @@ public bool TryAddTime(EntityUid uid, string key, TimeSpan time, _alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown); } - Dirty(status); + Dirty(uid, status); return true; } @@ -417,7 +417,7 @@ public bool TryRemoveTime(EntityUid uid, string key, TimeSpan time, _alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown); } - Dirty(status); + Dirty(uid, status); return true; } @@ -438,7 +438,7 @@ public bool TrySetTime(EntityUid uid, string key, TimeSpan time, status.ActiveEffects[key].Cooldown = (_gameTiming.CurTime, _gameTiming.CurTime + time); - Dirty(status); + Dirty(uid, status); return true; } diff --git a/Content.Shared/Storage/EntitySystems/BinSystem.cs b/Content.Shared/Storage/EntitySystems/BinSystem.cs index 17c3eb4288c000..1cc95337ea4a92 100644 --- a/Content.Shared/Storage/EntitySystems/BinSystem.cs +++ b/Content.Shared/Storage/EntitySystems/BinSystem.cs @@ -135,7 +135,7 @@ public bool TryInsertIntoBin(EntityUid uid, EntityUid toInsert, BinComponent? co _container.Insert(toInsert, component.ItemContainer); component.Items.Add(toInsert); - Dirty(component); + Dirty(uid, component); return true; } @@ -151,7 +151,7 @@ public bool TryRemoveFromBin(EntityUid uid, EntityUid? toRemove, BinComponent? c if (!Resolve(uid, ref component)) return false; - if (!component.Items.Any()) + if (component.Items.Count == 0) return false; if (toRemove == null || toRemove != component.Items.LastOrDefault()) @@ -161,7 +161,7 @@ public bool TryRemoveFromBin(EntityUid uid, EntityUid? toRemove, BinComponent? c return false; component.Items.Remove(toRemove.Value); - Dirty(component); + Dirty(uid, component); return true; } } diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index c447f8c8bc79e3..9190427d321486 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -1,7 +1,5 @@ using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; -using Content.Shared.Audio; -using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.Interaction.Events; using Content.Shared.Inventory.Events; @@ -11,16 +9,12 @@ using Content.Shared.Hands; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; -using Content.Shared.Mobs.Systems; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Standing; using Content.Shared.StatusEffect; using Content.Shared.Throwing; -using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; -using Robust.Shared.GameStates; -using Robust.Shared.Player; namespace Content.Shared.Stunnable; @@ -82,19 +76,19 @@ private void OnMobStateChanged(EntityUid uid, MobStateComponent component, MobSt switch (args.NewMobState) { case MobState.Alive: - { - break; - } + { + break; + } case MobState.Critical: - { - _statusEffect.TryRemoveStatusEffect(uid, "Stun"); - break; - } + { + _statusEffect.TryRemoveStatusEffect(uid, "Stun"); + break; + } case MobState.Dead: - { - _statusEffect.TryRemoveStatusEffect(uid, "Stun"); - break; - } + { + _statusEffect.TryRemoveStatusEffect(uid, "Stun"); + break; + } case MobState.Invalid: default: return; @@ -238,11 +232,11 @@ private void OnInteractHand(EntityUid uid, KnockedDownComponent knocked, Interac return; // Set it to half the help interval so helping is actually useful... - knocked.HelpTimer = knocked.HelpInterval/2f; + knocked.HelpTimer = knocked.HelpInterval / 2f; _statusEffect.TryRemoveTime(uid, "KnockedDown", TimeSpan.FromSeconds(knocked.HelpInterval)); _audio.PlayPredicted(knocked.StunAttemptSound, uid, args.User); - Dirty(knocked); + Dirty(uid, knocked); args.Handled = true; } diff --git a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs index 1ba88c571c7cee..da56c8d1c76253 100644 --- a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs +++ b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs @@ -35,7 +35,7 @@ private void SetScannerEnabled(EntityUid uid, bool enabled, TrayScannerComponent return; scanner.Enabled = enabled; - Dirty(scanner); + Dirty(uid, scanner); // We don't remove from _activeScanners on disabled, because the update function will handle that, as well as // managing the revealed subfloor entities diff --git a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs index bf2d087c761960..35ce5665ddf8fa 100644 --- a/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs +++ b/Content.Shared/Teleportation/Systems/LinkedEntitySystem.cs @@ -87,7 +87,7 @@ public bool OneWayLink(EntityUid source, EntityUid target, bool deleteOnEmptyLin /// Resolve comp /// Whether unlinking was successful (e.g. they both were actually linked to one another) public bool TryUnlink(EntityUid first, EntityUid second, - LinkedEntityComponent? firstLink=null, LinkedEntityComponent? secondLink=null) + LinkedEntityComponent? firstLink = null, LinkedEntityComponent? secondLink = null) { if (!Resolve(first, ref firstLink)) return false; @@ -101,8 +101,8 @@ public bool TryUnlink(EntityUid first, EntityUid second, _appearance.SetData(first, LinkedEntityVisuals.HasAnyLinks, firstLink.LinkedEntities.Any()); _appearance.SetData(second, LinkedEntityVisuals.HasAnyLinks, secondLink.LinkedEntities.Any()); - Dirty(firstLink); - Dirty(secondLink); + Dirty(first, firstLink); + Dirty(second, secondLink); if (firstLink.LinkedEntities.Count == 0 && firstLink.DeleteOnEmptyLinks) QueueDel(first); diff --git a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs index ebd83624114a0d..b356a1f94540fd 100644 --- a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -95,13 +95,13 @@ private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollid // break pulls before portal enter so we dont break shit if (TryComp(subject, out var pullable) && pullable.BeingPulled) { - _pulling.TryStopPull(pullable); + _pulling.TryStopPull((subject, pullable)); } if (TryComp(subject, out var pulling) && pulling.Pulling != null && TryComp(pulling.Pulling.Value, out var subjectPulling)) { - _pulling.TryStopPull(subjectPulling); + _pulling.TryStopPull((pulling.Pulling.Value, subjectPulling)); } // if they came from another portal, just return and wait for them to exit the portal @@ -150,7 +150,7 @@ private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollid private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndCollideEvent args) { - if (!ShouldCollide(args.OurFixtureId, args.OtherFixtureId,args.OurFixture, args.OtherFixture)) + if (!ShouldCollide(args.OurFixtureId, args.OtherFixtureId, args.OurFixture, args.OtherFixture)) return; var subject = args.OtherEntity; @@ -162,7 +162,7 @@ private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndColli } } - private void TeleportEntity(EntityUid portal, EntityUid subject, EntityCoordinates target, EntityUid? targetEntity=null, bool playSound=true, + private void TeleportEntity(EntityUid portal, EntityUid subject, EntityCoordinates target, EntityUid? targetEntity = null, bool playSound = true, PortalComponent? portalComponent = null) { if (!Resolve(portal, ref portalComponent)) diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 0f38c4d753383b..67bdd5816ef1c3 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -85,8 +85,8 @@ private void OnSleep(EntityUid uid, ThrownItemComponent thrownItem, ref PhysicsS private void HandlePullStarted(PullStartedMessage message) { // TODO: this isn't directed so things have to be done the bad way - if (EntityManager.TryGetComponent(message.Pulled.Owner, out ThrownItemComponent? thrownItemComponent)) - StopThrow(message.Pulled.Owner, thrownItemComponent); + if (TryComp(message.Pulled, out var thrownItemComponent)) + StopThrow(message.Pulled, thrownItemComponent); } public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent) diff --git a/Content.Shared/Weapons/Marker/SharedDamageMarkerSystem.cs b/Content.Shared/Weapons/Marker/SharedDamageMarkerSystem.cs index 63b2d5f211512e..d1814020e6e32e 100644 --- a/Content.Shared/Weapons/Marker/SharedDamageMarkerSystem.cs +++ b/Content.Shared/Weapons/Marker/SharedDamageMarkerSystem.cs @@ -71,7 +71,7 @@ private void OnMarkerCollide(EntityUid uid, DamageMarkerOnCollideComponent compo marker.Marker = projectile.Weapon.Value; marker.EndTime = _timing.CurTime + component.Duration; component.Amount--; - Dirty(marker); + Dirty(args.OtherEntity, marker); if (_netManager.IsServer) { @@ -81,7 +81,7 @@ private void OnMarkerCollide(EntityUid uid, DamageMarkerOnCollideComponent compo } else { - Dirty(component); + Dirty(uid, component); } } } diff --git a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs index 177cb310d18a5b..99cd3fa030aa9e 100644 --- a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs @@ -21,17 +21,17 @@ namespace Content.Shared.Weapons.Misc; public abstract partial class SharedTetherGunSystem : EntitySystem { - [Dependency] private readonly INetManager _netManager = default!; - [Dependency] private readonly ActionBlockerSystem _blocker = default!; - [Dependency] private readonly MobStateSystem _mob = default!; - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly SharedContainerSystem _container = default!; - [Dependency] private readonly SharedJointSystem _joints = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly INetManager _netManager = default!; + [Dependency] private readonly ActionBlockerSystem _blocker = default!; + [Dependency] private readonly MobStateSystem _mob = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly SharedJointSystem _joints = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] protected readonly SharedTransformSystem TransformSystem = default!; - [Dependency] private readonly ThrowingSystem _throwing = default!; - [Dependency] private readonly ThrownItemSystem _thrown = default!; + [Dependency] private readonly ThrowingSystem _throwing = default!; + [Dependency] private readonly ThrownItemSystem _thrown = default!; private const string TetherJoint = "tether"; @@ -282,7 +282,7 @@ protected virtual void StopTether(EntityUid gunUid, BaseForceGunComponent compon RemComp(component.Tethered.Value); _blocker.UpdateCanMove(component.Tethered.Value); component.Tethered = null; - Dirty(component); + Dirty(gunUid, component); } [Serializable, NetSerializable] diff --git a/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs b/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs index b774c8ab450dab..9d6d55240015f1 100644 --- a/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/RechargeBasicEntityAmmoSystem.cs @@ -49,19 +49,19 @@ public override void Update(float frameTime) if (ammo.Count == ammo.Capacity) { recharge.NextCharge = null; - Dirty(recharge); + Dirty(uid, recharge); continue; } recharge.NextCharge = recharge.NextCharge.Value + TimeSpan.FromSeconds(recharge.RechargeCooldown); - Dirty(recharge); + Dirty(uid, recharge); } } private void OnInit(EntityUid uid, RechargeBasicEntityAmmoComponent component, MapInitEvent args) { component.NextCharge = _timing.CurTime; - Dirty(component); + Dirty(uid, component); } private void OnExamined(EntityUid uid, RechargeBasicEntityAmmoComponent component, ExaminedEvent args) @@ -86,7 +86,7 @@ public void Reset(EntityUid uid, RechargeBasicEntityAmmoComponent? recharge = nu if (recharge.NextCharge == null || recharge.NextCharge < _timing.CurTime) { recharge.NextCharge = _timing.CurTime + TimeSpan.FromSeconds(recharge.RechargeCooldown); - Dirty(recharge); + Dirty(uid, recharge); } } } diff --git a/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs b/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs index 136e9b59b2fa3a..a014f8e5c744a8 100644 --- a/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/RechargeCycleAmmoSystem.cs @@ -25,7 +25,7 @@ private void OnRechargeCycled(EntityUid uid, RechargeCycleAmmoComponent componen return; _gun.UpdateBasicEntityAmmoCount(uid, basic.Count.Value + 1, basic); - Dirty(basic); + Dirty(uid, basic); args.Handled = true; } } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 71e3e80764f002..c97e2b4555e260 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -117,7 +117,7 @@ private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent arg if (melee.NextAttack > component.NextFire) { component.NextFire = melee.NextAttack; - Dirty(component); + Dirty(uid, component); } } diff --git a/Content.Shared/Weather/SharedWeatherSystem.cs b/Content.Shared/Weather/SharedWeatherSystem.cs index 45a2afe7cd980f..02a4e0fb4b8579 100644 --- a/Content.Shared/Weather/SharedWeatherSystem.cs +++ b/Content.Shared/Weather/SharedWeatherSystem.cs @@ -182,7 +182,7 @@ public void SetWeather(MapId mapId, WeatherPrototype? proto, TimeSpan? endTime) } if (proto != null) - StartWeather(weatherComp, proto, endTime); + StartWeather(mapUid, weatherComp, proto, endTime); } /// @@ -190,7 +190,7 @@ public void SetWeather(MapId mapId, WeatherPrototype? proto, TimeSpan? endTime) /// protected virtual void Run(EntityUid uid, WeatherData weather, WeatherPrototype weatherProto, float frameTime) {} - protected void StartWeather(WeatherComponent component, WeatherPrototype weather, TimeSpan? endTime) + protected void StartWeather(EntityUid uid, WeatherComponent component, WeatherPrototype weather, TimeSpan? endTime) { if (component.Weather.ContainsKey(weather.ID)) return; @@ -202,7 +202,7 @@ protected void StartWeather(WeatherComponent component, WeatherPrototype weather }; component.Weather.Add(weather.ID, data); - Dirty(component); + Dirty(uid, component); } protected virtual void EndWeather(EntityUid uid, WeatherComponent component, string proto) From 8d31c116c08917b1d341617f8d6273701dc49512 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Mon, 18 Mar 2024 13:22:30 -0400 Subject: [PATCH 2/4] Missed a few --- Content.Client/Weather/WeatherSystem.cs | 4 +- Content.IntegrationTests/Tests/Tag/TagTest.cs | 26 ++++++------ Content.Shared/Tag/TagSystem.cs | 42 +++++++++---------- Content.Shared/Weather/SharedWeatherSystem.cs | 14 +++---- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Content.Client/Weather/WeatherSystem.cs b/Content.Client/Weather/WeatherSystem.cs index f1d490dcb24385..b35483bba487d0 100644 --- a/Content.Client/Weather/WeatherSystem.cs +++ b/Content.Client/Weather/WeatherSystem.cs @@ -124,9 +124,9 @@ protected override void Run(EntityUid uid, WeatherData weather, WeatherPrototype comp.Occlusion = occlusion; } - protected override bool SetState(WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto) + protected override bool SetState(EntityUid uid, WeatherState state, WeatherComponent comp, WeatherData weather, WeatherPrototype weatherProto) { - if (!base.SetState(state, comp, weather, weatherProto)) + if (!base.SetState(uid, state, comp, weather, weatherProto)) return false; if (!Timing.IsFirstTimePredicted) diff --git a/Content.IntegrationTests/Tests/Tag/TagTest.cs b/Content.IntegrationTests/Tests/Tag/TagTest.cs index ed3c484b435ad7..cbcdd1c6c6231d 100644 --- a/Content.IntegrationTests/Tests/Tag/TagTest.cs +++ b/Content.IntegrationTests/Tests/Tag/TagTest.cs @@ -130,9 +130,9 @@ await server.WaitAssertion(() => Assert.Multiple(() => { // Cannot add the starting tag again - Assert.That(tagSystem.AddTag(sTagComponent, StartingTag), Is.False); - Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, StartingTag), Is.False); - Assert.That(tagSystem.AddTags(sTagComponent, new List { StartingTag, StartingTag }), Is.False); + Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, StartingTag), Is.False); + Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, StartingTag, StartingTag), Is.False); + Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, new List { StartingTag, StartingTag }), Is.False); // Has the starting tag Assert.That(tagSystem.HasTag(sTagComponent, StartingTag), Is.True); @@ -157,22 +157,22 @@ await server.WaitAssertion(() => Assert.That(tagSystem.HasAllTags(sTagComponent, new List { StartingTag, AddedTag }), Is.False); // Cannot remove a tag that does not exist - Assert.That(tagSystem.RemoveTag(sTagComponent, AddedTag), Is.False); - Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.False); - Assert.That(tagSystem.RemoveTags(sTagComponent, new List { AddedTag, AddedTag }), Is.False); + Assert.That(tagSystem.RemoveTag(sTagDummy, sTagComponent, AddedTag), Is.False); + Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, AddedTag, AddedTag), Is.False); + Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, new List { AddedTag, AddedTag }), Is.False); }); // Can add the new tag - Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.True); + Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, AddedTag), Is.True); Assert.Multiple(() => { // Cannot add it twice - Assert.That(tagSystem.AddTag(sTagComponent, AddedTag), Is.False); + Assert.That(tagSystem.AddTag(sTagDummy, sTagComponent, AddedTag), Is.False); // Cannot add existing tags - Assert.That(tagSystem.AddTags(sTagComponent, StartingTag, AddedTag), Is.False); - Assert.That(tagSystem.AddTags(sTagComponent, new List { StartingTag, AddedTag }), Is.False); + Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, StartingTag, AddedTag), Is.False); + Assert.That(tagSystem.AddTags(sTagDummy, sTagComponent, new List { StartingTag, AddedTag }), Is.False); // Now has two tags Assert.That(sTagComponent.Tags, Has.Count.EqualTo(2)); @@ -191,16 +191,16 @@ await server.WaitAssertion(() => Assert.Multiple(() => { // Remove the existing starting tag - Assert.That(tagSystem.RemoveTag(sTagComponent, StartingTag), Is.True); + Assert.That(tagSystem.RemoveTag(sTagDummy, sTagComponent, StartingTag), Is.True); // Remove the existing added tag - Assert.That(tagSystem.RemoveTags(sTagComponent, AddedTag, AddedTag), Is.True); + Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, AddedTag, AddedTag), Is.True); }); Assert.Multiple(() => { // No tags left to remove - Assert.That(tagSystem.RemoveTags(sTagComponent, new List { StartingTag, AddedTag }), Is.False); + Assert.That(tagSystem.RemoveTags(sTagDummy, sTagComponent, new List { StartingTag, AddedTag }), Is.False); // No tags left in the component Assert.That(sTagComponent.Tags, Is.Empty); diff --git a/Content.Shared/Tag/TagSystem.cs b/Content.Shared/Tag/TagSystem.cs index 0628b892edd1e2..62197dc319ace6 100644 --- a/Content.Shared/Tag/TagSystem.cs +++ b/Content.Shared/Tag/TagSystem.cs @@ -75,7 +75,7 @@ private void AssertValidTag(string id) /// public bool AddTag(EntityUid entity, string id) { - return AddTag(EnsureComp(entity), id); + return AddTag(entity, EnsureComp(entity), id); } /// @@ -91,7 +91,7 @@ public bool AddTag(EntityUid entity, string id) /// public bool AddTags(EntityUid entity, params string[] ids) { - return AddTags(EnsureComp(entity), ids); + return AddTags(entity, EnsureComp(entity), ids); } /// @@ -107,7 +107,7 @@ public bool AddTags(EntityUid entity, params string[] ids) /// public bool AddTags(EntityUid entity, IEnumerable ids) { - return AddTags(EnsureComp(entity), ids); + return AddTags(entity, EnsureComp(entity), ids); } /// @@ -125,7 +125,7 @@ public bool AddTags(EntityUid entity, IEnumerable ids) public bool TryAddTag(EntityUid entity, string id) { return TryComp(entity, out var component) && - AddTag(component, id); + AddTag(entity, component, id); } /// @@ -143,7 +143,7 @@ public bool TryAddTag(EntityUid entity, string id) public bool TryAddTags(EntityUid entity, params string[] ids) { return TryComp(entity, out var component) && - AddTags(component, ids); + AddTags(entity, component, ids); } /// @@ -161,7 +161,7 @@ public bool TryAddTags(EntityUid entity, params string[] ids) public bool TryAddTags(EntityUid entity, IEnumerable ids) { return TryComp(entity, out var component) && - AddTags(component, ids); + AddTags(entity, component, ids); } /// @@ -299,7 +299,7 @@ public bool HasAnyTag(EntityUid entity, IEnumerable ids) public bool RemoveTag(EntityUid entity, string id) { return TryComp(entity, out var component) && - RemoveTag(component, id); + RemoveTag(entity, component, id); } /// @@ -316,7 +316,7 @@ public bool RemoveTag(EntityUid entity, string id) public bool RemoveTags(EntityUid entity, params string[] ids) { return TryComp(entity, out var component) && - RemoveTags(component, ids); + RemoveTags(entity, component, ids); } /// @@ -333,7 +333,7 @@ public bool RemoveTags(EntityUid entity, params string[] ids) public bool RemoveTags(EntityUid entity, IEnumerable ids) { return TryComp(entity, out var component) && - RemoveTags(component, ids); + RemoveTags(entity, component, ids); } /// @@ -344,14 +344,14 @@ public bool RemoveTags(EntityUid entity, IEnumerable ids) /// /// Thrown if no exists with the given id. /// - public bool AddTag(TagComponent component, string id) + public bool AddTag(EntityUid uid, TagComponent component, string id) { AssertValidTag(id); var added = component.Tags.Add(id); if (added) { - Dirty(component); + Dirty(uid, component); return true; } @@ -366,9 +366,9 @@ public bool AddTag(TagComponent component, string id) /// /// Thrown if one of the ids represents an unregistered . /// - public bool AddTags(TagComponent component, params string[] ids) + public bool AddTags(EntityUid uid, TagComponent component, params string[] ids) { - return AddTags(component, ids.AsEnumerable()); + return AddTags(uid, component, ids.AsEnumerable()); } /// @@ -379,7 +379,7 @@ public bool AddTags(TagComponent component, params string[] ids) /// /// Thrown if one of the ids represents an unregistered . /// - public bool AddTags(TagComponent component, IEnumerable ids) + public bool AddTags(EntityUid uid, TagComponent component, IEnumerable ids) { var count = component.Tags.Count; @@ -391,7 +391,7 @@ public bool AddTags(TagComponent component, IEnumerable ids) if (component.Tags.Count > count) { - Dirty(component); + Dirty(uid, component); return true; } @@ -557,13 +557,13 @@ public bool HasAnyTag(TagComponent component, IEnumerable ids) /// /// Thrown if no exists with the given id. /// - public bool RemoveTag(TagComponent component, string id) + public bool RemoveTag(EntityUid uid, TagComponent component, string id) { AssertValidTag(id); if (component.Tags.Remove(id)) { - Dirty(component); + Dirty(uid, component); return true; } @@ -580,9 +580,9 @@ public bool RemoveTag(TagComponent component, string id) /// /// Thrown if one of the ids represents an unregistered . /// - public bool RemoveTags(TagComponent component, params string[] ids) + public bool RemoveTags(EntityUid uid, TagComponent component, params string[] ids) { - return RemoveTags(component, ids.AsEnumerable()); + return RemoveTags(uid, component, ids.AsEnumerable()); } /// @@ -593,7 +593,7 @@ public bool RemoveTags(TagComponent component, params string[] ids) /// /// Thrown if one of the ids represents an unregistered . /// - public bool RemoveTags(TagComponent component, IEnumerable ids) + public bool RemoveTags(EntityUid uid, TagComponent component, IEnumerable ids) { var count = component.Tags.Count; @@ -605,7 +605,7 @@ public bool RemoveTags(TagComponent component, IEnumerable ids) if (component.Tags.Count < count) { - Dirty(component); + Dirty(uid, component); return true; } diff --git a/Content.Shared/Weather/SharedWeatherSystem.cs b/Content.Shared/Weather/SharedWeatherSystem.cs index 02a4e0fb4b8579..19671bd77b0f2a 100644 --- a/Content.Shared/Weather/SharedWeatherSystem.cs +++ b/Content.Shared/Weather/SharedWeatherSystem.cs @@ -15,8 +15,8 @@ public abstract class SharedWeatherSystem : EntitySystem [Dependency] protected readonly IGameTiming Timing = default!; [Dependency] protected readonly IMapManager MapManager = default!; [Dependency] protected readonly IPrototypeManager ProtoMan = default!; - [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; - [Dependency] private readonly MetaDataSystem _metadata = default!; + [Dependency] private readonly ITileDefinitionManager _tileDefManager = default!; + [Dependency] private readonly MetaDataSystem _metadata = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; private EntityQuery _blockQuery; @@ -129,7 +129,7 @@ public override void Update(float frameTime) // Shutting down if (endTime != null && remainingTime < WeatherComponent.ShutdownTime) { - SetState(WeatherState.Ending, comp, weather, weatherProto); + SetState(uid, WeatherState.Ending, comp, weather, weatherProto); } // Starting up else @@ -139,7 +139,7 @@ public override void Update(float frameTime) if (elapsed < WeatherComponent.StartupTime) { - SetState(WeatherState.Starting, comp, weather, weatherProto); + SetState(uid, WeatherState.Starting, comp, weather, weatherProto); } } @@ -188,7 +188,7 @@ public void SetWeather(MapId mapId, WeatherPrototype? proto, TimeSpan? endTime) /// /// Run every tick when the weather is running. /// - protected virtual void Run(EntityUid uid, WeatherData weather, WeatherPrototype weatherProto, float frameTime) {} + protected virtual void Run(EntityUid uid, WeatherData weather, WeatherPrototype weatherProto, float frameTime) { } protected void StartWeather(EntityUid uid, WeatherComponent component, WeatherPrototype weather, TimeSpan? endTime) { @@ -216,13 +216,13 @@ protected virtual void EndWeather(EntityUid uid, WeatherComponent component, str Dirty(uid, component); } - protected virtual bool SetState(WeatherState state, WeatherComponent component, WeatherData weather, WeatherPrototype weatherProto) + protected virtual bool SetState(EntityUid uid, WeatherState state, WeatherComponent component, WeatherData weather, WeatherPrototype weatherProto) { if (weather.State.Equals(state)) return false; weather.State = state; - Dirty(component); + Dirty(uid, component); return true; } From dbbea360bf5a28e0f257e1f9a34fadbf4aa11fad Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 19 Mar 2024 16:59:43 -0400 Subject: [PATCH 3/4] Revert changes to pulling --- Content.Server/Alert/Click/StopBeingPulled.cs | 2 +- Content.Server/Alert/Click/StopPulling.cs | 2 +- Content.Server/Hands/Systems/HandsSystem.cs | 27 ++- .../Physics/Controllers/PullController.cs | 24 +-- Content.Server/Pulling/PullingSystem.cs | 4 +- .../ArtifactInteractionTriggerSystem.cs | 2 +- .../Administration/AdminFrozenSystem.cs | 5 +- .../EntitySystems/AnchorableSystem.cs | 8 +- .../Interaction/SharedInteractionSystem.cs | 4 +- .../Pulling/Components/PullableComponent.cs | 57 ++++++ .../Components/SharedPullerComponent.cs | 2 +- .../Pulling/Events/PullAttemptEvent.cs | 11 +- Content.Shared/Pulling/Events/PullMessage.cs | 16 +- .../Pulling/Events/PullStartedMessage.cs | 13 +- .../Pulling/Events/PullStoppedMessage.cs | 13 +- .../Pulling/Events/StartPullAttemptEvent.cs | 23 ++- .../Pulling/Systems/SharedPullableSystem.cs | 5 +- .../Pulling/Systems/SharedPullerSystem.cs | 49 +++-- .../SharedPullingStateManagementSystem.cs | 189 ++++++++---------- .../Systems/SharedPullingSystem.Actions.cs | 150 +++++++------- .../Pulling/Systems/SharedPullingSystem.cs | 103 ++++------ .../Systems/DeployableBarrierSystem.cs | 2 +- .../Systems/SharedPortalSystem.cs | 8 +- Content.Shared/Throwing/ThrownItemSystem.cs | 4 +- 24 files changed, 392 insertions(+), 331 deletions(-) create mode 100644 Content.Shared/Pulling/Components/PullableComponent.cs diff --git a/Content.Server/Alert/Click/StopBeingPulled.cs b/Content.Server/Alert/Click/StopBeingPulled.cs index f8026fc5a39680..2cf076fbeed236 100644 --- a/Content.Server/Alert/Click/StopBeingPulled.cs +++ b/Content.Server/Alert/Click/StopBeingPulled.cs @@ -22,7 +22,7 @@ public void AlertClicked(EntityUid player) if (entityManager.TryGetComponent(player, out SharedPullableComponent? playerPullable)) { - entityManager.System().TryStopPull(player, playerPullable); + entityManager.System().TryStopPull(playerPullable); } } } diff --git a/Content.Server/Alert/Click/StopPulling.cs b/Content.Server/Alert/Click/StopPulling.cs index ffaac2fe33d49f..00a4149598517e 100644 --- a/Content.Server/Alert/Click/StopPulling.cs +++ b/Content.Server/Alert/Click/StopPulling.cs @@ -20,7 +20,7 @@ public void AlertClicked(EntityUid player) var playerTarget = ps.GetPulled(player); if (playerTarget != default && entManager.TryGetComponent(playerTarget, out SharedPullableComponent? playerPullable)) { - ps.TryStopPull(playerTarget, playerPullable); + ps.TryStopPull(playerPullable); } } } diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index 4f1e7cbe517019..62278064b685a2 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -10,12 +10,16 @@ using Content.Shared.Explosion; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; +using Content.Shared.IdentityManagement; using Content.Shared.Input; using Content.Shared.Inventory.VirtualItem; using Content.Shared.Physics.Pull; +using Content.Shared.Popups; using Content.Shared.Pulling.Components; using Content.Shared.Stacks; using Content.Shared.Throwing; +using Robust.Shared.Audio; +using Robust.Shared.Audio.Systems; using Robust.Shared.GameStates; using Robust.Shared.Input.Binding; using Robust.Shared.Map; @@ -39,7 +43,7 @@ public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnDisarmed, before: [typeof(StunSystem), typeof(StaminaSystem)]); + SubscribeLocalEvent(OnDisarmed, before: new[] {typeof(StunSystem), typeof(StaminaSystem)}); SubscribeLocalEvent(HandlePullStarted); SubscribeLocalEvent(HandlePullStopped); @@ -84,8 +88,9 @@ private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent a return; // Break any pulls - if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled) - _pullingSystem.TryStopPull(pulled); + if (TryComp(uid, out SharedPullerComponent? puller) && puller.Pulling is EntityUid pulled && + TryComp(pulled, out SharedPullableComponent? pullable)) + _pullingSystem.TryStopPull(pullable); if (!_handsSystem.TryDrop(uid, component.ActiveHand!, null, checkActionBlocker: false)) return; @@ -125,13 +130,13 @@ private void HandleBodyPartRemoved(EntityUid uid, HandsComponent component, ref private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) { - if (args.Puller != uid) + if (args.Puller.Owner != uid) return; - if (TryComp(args.Puller, out var pullerComp) && !pullerComp.NeedsHands) + if (TryComp(args.Puller.Owner, out var pullerComp) && !pullerComp.NeedsHands) return; - if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled, uid)) + if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.Pulled.Owner, uid)) { DebugTools.Assert("Unable to find available hand when starting pulling??"); } @@ -139,7 +144,7 @@ private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStar private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) { - if (args.Puller != uid) + if (args.Puller.Owner != uid) return; // Try find hand that is doing this pull. @@ -148,7 +153,7 @@ private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStop { if (hand.HeldEntity == null || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem) - || virtualItem.BlockingEntity != args.Pulled) + || virtualItem.BlockingEntity != args.Pulled.Owner) continue; QueueDel(hand.HeldEntity.Value); @@ -162,7 +167,7 @@ private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStop private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity) { - if (playerSession?.AttachedEntity is not { Valid: true } player || !Exists(player)) + if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player)) return false; return ThrowHeldItem(player, coordinates); @@ -187,7 +192,7 @@ hands.ActiveHandEntity is not { } throwEnt || { var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent(player).Coordinates, stack); - if (splitStack is not { Valid: true }) + if (splitStack is not {Valid: true}) return false; throwEnt = splitStack.Value; @@ -199,7 +204,7 @@ hands.ActiveHandEntity is not { } throwEnt || var length = direction.Length(); var distance = Math.Clamp(length, minDistance, hands.ThrowRange); - direction *= distance / length; + direction *= distance/length; var throwStrength = hands.ThrowForceMultiplier; diff --git a/Content.Server/Physics/Controllers/PullController.cs b/Content.Server/Physics/Controllers/PullController.cs index 98c6f10e710261..8f58f807aaee53 100644 --- a/Content.Server/Physics/Controllers/PullController.cs +++ b/Content.Server/Physics/Controllers/PullController.cs @@ -81,7 +81,7 @@ private void OnPullerMove(EntityUid uid, SharedPullerComponent component, ref Mo if (TryComp(pullable, out var physics)) PhysicsSystem.WakeBody(pullable, body: physics); - _pullableSystem.StopMoveTo((pullable, pullableComponent)); + _pullableSystem.StopMoveTo(pullableComponent); } private void UpdatePulledRotation(EntityUid puller, EntityUid pulled) @@ -131,32 +131,30 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) // This can include if leaving the Moving set due to not being pulled anymore, // or due to being deleted. - if (!TryComp(pullable, out var pullableComp)) + if (pullable.Deleted) continue; - if (pullableComp.Deleted) + if (pullable.MovingTo == null) continue; - if (pullableComp.MovingTo == null) + if (pullable.Puller is not {Valid: true} puller) continue; - if (pullableComp.Puller is not { Valid: true } puller) - continue; - - var pullableXform = Transform(pullable); + var pullableEnt = pullable.Owner; + var pullableXform = Transform(pullableEnt); var pullerXform = Transform(puller); // Now that's over with... var pullerPosition = pullerXform.MapPosition; - var movingTo = pullableComp.MovingTo.Value.ToMap(EntityManager, _transform); + var movingTo = pullable.MovingTo.Value.ToMap(EntityManager, _transform); if (movingTo.MapId != pullerPosition.MapId) { _pullableSystem.StopMoveTo(pullable); continue; } - if (!TryComp(pullable, out var physics) || + if (!TryComp(pullableEnt, out var physics) || physics.BodyType == BodyType.Static || movingTo.MapId != pullableXform.MapID) { @@ -172,7 +170,7 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) if (diffLength < MaximumSettleDistance && physics.LinearVelocity.Length() < MaximumSettleVelocity) { - PhysicsSystem.SetLinearVelocity(pullable, Vector2.Zero, body: physics); + PhysicsSystem.SetLinearVelocity(pullableEnt, Vector2.Zero, body: physics); _pullableSystem.StopMoveTo(pullable); continue; } @@ -190,10 +188,10 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime) accel -= physics.LinearVelocity * SettleShutdownMultiplier * scaling; } - PhysicsSystem.WakeBody(pullable, body: physics); + PhysicsSystem.WakeBody(pullableEnt, body: physics); var impulse = accel * physics.Mass * frameTime; - PhysicsSystem.ApplyLinearImpulse(pullable, impulse, body: physics); + PhysicsSystem.ApplyLinearImpulse(pullableEnt, impulse, body: physics); // if the puller is weightless or can't move, then we apply the inverse impulse (Newton's third law). // doing it under gravity produces an unsatisfying wiggling when pulling. diff --git a/Content.Server/Pulling/PullingSystem.cs b/Content.Server/Pulling/PullingSystem.cs index 512d221dab6f7b..69bb7c93704ede 100644 --- a/Content.Server/Pulling/PullingSystem.cs +++ b/Content.Server/Pulling/PullingSystem.cs @@ -27,7 +27,7 @@ public override void Initialize() private void HandleReleasePulledObject(ICommonSession? session) { - if (session?.AttachedEntity is not { Valid: true } player) + if (session?.AttachedEntity is not {Valid: true} player) { return; } @@ -42,7 +42,7 @@ private void HandleReleasePulledObject(ICommonSession? session) return; } - TryStopPull((pulled.Value, pullable)); + TryStopPull(pullable); } } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs index d4605b561bc142..239b6741608171 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs @@ -22,7 +22,7 @@ private void OnPull(EntityUid uid, ArtifactInteractionTriggerComponent component if (!component.PullActivation) return; - _artifactSystem.TryActivateArtifact(uid, args.Puller); + _artifactSystem.TryActivateArtifact(uid, args.Puller.Owner); } private void OnAttack(EntityUid uid, ArtifactInteractionTriggerComponent component, AttackedEvent args) diff --git a/Content.Shared/Administration/AdminFrozenSystem.cs b/Content.Shared/Administration/AdminFrozenSystem.cs index 6725ab6290aeb0..14438cc59120cc 100644 --- a/Content.Shared/Administration/AdminFrozenSystem.cs +++ b/Content.Shared/Administration/AdminFrozenSystem.cs @@ -1,10 +1,13 @@ using Content.Shared.ActionBlocker; using Content.Shared.Interaction.Events; using Content.Shared.Item; +using Content.Shared.Movement; using Content.Shared.Movement.Events; using Content.Shared.Physics.Pull; using Content.Shared.Pulling; using Content.Shared.Pulling.Components; +using Content.Shared.Pulling.Events; +using Content.Shared.Stunnable; using Content.Shared.Throwing; namespace Content.Shared.Administration; @@ -44,7 +47,7 @@ private void OnStartup(EntityUid uid, AdminFrozenComponent component, ComponentS { if (TryComp(uid, out var pullable)) { - _pulling.TryStopPull((uid, pullable)); + _pulling.TryStopPull(pullable); } UpdateCanMove(uid, component, args); diff --git a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs index 35f5f7814a01cc..70bcfbab43f496 100644 --- a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs +++ b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs @@ -9,11 +9,13 @@ using Content.Shared.Popups; using Content.Shared.Pulling; using Content.Shared.Pulling.Components; +using Content.Shared.Tools; using Content.Shared.Tools.Components; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics.Components; using Content.Shared.Tag; +using Robust.Shared.Player; using Robust.Shared.Serialization; using Robust.Shared.Utility; using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem; @@ -28,7 +30,7 @@ public sealed partial class AnchorableSystem : EntitySystem [Dependency] private readonly SharedPullingSystem _pulling = default!; [Dependency] private readonly SharedToolSystem _tool = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; - [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly TagSystem _tagSystem = default!; private EntityQuery _physicsQuery; private EntityQuery _tagQuery; @@ -131,7 +133,9 @@ private void OnAnchorComplete(EntityUid uid, AnchorableComponent component, TryA xform.LocalRotation = Math.Round(rot / (Math.PI / 2)) * (Math.PI / 2); if (TryComp(uid, out var pullable) && pullable.Puller != null) - _pulling.TryStopPull((uid, pullable)); + { + _pulling.TryStopPull(pullable); + } // TODO: Anchoring snaps rn anyway! if (component.Snap) diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs index 8649181e00b6a2..7d5e390b6f01ef 100644 --- a/Content.Shared/Interaction/SharedInteractionSystem.cs +++ b/Content.Shared/Interaction/SharedInteractionSystem.cs @@ -185,10 +185,10 @@ private bool HandleTryPullObject(ICommonSession? session, EntityCoordinates coor if (!InRangeUnobstructed(userEntity.Value, uid, popup: true)) return false; - if (!HasComp(uid)) + if (!TryComp(uid, out SharedPullableComponent? pull)) return false; - _pullSystem.TogglePull(userEntity.Value, uid); + _pullSystem.TogglePull(userEntity.Value, pull); return false; } diff --git a/Content.Shared/Pulling/Components/PullableComponent.cs b/Content.Shared/Pulling/Components/PullableComponent.cs new file mode 100644 index 00000000000000..c5c30688699464 --- /dev/null +++ b/Content.Shared/Pulling/Components/PullableComponent.cs @@ -0,0 +1,57 @@ +using Robust.Shared.GameStates; +using Robust.Shared.Map; +using Robust.Shared.Serialization; + +namespace Content.Shared.Pulling.Components +{ + // Before you try to add another type than SharedPullingStateManagementSystem, consider the can of worms you may be opening! + [NetworkedComponent, AutoGenerateComponentState] + [Access(typeof(SharedPullingStateManagementSystem))] + [RegisterComponent] + public sealed partial class SharedPullableComponent : Component + { + /// + /// The current entity pulling this component. + /// + [DataField, AutoNetworkedField] + public EntityUid? Puller { get; set; } + + /// + /// The pull joint. + /// + [DataField, AutoNetworkedField] + public string? PullJointId { get; set; } + + public bool BeingPulled => Puller != null; + + [Access(typeof(SharedPullingStateManagementSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends + public EntityCoordinates? MovingTo { get; set; } + + /// + /// If the physics component has FixedRotation should we keep it upon being pulled + /// + [Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)] + [ViewVariables(VVAccess.ReadWrite), DataField("fixedRotation")] + public bool FixedRotationOnPull { get; set; } + + /// + /// What the pullable's fixedrotation was set to before being pulled. + /// + [Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)] + [ViewVariables] + public bool PrevFixedRotation; + } + + /// + /// Raised when a request is made to stop pulling an entity. + /// + public sealed class StopPullingEvent : CancellableEntityEventArgs + { + public EntityUid? User { get; } + + public StopPullingEvent(EntityUid? uid = null) + { + User = uid; + } + } +} diff --git a/Content.Shared/Pulling/Components/SharedPullerComponent.cs b/Content.Shared/Pulling/Components/SharedPullerComponent.cs index 5f11bcbd89a165..57a86e7f7a842f 100644 --- a/Content.Shared/Pulling/Components/SharedPullerComponent.cs +++ b/Content.Shared/Pulling/Components/SharedPullerComponent.cs @@ -17,7 +17,7 @@ public sealed partial class SharedPullerComponent : Component /// /// Does this entity need hands to be able to pull something? /// - [DataField] + [DataField("needsHands")] public bool NeedsHands = true; } } diff --git a/Content.Shared/Pulling/Events/PullAttemptEvent.cs b/Content.Shared/Pulling/Events/PullAttemptEvent.cs index 53b4589be30d1a..6296dc2f14f68c 100644 --- a/Content.Shared/Pulling/Events/PullAttemptEvent.cs +++ b/Content.Shared/Pulling/Events/PullAttemptEvent.cs @@ -1,6 +1,11 @@ -namespace Content.Shared.Physics.Pull; +using Robust.Shared.Physics.Components; -public sealed class PullAttemptEvent(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) +namespace Content.Shared.Physics.Pull { - public bool Cancelled { get; set; } + public sealed class PullAttemptEvent : PullMessage + { + public PullAttemptEvent(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) { } + + public bool Cancelled { get; set; } + } } diff --git a/Content.Shared/Pulling/Events/PullMessage.cs b/Content.Shared/Pulling/Events/PullMessage.cs index 91172fe0fa0c50..b11de7c1702610 100644 --- a/Content.Shared/Pulling/Events/PullMessage.cs +++ b/Content.Shared/Pulling/Events/PullMessage.cs @@ -1,8 +1,16 @@ -namespace Content.Shared.Physics.Pull +using Robust.Shared.Physics.Components; + +namespace Content.Shared.Physics.Pull { - public abstract class PullMessage(EntityUid puller, EntityUid pulled) : EntityEventArgs + public abstract class PullMessage : EntityEventArgs { - public readonly EntityUid Puller = puller; - public readonly EntityUid Pulled = pulled; + public readonly PhysicsComponent Puller; + public readonly PhysicsComponent Pulled; + + protected PullMessage(PhysicsComponent puller, PhysicsComponent pulled) + { + Puller = puller; + Pulled = pulled; + } } } diff --git a/Content.Shared/Pulling/Events/PullStartedMessage.cs b/Content.Shared/Pulling/Events/PullStartedMessage.cs index a308f1d29766dd..0ede284bb0cc3b 100644 --- a/Content.Shared/Pulling/Events/PullStartedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStartedMessage.cs @@ -1,3 +1,12 @@ -namespace Content.Shared.Physics.Pull; +using Robust.Shared.Physics.Components; -public sealed class PullStartedMessage(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) { } +namespace Content.Shared.Physics.Pull +{ + public sealed class PullStartedMessage : PullMessage + { + public PullStartedMessage(PhysicsComponent puller, PhysicsComponent pulled) : + base(puller, pulled) + { + } + } +} diff --git a/Content.Shared/Pulling/Events/PullStoppedMessage.cs b/Content.Shared/Pulling/Events/PullStoppedMessage.cs index 95208dbc4a013e..afcbcb7074019b 100644 --- a/Content.Shared/Pulling/Events/PullStoppedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStoppedMessage.cs @@ -1,2 +1,11 @@ -namespace Content.Shared.Physics.Pull; -public sealed class PullStoppedMessage(EntityUid puller, EntityUid pulled) : PullMessage(puller, pulled) { } +using Robust.Shared.Physics.Components; + +namespace Content.Shared.Physics.Pull +{ + public sealed class PullStoppedMessage : PullMessage + { + public PullStoppedMessage(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) + { + } + } +} diff --git a/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs index bb91214ecd4180..9ef2ef3198cdd7 100644 --- a/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs +++ b/Content.Shared/Pulling/Events/StartPullAttemptEvent.cs @@ -1,10 +1,17 @@ -namespace Content.Shared.Pulling.Events; - -/// -/// Directed event raised on the puller to see if it can start pulling something. -/// -public sealed class StartPullAttemptEvent(EntityUid puller, EntityUid pulled) : CancellableEntityEventArgs +namespace Content.Shared.Pulling.Events { - public EntityUid Puller { get; } = puller; - public EntityUid Pulled { get; } = pulled; + /// + /// Directed event raised on the puller to see if it can start pulling something. + /// + public sealed class StartPullAttemptEvent : CancellableEntityEventArgs + { + public StartPullAttemptEvent(EntityUid puller, EntityUid pulled) + { + Puller = puller; + Pulled = pulled; + } + + public EntityUid Puller { get; } + public EntityUid Pulled { get; } + } } diff --git a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs index 48b03704f0c543..3dab476337b966 100644 --- a/Content.Shared/Pulling/Systems/SharedPullableSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullableSystem.cs @@ -17,11 +17,12 @@ public override void Initialize() SubscribeLocalEvent(OnRelayMoveInput); } - private void OnRelayMoveInput(Entity entity, ref MoveInputEvent args) + private void OnRelayMoveInput(EntityUid uid, SharedPullableComponent component, ref MoveInputEvent args) { + var entity = args.Entity; if (_mobState.IsIncapacitated(entity) || !_blocker.CanMove(entity)) return; - _pullSystem.TryStopPull((entity, entity.Comp)); + _pullSystem.TryStopPull(component); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs index 348bd101a61fdd..e388d7a57c6eb0 100644 --- a/Content.Shared/Pulling/Systems/SharedPullerSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullerSystem.cs @@ -29,55 +29,62 @@ public override void Initialize() SubscribeLocalEvent(OnPullerShutdown); } - private void OnPullerShutdown(Entity entity, ref ComponentShutdown args) + private void OnPullerShutdown(EntityUid uid, SharedPullerComponent component, ComponentShutdown args) { - _why.ForceDisconnectPuller(entity, entity.Comp); + _why.ForceDisconnectPuller(component); } - private void OnVirtualItemDeleted(Entity entity, ref VirtualItemDeletedEvent args) + private void OnVirtualItemDeleted(EntityUid uid, SharedPullerComponent component, VirtualItemDeletedEvent args) { - if (entity.Comp.Pulling == null) + if (component.Pulling == null) return; - if (entity.Comp.Pulling == args.BlockingEntity) + if (component.Pulling == args.BlockingEntity) { - if (TryComp(args.BlockingEntity, out var comp)) + if (EntityManager.TryGetComponent(args.BlockingEntity, out var comp)) { - _pullSystem.TryStopPull((args.BlockingEntity, comp), entity); + _pullSystem.TryStopPull(comp, uid); } } } - private void PullerHandlePullStarted(Entity entity, ref PullStartedMessage args) + private void PullerHandlePullStarted( + EntityUid uid, + SharedPullerComponent component, + PullStartedMessage args) { - if (args.Puller != entity.Owner) + if (args.Puller.Owner != uid) return; - _alertsSystem.ShowAlert(entity, AlertType.Pulling); + _alertsSystem.ShowAlert(component.Owner, AlertType.Pulling); - RefreshMovementSpeed(entity); + RefreshMovementSpeed(component); } - private void PullerHandlePullStopped(Entity entity, ref PullStoppedMessage args) + private void PullerHandlePullStopped( + EntityUid uid, + SharedPullerComponent component, + PullStoppedMessage args) { - if (args.Puller != entity.Owner) + if (args.Puller.Owner != uid) return; - if (_alertsSystem.IsShowingAlert(entity, AlertType.Pulling)) - _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(entity):user} stopped pulling {ToPrettyString(args.Pulled):target}"); - _alertsSystem.ClearAlert(entity, AlertType.Pulling); + var euid = component.Owner; + if (_alertsSystem.IsShowingAlert(euid, AlertType.Pulling)) + _adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(euid):user} stopped pulling {ToPrettyString(args.Pulled.Owner):target}"); + _alertsSystem.ClearAlert(euid, AlertType.Pulling); - RefreshMovementSpeed(entity); + RefreshMovementSpeed(component); } - private void OnRefreshMovespeed(Entity entity, ref RefreshMovementSpeedModifiersEvent args) + private void OnRefreshMovespeed(EntityUid uid, SharedPullerComponent component, RefreshMovementSpeedModifiersEvent args) { - args.ModifySpeed(entity.Comp.WalkSpeedModifier, entity.Comp.SprintSpeedModifier); + args.ModifySpeed(component.WalkSpeedModifier, component.SprintSpeedModifier); } - private void RefreshMovementSpeed(Entity entity) + private void RefreshMovementSpeed(SharedPullerComponent component) { - _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(entity); + _movementSpeedModifierSystem.RefreshMovementSpeedModifiers(component.Owner); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 52f34b6a4aa125..38ed8998898965 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -27,70 +27,56 @@ public override void Initialize() SubscribeLocalEvent(OnShutdown); } - private void OnShutdown(Entity entity, ref ComponentShutdown args) + private void OnShutdown(EntityUid uid, SharedPullableComponent component, ComponentShutdown args) { - if (entity.Comp.Puller != null) - ForceRelationship(null, entity); + if (component.Puller != null) + ForceRelationship(null, component); } // A WARNING: // The following 2 functions are the most internal part of the pulling system's relationship management. // They do not expect to be cancellable. - private void ForceDisconnect(Entity puller, Entity pullable) + private void ForceDisconnect(SharedPullerComponent puller, SharedPullableComponent pullable) { - if (!Resolve(puller, ref puller.Comp)) - return; - - if (!Resolve(pullable, ref pullable.Comp)) - return; + var pullerPhysics = EntityManager.GetComponent(puller.Owner); + var pullablePhysics = EntityManager.GetComponent(pullable.Owner); // MovingTo shutdown ForceSetMovingTo(pullable, null); // Joint shutdown if (!_timing.ApplyingState && // During state-handling, joint component will handle its own state. - pullable.Comp.PullJointId != null && - TryComp(puller, out JointComponent? jointComp)) + pullable.PullJointId != null && + TryComp(puller.Owner, out JointComponent? jointComp)) { - if (jointComp.GetJoints.TryGetValue(pullable.Comp.PullJointId, out var j)) + if (jointComp.GetJoints.TryGetValue(pullable.PullJointId, out var j)) _jointSystem.RemoveJoint(j); } - pullable.Comp.PullJointId = null; + pullable.PullJointId = null; // State shutdown - puller.Comp.Pulling = null; - pullable.Comp.Puller = null; + puller.Pulling = null; + pullable.Puller = null; // Messaging - var message = new PullStoppedMessage(puller, pullable); + var message = new PullStoppedMessage(pullerPhysics, pullablePhysics); - RaiseLocalEvent(puller, message, broadcast: false); + RaiseLocalEvent(puller.Owner, message, broadcast: false); - if (Initialized(pullable)) - RaiseLocalEvent(pullable, message, true); + if (Initialized(pullable.Owner)) + RaiseLocalEvent(pullable.Owner, message, true); // Networking Dirty(puller); Dirty(pullable); } - private void ForceDisconnect(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) - { - ForceDisconnect((puller, pullerComp), (pullable, pullableComp)); - } - - public void ForceRelationship(EntityUid? pullerEnt, EntityUid? pullableEnt, SharedPullerComponent? puller = null, SharedPullableComponent? pullable = null) + public void ForceRelationship(SharedPullerComponent? puller, SharedPullableComponent? pullable) { if (_timing.ApplyingState) return; - - if (pullerEnt != null && !Resolve(pullerEnt.Value, ref puller)) - return; - - if (pullableEnt != null && !Resolve(pullableEnt.Value, ref pullable)) - return; - - if (pullable != null && puller != null && puller.Pulling == pullableEnt) + ; + if (pullable != null && puller != null && (puller.Pulling == pullable.Owner)) { // Already done return; @@ -98,130 +84,113 @@ public void ForceRelationship(EntityUid? pullerEnt, EntityUid? pullableEnt, Shar // Start by disconnecting the pullable from whatever it is currently connected to. var pullableOldPullerE = pullable?.Puller; - if (pullableOldPullerE != null && pullableEnt != null) - ForceDisconnect(pullableOldPullerE.Value, pullableEnt.Value); + if (pullableOldPullerE != null) + { + ForceDisconnect(EntityManager.GetComponent(pullableOldPullerE.Value), pullable!); + } // Continue with the puller. var pullerOldPullableE = puller?.Pulling; - if (pullerOldPullableE != null && pullerEnt != null) - ForceDisconnect(pullerEnt.Value!, pullerOldPullableE.Value); - - if (pullerEnt == null || !Resolve(pullerEnt.Value, ref puller)) - return; - - if (pullableEnt == null || !Resolve(pullableEnt.Value, ref pullable)) - return; + if (pullerOldPullableE != null) + { + ForceDisconnect(puller!, EntityManager.GetComponent(pullerOldPullableE.Value)); + } // And now for the actual connection (if any). - var pullablePhysics = Comp(pullableEnt.Value); - pullable.PullJointId = $"pull-joint-{pullableEnt.Value}"; - // State startup - puller.Pulling = pullableEnt; - pullable.Puller = pullerEnt; - - // joint state handling will manage its own state - if (!_timing.ApplyingState) + if (puller != null && pullable != null) { - // Joint startup - var union = _physics.GetHardAABB(pullerEnt.Value).Union(_physics.GetHardAABB(pullableEnt.Value, body: pullablePhysics)); - var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f; - - var joint = _jointSystem.CreateDistanceJoint(pullableEnt.Value, pullerEnt.Value, id: pullable.PullJointId); - joint.CollideConnected = false; - // This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts. - joint.MaxLength = Math.Max(1.0f, length); - joint.Length = length * 0.75f; - joint.MinLength = 0f; - joint.Stiffness = 1f; + var pullerPhysics = EntityManager.GetComponent(puller.Owner); + var pullablePhysics = EntityManager.GetComponent(pullable.Owner); + pullable.PullJointId = $"pull-joint-{pullable.Owner}"; + + // State startup + puller.Pulling = pullable.Owner; + pullable.Puller = puller.Owner; + + // joint state handling will manage its own state + if (!_timing.ApplyingState) + { + // Joint startup + var union = _physics.GetHardAABB(puller.Owner).Union(_physics.GetHardAABB(pullable.Owner, body: pullablePhysics)); + var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f; + + var joint = _jointSystem.CreateDistanceJoint(pullablePhysics.Owner, pullerPhysics.Owner, id: pullable.PullJointId); + joint.CollideConnected = false; + // This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts. + joint.MaxLength = Math.Max(1.0f, length); + joint.Length = length * 0.75f; + joint.MinLength = 0f; + joint.Stiffness = 1f; + } + + // Messaging + var message = new PullStartedMessage(pullerPhysics, pullablePhysics); + + RaiseLocalEvent(puller.Owner, message, broadcast: false); + RaiseLocalEvent(pullable.Owner, message, true); + + // Networking + Dirty(puller); + Dirty(pullable); } - - // Messaging - var message = new PullStartedMessage(pullerEnt.Value, pullableEnt.Value); - - RaiseLocalEvent(pullerEnt.Value, message, broadcast: false); - RaiseLocalEvent(pullableEnt.Value, message, true); - - // Networking - Dirty(pullerEnt.Value, puller); - Dirty(pullableEnt.Value, pullable); - } - - public void ForceRelationship(Entity puller, Entity pullable) - { - ForceRelationship(puller, pullable, puller.Comp, pullable.Comp); } // For OnRemove use only. - public void ForceDisconnectPuller(Entity puller) + public void ForceDisconnectPuller(SharedPullerComponent puller) { // DO NOT ADD ADDITIONAL LOGIC IN THIS FUNCTION. Do it in ForceRelationship. ForceRelationship(puller, null); } - public void ForceDisconnectPuller(EntityUid puller, SharedPullerComponent? comp = null) - { - ForceDisconnectPuller((puller, comp)); - } - // For OnRemove use only. - public void ForceDisconnectPullable(Entity pullable) + public void ForceDisconnectPullable(SharedPullableComponent pullable) { // DO NOT ADD ADDITIONAL LOGIC IN THIS FUNCTION. Do it in ForceRelationship. ForceRelationship(null, pullable); } - public void ForceDisconnectPullable(EntityUid pullable, SharedPullableComponent? comp = null) + public void ForceSetMovingTo(SharedPullableComponent pullable, EntityCoordinates? movingTo) { - ForceDisconnectPullable((pullable, comp)); - } - - public void ForceSetMovingTo(Entity pullable, EntityCoordinates? movingTo) - { - if (!Resolve(pullable, ref pullable.Comp)) - return; - if (_timing.ApplyingState) return; - if (pullable.Comp.MovingTo == movingTo) + if (pullable.MovingTo == movingTo) + { return; + } // Don't allow setting a MovingTo if there's no puller. // The other half of this guarantee (shutting down a MovingTo if the puller goes away) is enforced in ForceRelationship. - if (pullable.Comp.Puller == null && movingTo != null) + if (pullable.Puller == null && movingTo != null) + { return; + } - pullable.Comp.MovingTo = movingTo; + pullable.MovingTo = movingTo; Dirty(pullable); if (movingTo == null) + { RaiseLocalEvent(pullable.Owner, new PullableStopMovingMessage(), true); + } else + { RaiseLocalEvent(pullable.Owner, new PullableMoveMessage(), true); - } - - public void ForceSetMovingTo(EntityUid pullable, EntityCoordinates? movingTo, SharedPullableComponent? comp = null) - { - ForceSetMovingTo((pullable, comp), movingTo); + } } /// /// Changes if the entity needs a hand in order to be able to pull objects. /// - public void ChangeHandRequirement(Entity entity, bool needsHands) + public void ChangeHandRequirement(EntityUid uid, bool needsHands, SharedPullerComponent? comp) { - if (!Resolve(entity, ref entity.Comp, false)) + if (!Resolve(uid, ref comp, false)) return; - entity.Comp.NeedsHands = needsHands; + comp.NeedsHands = needsHands; - Dirty(entity); - } - - public void ChangeHandRequirement(EntityUid uid, bool needsHands, SharedPullerComponent? comp = null) - { - ChangeHandRequirement((uid, comp), needsHands); + Dirty(uid, comp); } } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index 3ba13d335b246f..1e2bb90c61eb34 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -13,6 +13,7 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; +using Robust.Shared.Utility; namespace Content.Shared.Pulling { @@ -28,32 +29,48 @@ public abstract partial class SharedPullingSystem public bool CanPull(EntityUid puller, EntityUid pulled) { - if (!TryComp(puller, out var comp)) + if (!EntityManager.TryGetComponent(puller, out var comp)) + { return false; + } if (comp.NeedsHands && !_handsSystem.TryGetEmptyHand(puller, out _)) + { return false; + } if (!_blocker.CanInteract(puller, pulled)) + { return false; + } - if (!TryComp(pulled, out var physics)) + if (!EntityManager.TryGetComponent(pulled, out var physics)) + { return false; + } if (physics.BodyType == BodyType.Static) + { return false; + } if (puller == pulled) + { return false; + } - if (_containerSystem.IsEntityInContainer(puller) || _containerSystem.IsEntityInContainer(pulled)) + if(_containerSystem.IsEntityInContainer(puller) || _containerSystem.IsEntityInContainer(pulled)) + { return false; + } - if (TryComp(puller, out var buckle)) + if (EntityManager.TryGetComponent(puller, out BuckleComponent? buckle)) { // Prevent people pulling the chair they're on, etc. - if (buckle is { PullStrap: false, Buckled: true } && buckle.LastEntityBuckledTo == pulled) + if (buckle is { PullStrap: false, Buckled: true } && (buckle.LastEntityBuckledTo == pulled)) + { return false; + } } var getPulled = new BeingPulledAttemptEvent(puller, pulled); @@ -63,100 +80,95 @@ public bool CanPull(EntityUid puller, EntityUid pulled) return (!startPull.Cancelled && !getPulled.Cancelled); } - public bool TogglePull(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) - { - if (!Resolve(puller, ref pullerComp)) - return false; - - if (!Resolve(pullable, ref pullableComp)) - return false; - - return TogglePull((puller, pullerComp), (pullable, pullableComp)); - } - - public bool TogglePull(Entity puller, Entity pullable) + public bool TogglePull(EntityUid puller, SharedPullableComponent pullable) { - if (pullable.Comp?.Puller == puller) + if (pullable.Puller == puller) + { return TryStopPull(pullable); - - return TryStartPull(puller, pullable); + } + return TryStartPull(puller, pullable.Owner); } // -- Core attempted actions -- - public bool TryStopPull(EntityUid pullable, SharedPullableComponent? comp = null, EntityUid? user = null) + public bool TryStopPull(SharedPullableComponent pullable, EntityUid? user = null) { - return TryStopPull((pullable, comp), user); - } - - public bool TryStopPull(Entity pullable, EntityUid? user = null) - { - if (!Resolve(pullable, ref pullable.Comp)) - return false; - if (_timing.ApplyingState) return false; - if (!pullable.Comp.BeingPulled) + if (!pullable.BeingPulled) { return false; } var msg = new StopPullingEvent(user); - RaiseLocalEvent(pullable, msg, true); + RaiseLocalEvent(pullable.Owner, msg, true); if (msg.Cancelled) return false; // Stop pulling confirmed! - if (TryComp(pullable, out var pullablePhysics)) + if (TryComp(pullable.Owner, out var pullablePhysics)) { - _physics.SetFixedRotation(pullable, pullable.Comp.PrevFixedRotation, body: pullablePhysics); + _physics.SetFixedRotation(pullable.Owner, pullable.PrevFixedRotation, body: pullablePhysics); } _pullSm.ForceRelationship(null, pullable); return true; } - public bool TryStartPull(EntityUid puller, EntityUid pullable, SharedPullerComponent? pullerComp = null, SharedPullableComponent? pullableComp = null) + public bool TryStartPull(EntityUid puller, EntityUid pullable) { - return TryStartPull((puller, pullerComp), (pullable, pullableComp)); + if (!EntityManager.TryGetComponent(puller, out SharedPullerComponent? pullerComp)) + { + return false; + } + if (!EntityManager.TryGetComponent(pullable, out SharedPullableComponent? pullableComp)) + { + return false; + } + return TryStartPull(pullerComp, pullableComp); } // The main "start pulling" function. - public bool TryStartPull(Entity puller, Entity pullable) + public bool TryStartPull(SharedPullerComponent puller, SharedPullableComponent pullable) { - if (!Resolve(puller, ref puller.Comp) || !Resolve(pullable, ref pullable.Comp)) - return false; - if (_timing.ApplyingState) return false; - if (puller.Comp.Pulling == pullable) + if (puller.Pulling == pullable.Owner) return true; // Pulling a new object : Perform sanity checks. - if (!CanPull(puller, pullable)) + if (!CanPull(puller.Owner, pullable.Owner)) + { return false; + } - if (!HasComp(puller)) + if (!EntityManager.TryGetComponent(puller.Owner, out var pullerPhysics)) + { return false; + } - if (!TryComp(pullable, out var pullablePhysics)) + if (!EntityManager.TryGetComponent(pullable.Owner, out var pullablePhysics)) + { return false; + } // Ensure that the puller is not currently pulling anything. // If this isn't done, then it happens too late, and the start/stop messages go out of order, // and next thing you know it thinks it's not pulling anything even though it is! - var oldPullable = puller.Comp.Pulling; + var oldPullable = puller.Pulling; if (oldPullable != null) { - if (TryComp(oldPullable.Value, out var oldPullableComp)) + if (EntityManager.TryGetComponent(oldPullable.Value, out SharedPullableComponent? oldPullableComp)) { - if (!TryStopPull(oldPullable.Value, oldPullableComp)) + if (!TryStopPull(oldPullableComp)) + { return false; + } } else { @@ -168,69 +180,59 @@ public bool TryStartPull(Entity puller, Entity pullable, EntityCoordinates to) + public bool TryMoveTo(SharedPullableComponent pullable, EntityCoordinates to) { - if (!Resolve(pullable, ref pullable.Comp)) - return false; - - if (pullable.Comp.Puller == null) + if (pullable.Puller == null) + { return false; + } - if (!HasComp(pullable)) + if (!EntityManager.HasComponent(pullable.Owner)) + { return false; + } _pullSm.ForceSetMovingTo(pullable, to); return true; } - public void StopMoveTo(EntityUid pullable, SharedPullableComponent? comp = null) + public void StopMoveTo(SharedPullableComponent pullable) { - StopMoveTo((pullable, comp)); - } - - public void StopMoveTo(Entity pullable) - { - if (!Resolve(pullable, ref pullable.Comp)) - return; - _pullSm.ForceSetMovingTo(pullable, null); } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index 88e6ff6d82a734..0c139ee9e35010 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -26,12 +26,13 @@ public abstract partial class SharedPullingSystem : EntitySystem /// /// A mapping of pullers to the entity that they are pulling. /// - private readonly Dictionary _pullers = []; + private readonly Dictionary _pullers = + new(); - private readonly HashSet _moving = []; - private readonly HashSet _stoppedMoving = []; + private readonly HashSet _moving = new(); + private readonly HashSet _stoppedMoving = new(); - public IReadOnlySet Moving => _moving; + public IReadOnlySet Moving => _moving; public override void Initialize() { @@ -56,37 +57,37 @@ public override void Initialize() .Register(); } - private void OnPullableCollisionChange(Entity entity, ref CollisionChangeEvent args) + private void OnPullableCollisionChange(EntityUid uid, SharedPullableComponent component, ref CollisionChangeEvent args) { - if (entity.Comp.PullJointId != null && !args.CanCollide) + if (component.PullJointId != null && !args.CanCollide) { - _joints.RemoveJoint(entity, entity.Comp.PullJointId); + _joints.RemoveJoint(uid, component.PullJointId); } } - private void OnJointRemoved(Entity entity, ref JointRemovedEvent args) + private void OnJointRemoved(EntityUid uid, SharedPullableComponent component, JointRemovedEvent args) { - if (entity.Comp.Puller != args.OtherEntity) + if (component.Puller != args.OtherEntity) return; // Do we have some other join with our Puller? // or alternatively: // TODO track the relevant joint. - if (TryComp(entity, out JointComponent? joints)) + if (TryComp(uid, out JointComponent? joints)) { foreach (var jt in joints.GetJoints.Values) { - if (jt.BodyAUid == entity.Comp.Puller.Value || jt.BodyBUid == entity.Comp.Puller.Value) + if (jt.BodyAUid == component.Puller || jt.BodyBUid == component.Puller) return; } } // No more joints with puller -> force stop pull. - _pullSm.ForceDisconnectPullable(entity.Owner, entity.Comp); + _pullSm.ForceDisconnectPullable(component); } - private void AddPullVerbs(Entity entity, ref GetVerbsEvent args) + private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetVerbsEvent args) { if (!args.CanAccess || !args.CanInteract) return; @@ -96,25 +97,22 @@ private void AddPullVerbs(Entity entity, ref GetVerbsEv return; //TODO VERB ICONS add pulling icon - if (entity.Comp.Puller == args.User) + if (component.Puller == args.User) { - var user = args.User; Verb verb = new() { Text = Loc.GetString("pulling-verb-get-data-text-stop-pulling"), - Act = () => TryStopPull(entity.Owner, entity.Comp, user), + Act = () => TryStopPull(component, args.User), DoContactInteraction = false // pulling handle its own contact interaction. }; args.Verbs.Add(verb); } else if (CanPull(args.User, args.Target)) { - var user = args.User; - var target = args.Target; Verb verb = new() { Text = Loc.GetString("pulling-verb-get-data-text"), - Act = () => TryStartPull(user, target), + Act = () => TryStartPull(args.User, args.Target), DoContactInteraction = false // pulling handle its own contact interaction. }; args.Verbs.Add(verb); @@ -122,25 +120,25 @@ private void AddPullVerbs(Entity entity, ref GetVerbsEv } // Raise a "you are being pulled" alert if the pulled entity has alerts. - private void PullableHandlePullStarted(Entity entity, ref PullStartedMessage args) + private void PullableHandlePullStarted(EntityUid uid, SharedPullableComponent component, PullStartedMessage args) { - if (args.Pulled != entity.Owner) + if (args.Pulled.Owner != uid) return; - _alertsSystem.ShowAlert(entity, AlertType.Pulled); + _alertsSystem.ShowAlert(uid, AlertType.Pulled); } - private void PullableHandlePullStopped(Entity entity, ref PullStoppedMessage args) + private void PullableHandlePullStopped(EntityUid uid, SharedPullableComponent component, PullStoppedMessage args) { - if (args.Pulled != entity.Owner) + if (args.Pulled.Owner != uid) return; - _alertsSystem.ClearAlert(entity, AlertType.Pulled); + _alertsSystem.ClearAlert(uid, AlertType.Pulled); } - public bool IsPulled(Entity entity) + public bool IsPulled(EntityUid uid, SharedPullableComponent? component = null) { - return Resolve(entity, ref entity.Comp, false) && entity.Comp.BeingPulled; + return Resolve(uid, ref component, false) && component.BeingPulled; } public override void Update(float frameTime) @@ -160,22 +158,22 @@ public void Reset(RoundRestartCleanupEvent ev) private void OnPullStarted(PullStartedMessage message) { - SetPuller(message.Puller, message.Pulled); + SetPuller(message.Puller.Owner, message.Pulled.Owner); } private void OnPullStopped(PullStoppedMessage message) { - RemovePuller(message.Puller); + RemovePuller(message.Puller.Owner); } - protected void OnPullableMove(Entity entity, ref PullableMoveMessage args) + protected void OnPullableMove(EntityUid uid, SharedPullableComponent component, PullableMoveMessage args) { - _moving.Add(entity); + _moving.Add(component); } - protected void OnPullableStopMove(Entity entity, ref PullableStopMovingMessage args) + protected void OnPullableStopMove(EntityUid uid, SharedPullableComponent component, PullableStopMovingMessage args) { - _stoppedMoving.Add(entity); + _stoppedMoving.Add(component); } // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. @@ -183,7 +181,7 @@ private void HandleContainerInsert(EntInsertedIntoContainerMessage message) { if (TryComp(message.Entity, out SharedPullableComponent? pullable)) { - TryStopPull((message.Entity, pullable)); + TryStopPull(pullable); } if (TryComp(message.Entity, out SharedPullerComponent? puller)) @@ -193,7 +191,7 @@ private void HandleContainerInsert(EntInsertedIntoContainerMessage message) if (!TryComp(puller.Pulling.Value, out SharedPullableComponent? pulling)) return; - TryStopPull((puller.Pulling.Value, pulling)); + TryStopPull(pulling); } } @@ -203,10 +201,7 @@ private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates c !player.IsValid()) return false; - if (!TryComp(player, out var pullerComp)) - return false; - - if (!TryGetPulled((player, pullerComp), out var pulled)) + if (!TryGetPulled(player, out var pulled)) return false; if (!TryComp(pulled.Value, out SharedPullableComponent? pullable)) @@ -215,50 +210,32 @@ private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates c if (_containerSystem.IsEntityInContainer(player)) return false; - TryMoveTo((pulled.Value, pullable), coords); + TryMoveTo(pullable, coords); return false; } - private void SetPuller(Entity puller, Entity pulled) + private void SetPuller(EntityUid puller, EntityUid pulled) { _pullers[puller] = pulled; } - private bool RemovePuller(Entity puller) + private bool RemovePuller(EntityUid puller) { return _pullers.Remove(puller); } - public EntityUid GetPulled(EntityUid by, SharedPullerComponent? comp = null) - { - if (!Resolve(by, ref comp)) - return EntityUid.Invalid; - - return GetPulled((by, comp)); - } - public EntityUid GetPulled(Entity by) + public EntityUid GetPulled(EntityUid by) { return _pullers.GetValueOrDefault(by); } - public bool TryGetPulled(EntityUid by, [NotNullWhen(true)] out EntityUid? pulled, SharedPullerComponent? comp = null) - { - if (!Resolve(by, ref comp)) - { - pulled = default; - return false; - } - - return TryGetPulled((by, comp), out pulled); - } - - public bool TryGetPulled(Entity by, [NotNullWhen(true)] out EntityUid? pulled) + public bool TryGetPulled(EntityUid by, [NotNullWhen(true)] out EntityUid? pulled) { return (pulled = GetPulled(by)) != null; } - public bool IsPulling(Entity puller) + public bool IsPulling(EntityUid puller) { return _pullers.ContainsKey(puller); } diff --git a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs index c81527063bbcb0..7b9ce841a9939b 100644 --- a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs @@ -55,7 +55,7 @@ private void ToggleBarrierDeploy(EntityUid uid, bool isDeployed, DeployableBarri } if (TryComp(uid, out SharedPullableComponent? pullable)) - _pulling.TryStopPull(uid, pullable); + _pulling.TryStopPull(pullable); SharedPointLightComponent? pointLight = null; if (_pointLight.ResolveLight(uid, ref pointLight)) diff --git a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs index b356a1f94540fd..ebd83624114a0d 100644 --- a/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs +++ b/Content.Shared/Teleportation/Systems/SharedPortalSystem.cs @@ -95,13 +95,13 @@ private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollid // break pulls before portal enter so we dont break shit if (TryComp(subject, out var pullable) && pullable.BeingPulled) { - _pulling.TryStopPull((subject, pullable)); + _pulling.TryStopPull(pullable); } if (TryComp(subject, out var pulling) && pulling.Pulling != null && TryComp(pulling.Pulling.Value, out var subjectPulling)) { - _pulling.TryStopPull((pulling.Pulling.Value, subjectPulling)); + _pulling.TryStopPull(subjectPulling); } // if they came from another portal, just return and wait for them to exit the portal @@ -150,7 +150,7 @@ private void OnCollide(EntityUid uid, PortalComponent component, ref StartCollid private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndCollideEvent args) { - if (!ShouldCollide(args.OurFixtureId, args.OtherFixtureId, args.OurFixture, args.OtherFixture)) + if (!ShouldCollide(args.OurFixtureId, args.OtherFixtureId,args.OurFixture, args.OtherFixture)) return; var subject = args.OtherEntity; @@ -162,7 +162,7 @@ private void OnEndCollide(EntityUid uid, PortalComponent component, ref EndColli } } - private void TeleportEntity(EntityUid portal, EntityUid subject, EntityCoordinates target, EntityUid? targetEntity = null, bool playSound = true, + private void TeleportEntity(EntityUid portal, EntityUid subject, EntityCoordinates target, EntityUid? targetEntity=null, bool playSound=true, PortalComponent? portalComponent = null) { if (!Resolve(portal, ref portalComponent)) diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 67bdd5816ef1c3..0f38c4d753383b 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -85,8 +85,8 @@ private void OnSleep(EntityUid uid, ThrownItemComponent thrownItem, ref PhysicsS private void HandlePullStarted(PullStartedMessage message) { // TODO: this isn't directed so things have to be done the bad way - if (TryComp(message.Pulled, out var thrownItemComponent)) - StopThrow(message.Pulled, thrownItemComponent); + if (EntityManager.TryGetComponent(message.Pulled.Owner, out ThrownItemComponent? thrownItemComponent)) + StopThrow(message.Pulled.Owner, thrownItemComponent); } public void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent) From f4e01bad46a9875515375ee4511cbfdaf85443f9 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 19 Mar 2024 17:09:39 -0400 Subject: [PATCH 4/4] No --- .../Components/SharedPullableComponent.cs | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 Content.Shared/Pulling/Components/SharedPullableComponent.cs diff --git a/Content.Shared/Pulling/Components/SharedPullableComponent.cs b/Content.Shared/Pulling/Components/SharedPullableComponent.cs deleted file mode 100644 index 44be22564e7a85..00000000000000 --- a/Content.Shared/Pulling/Components/SharedPullableComponent.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Robust.Shared.GameStates; -using Robust.Shared.Map; - -namespace Content.Shared.Pulling.Components -{ - // Before you try to add another type than SharedPullingStateManagementSystem, consider the can of worms you may be opening! - [NetworkedComponent, AutoGenerateComponentState] - [Access(typeof(SharedPullingStateManagementSystem))] - [RegisterComponent] - public sealed partial class SharedPullableComponent : Component - { - /// - /// The current entity pulling this component. - /// - [DataField, AutoNetworkedField] - public EntityUid? Puller { get; set; } - - /// - /// The pull joint. - /// - [DataField, AutoNetworkedField] - public string? PullJointId { get; set; } - - public bool BeingPulled => Puller != null; - - [Access(typeof(SharedPullingStateManagementSystem), Other = AccessPermissions.ReadExecute)] // FIXME Friends - public EntityCoordinates? MovingTo { get; set; } - - /// - /// If the physics component has FixedRotation should we keep it upon being pulled - /// - [Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)] - [ViewVariables(VVAccess.ReadWrite), DataField("fixedRotation")] - public bool FixedRotationOnPull { get; set; } - - /// - /// What the pullable's fixedrotation was set to before being pulled. - /// - [Access(typeof(SharedPullingSystem), Other = AccessPermissions.ReadExecute)] - [ViewVariables] - public bool PrevFixedRotation; - } - - /// - /// Raised when a request is made to stop pulling an entity. - /// - public sealed class StopPullingEvent(EntityUid? uid = null) : CancellableEntityEventArgs - { - public EntityUid? User { get; } = uid; - } -}