From b647ad0f4290acc12e3bfc592d1e124014139ce6 Mon Sep 17 00:00:00 2001 From: Vince <39844191+Visne@users.noreply.github.com> Date: Sun, 16 Aug 2020 05:38:35 +0200 Subject: [PATCH] Refactor UpdateKinematics() and fix a lot of Content warnings (#1709) Most warnings were related to EntityQuery and IPhysicsComponent. Partially fixes #1650 and fixes #1682 --- .../EntitySystems/CameraRecoilSystem.cs | 11 +------- .../EntitySystems/InstrumentSystem.cs | 11 ++------ .../GameObjects/EntitySystems/MarkerSystem.cs | 12 ++------- .../EntitySystems/MeleeLungeSystem.cs | 12 ++------- .../EntitySystems/MeleeWeaponSystem.cs | 5 ++-- .../GameObjects/EntitySystems/MoverSystem.cs | 7 +++-- .../EntitySystems/StatusEffectsSystem.cs | 10 ++----- Content.Client/UserInterface/EscapeMenu.cs | 11 +++----- .../Atmos/GridAtmosphereComponent.cs | 1 - .../Components/Chemistry/VaporComponent.cs | 4 +-- .../Construction/ConstructionComponent.cs | 5 ---- .../Disposal/DisposalUnitComponent.cs | 2 +- .../Components/GUI/HandsComponent.cs | 4 +-- .../Components/Items/Storage/ItemComponent.cs | 4 +-- .../Movement/AiControllerComponent.cs | 6 ++--- .../Movement/ShuttleControllerComponent.cs | 19 +++++--------- .../Projectiles/ProjectileComponent.cs | 4 +-- .../Projectiles/ThrownItemComponent.cs | 2 +- .../Rotatable/RotatableComponent.cs | 4 +-- .../Barrels/ServerRangedBarrelComponent.cs | 8 +++--- .../AI/Steering/AiSteeringSystem.cs | 1 - .../EntitySystems/AtmosphereSystem.cs | 13 +++------- .../GameObjects/EntitySystems/MoverSystem.cs | 18 +++---------- Content.Server/Throw/ThrowHelper.cs | 4 +-- .../Disposal/SharedDisposalUnitComponent.cs | 2 +- .../SharedPlayerInputMoverComponent.cs | 6 ++--- .../Movement/SharedSlipperyComponent.cs | 3 +-- .../EntitySystems/SharedMoverSystem.cs | 26 ++++++++----------- .../Mechanism/MechanismPrototype.cs | 1 - 29 files changed, 65 insertions(+), 151 deletions(-) diff --git a/Content.Client/GameObjects/EntitySystems/CameraRecoilSystem.cs b/Content.Client/GameObjects/EntitySystems/CameraRecoilSystem.cs index 2d5af8c103..137dc2a5e7 100644 --- a/Content.Client/GameObjects/EntitySystems/CameraRecoilSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/CameraRecoilSystem.cs @@ -1,25 +1,16 @@ using Content.Client.GameObjects.Components.Mobs; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Client.GameObjects.EntitySystems { public sealed class CameraRecoilSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(CameraRecoilComponent)); - } - public override void FrameUpdate(float frameTime) { base.FrameUpdate(frameTime); - foreach (var entity in RelevantEntities) + foreach (var recoil in EntityManager.ComponentManager.EntityQuery()) { - var recoil = entity.GetComponent(); recoil.FrameUpdate(frameTime); } } diff --git a/Content.Client/GameObjects/EntitySystems/InstrumentSystem.cs b/Content.Client/GameObjects/EntitySystems/InstrumentSystem.cs index 5401274988..e184d7d1eb 100644 --- a/Content.Client/GameObjects/EntitySystems/InstrumentSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/InstrumentSystem.cs @@ -1,6 +1,5 @@ using Content.Client.GameObjects.Components.Instruments; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -12,12 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems { [Dependency] private readonly IGameTiming _gameTiming = default; - public override void Initialize() - { - base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(InstrumentComponent)); - } - public override void Update(float frameTime) { base.Update(frameTime); @@ -27,9 +20,9 @@ namespace Content.Client.GameObjects.EntitySystems return; } - foreach (var entity in RelevantEntities) + foreach (var instrumentComponent in EntityManager.ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + instrumentComponent.Update(frameTime); } } } diff --git a/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs b/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs index 7573253fb6..bec86abbb4 100644 --- a/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MarkerSystem.cs @@ -1,5 +1,4 @@ using Content.Client.GameObjects.Components.Markers; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Client.GameObjects.EntitySystems @@ -8,13 +7,6 @@ namespace Content.Client.GameObjects.EntitySystems { private bool _markersVisible; - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(); - } - public bool MarkersVisible { get => _markersVisible; @@ -27,9 +19,9 @@ namespace Content.Client.GameObjects.EntitySystems private void UpdateMarkers() { - foreach (var entity in RelevantEntities) + foreach (var markerComponent in EntityManager.ComponentManager.EntityQuery()) { - entity.GetComponent().UpdateVisibility(); + markerComponent.UpdateVisibility(); } } } diff --git a/Content.Client/GameObjects/EntitySystems/MeleeLungeSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeLungeSystem.cs index bff419b8ab..3f180d4399 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeLungeSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeLungeSystem.cs @@ -1,6 +1,5 @@ using Content.Client.GameObjects.Components.Mobs; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Client.GameObjects.EntitySystems @@ -8,20 +7,13 @@ namespace Content.Client.GameObjects.EntitySystems [UsedImplicitly] public sealed class MeleeLungeSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(); - } - public override void FrameUpdate(float frameTime) { base.FrameUpdate(frameTime); - foreach (var entity in RelevantEntities) + foreach (var meleeLungeComponent in EntityManager.ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + meleeLungeComponent.Update(frameTime); } } } diff --git a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs index 8b95cb6405..ca7a9d79e4 100644 --- a/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MeleeWeaponSystem.cs @@ -24,16 +24,15 @@ namespace Content.Client.GameObjects.EntitySystems public override void Initialize() { SubscribeNetworkEvent(PlayWeaponArc); - EntityQuery = new TypeEntityQuery(typeof(MeleeWeaponArcAnimationComponent)); } public override void FrameUpdate(float frameTime) { base.FrameUpdate(frameTime); - foreach (var entity in RelevantEntities) + foreach (var arcAnimationComponent in EntityManager.ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + arcAnimationComponent.Update(frameTime); } } diff --git a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs index b16cea1672..cdabb87d7c 100644 --- a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs @@ -30,11 +30,10 @@ namespace Content.Client.GameObjects.EntitySystems return; } - var physics = playerEnt.GetComponent(); - playerEnt.TryGetComponent(out ICollidableComponent? collidable); - physics.Predict = true; + var collidable = playerEnt.GetComponent(); + collidable.Predict = true; - UpdateKinematics(playerEnt.Transform, mover, physics, collidable); + UpdateKinematics(playerEnt.Transform, mover, collidable); } public override void Update(float frameTime) diff --git a/Content.Client/GameObjects/EntitySystems/StatusEffectsSystem.cs b/Content.Client/GameObjects/EntitySystems/StatusEffectsSystem.cs index a0fd868b2c..367c49f0b9 100644 --- a/Content.Client/GameObjects/EntitySystems/StatusEffectsSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/StatusEffectsSystem.cs @@ -1,5 +1,4 @@ using Content.Client.GameObjects.Components.Mobs; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -12,11 +11,6 @@ namespace Content.Client.GameObjects.EntitySystems [Dependency] private IGameTiming _gameTiming; #pragma warning restore 649 - public StatusEffectsSystem() - { - EntityQuery = new TypeEntityQuery(typeof(ClientStatusEffectsComponent)); - } - public override void FrameUpdate(float frameTime) { base.FrameUpdate(frameTime); @@ -24,9 +18,9 @@ namespace Content.Client.GameObjects.EntitySystems if (!_gameTiming.IsFirstTimePredicted) return; - foreach (var entity in RelevantEntities) + foreach (var clientStatusEffectsComponent in EntityManager.ComponentManager.EntityQuery()) { - entity.GetComponent().FrameUpdate(frameTime); + clientStatusEffectsComponent.FrameUpdate(frameTime); } } } diff --git a/Content.Client/UserInterface/EscapeMenu.cs b/Content.Client/UserInterface/EscapeMenu.cs index 3f085d1a8a..7b3ba644ce 100644 --- a/Content.Client/UserInterface/EscapeMenu.cs +++ b/Content.Client/UserInterface/EscapeMenu.cs @@ -1,5 +1,4 @@ -using Content.Client.Sandbox; -using Robust.Client.Console; +using Robust.Client.Console; using Robust.Client.Interfaces.Placement; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.UserInterface.Controls; @@ -15,16 +14,12 @@ namespace Content.Client.UserInterface internal sealed class EscapeMenu : SS14Window { private readonly IClientConsole _console; - private readonly ITileDefinitionManager __tileDefinitionManager; + private readonly ITileDefinitionManager _tileDefinitionManager; private readonly IPlacementManager _placementManager; private readonly IPrototypeManager _prototypeManager; private readonly IResourceCache _resourceCache; private readonly IConfigurationManager _configSystem; private readonly ILocalizationManager _localizationManager; -#pragma warning disable 649 - [Dependency] private readonly ISandboxManager _sandboxManager; - [Dependency] private readonly IClientConGroupController _conGroupController; -#pragma warning restore 649 private BaseButton DisconnectButton; private BaseButton QuitButton; @@ -41,7 +36,7 @@ namespace Content.Client.UserInterface _configSystem = configSystem; _localizationManager = localizationManager; _console = console; - __tileDefinitionManager = tileDefinitionManager; + _tileDefinitionManager = tileDefinitionManager; _placementManager = placementManager; _prototypeManager = prototypeManager; _resourceCache = resourceCache; diff --git a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs index c872ea8893..05ba999b0b 100644 --- a/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs +++ b/Content.Server/GameObjects/Components/Atmos/GridAtmosphereComponent.cs @@ -28,7 +28,6 @@ namespace Content.Server.GameObjects.Components.Atmos [RegisterComponent, Serializable] public class GridAtmosphereComponent : Component, IGridAtmosphereComponent { - [Robust.Shared.IoC.Dependency] private IGameTiming _gameTiming = default!; [Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!; /// diff --git a/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs b/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs index cc477cd8e9..066cf21836 100644 --- a/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/VaporComponent.cs @@ -16,9 +16,7 @@ namespace Content.Server.GameObjects.Components.Chemistry [RegisterComponent] class VaporComponent : Component, ICollideBehavior { -#pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager = default!; -#pragma warning enable 649 public override string Name => "Vapor"; [ViewVariables] @@ -66,7 +64,7 @@ namespace Content.Server.GameObjects.Components.Chemistry { var worldBounds = collidable.WorldAABB; var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID); - + var tiles = mapGrid.GetTilesIntersecting(worldBounds); var amount = _transferAmount / ReagentUnit.New(tiles.Count()); foreach (var tile in tiles) diff --git a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs index 8e5ca778a1..d29c7d93c9 100644 --- a/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs +++ b/Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs @@ -2,8 +2,6 @@ using Content.Shared.GameObjects.EntitySystems; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Serialization; using Robust.Shared.Utility; using Robust.Shared.ViewVariables; @@ -16,9 +14,6 @@ namespace Content.Server.GameObjects.Components.Construction [RegisterComponent] public class ConstructionComponent : Component, IExamine { -#pragma warning disable 649 - [Dependency] private readonly ILocalizationManager _loc; -#pragma warning restore 649 /// public override string Name => "Construction"; diff --git a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs index bc4d887457..89a6049b66 100644 --- a/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs +++ b/Content.Server/GameObjects/Components/Disposal/DisposalUnitComponent.cs @@ -94,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Disposal collidable.Anchored; [ViewVariables] - private State State => _pressure >= 1 ? State.Ready : State.Pressurizing; + private PressureState State => _pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing; [ViewVariables] private bool Engaged diff --git a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs index e9097d40b5..ea75c7f382 100644 --- a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs @@ -668,13 +668,13 @@ namespace Content.Server.GameObjects.Components.GUI Dirty(); - if (!message.Entity.TryGetComponent(out ICollidableComponent physics)) + if (!message.Entity.TryGetComponent(out ICollidableComponent collidable)) { return; } // set velocity to zero - physics.Stop(); + collidable.Stop(); return; } } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index daf1f94d07..67eca347f2 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -14,7 +14,6 @@ using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; -using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Serialization; @@ -29,7 +28,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage public override uint? NetID => ContentNetIDs.ITEM; #pragma warning disable 649 - [Dependency] private readonly IRobustRandom _robustRandom; [Dependency] private readonly IMapManager _mapManager; #pragma warning restore 649 @@ -93,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage return false; } - if (Owner.TryGetComponent(out PhysicsComponent physics) && + if (Owner.TryGetComponent(out CollidableComponent physics) && physics.Anchored) { return false; diff --git a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs index 0c89727f0c..26b450ca47 100644 --- a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs @@ -42,9 +42,9 @@ namespace Content.Server.GameObjects.Components.Movement { base.Initialize(); - // This component requires a physics component. - if (!Owner.HasComponent()) - Owner.AddComponent(); + // This component requires a collidable component. + if (!Owner.HasComponent()) + Owner.AddComponent(); } /// diff --git a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs index 62063854f2..85bb04b84b 100644 --- a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs @@ -71,22 +71,15 @@ namespace Content.Server.GameObjects.Components.Movement _entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) { //TODO: Switch to shuttle component - if (!gridEntity.TryGetComponent(out IPhysicsComponent physComp)) + if (!gridEntity.TryGetComponent(out ICollidableComponent collidable)) { - physComp = gridEntity.AddComponent(); - physComp.Mass = 1; + collidable = gridEntity.AddComponent(); + collidable.Mass = 1; + collidable.CanCollide = true; + collidable.PhysicsShapes.Add(new PhysShapeGrid(grid)); } - //TODO: Is this always true? - if (!gridEntity.HasComponent()) - { - var collideComp = gridEntity.AddComponent(); - collideComp.CanCollide = true; - //collideComp.IsHardCollidable = true; - collideComp.PhysicsShapes.Add(new PhysShapeGrid(grid)); - } - - var controller = physComp.EnsureController(); + var controller = collidable.EnsureController(); controller.Push(CalcNewVelocity(direction, enabled), CurrentWalkSpeed); } } diff --git a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs index 00613c2b96..9b633dc688 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs @@ -92,9 +92,9 @@ namespace Content.Server.GameObjects.Components.Projectiles } if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent) - && Owner.TryGetComponent(out IPhysicsComponent physicsComponent)) + && Owner.TryGetComponent(out ICollidableComponent collidableComponent)) { - var direction = physicsComponent.LinearVelocity.Normalized; + var direction = collidableComponent.LinearVelocity.Normalized; recoilComponent.Kick(direction); } } diff --git a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs index 2ae7c7f5c9..b072072bc5 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs @@ -88,7 +88,7 @@ namespace Content.Server.GameObjects.Components.Projectiles public void StartThrow(Vector2 direction, float speed) { - var comp = Owner.GetComponent(); + var comp = Owner.GetComponent(); comp.Status = BodyStatus.InAir; var controller = comp.EnsureController(); diff --git a/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs b/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs index 73194471c8..ffbcfbe4cc 100644 --- a/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs +++ b/Content.Server/GameObjects/Components/Rotatable/RotatableComponent.cs @@ -21,9 +21,9 @@ namespace Content.Server.GameObjects.Components.Rotatable private void TryRotate(IEntity user, Angle angle) { - if (Owner.TryGetComponent(out IPhysicsComponent physics)) + if (Owner.TryGetComponent(out ICollidableComponent collidable)) { - if (physics.Anchored) + if (collidable.Anchored) { _notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("It's stuck.")); return; diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index b3d6b8e924..4b0553fe2b 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -5,7 +5,6 @@ using Content.Server.GameObjects.Components.Damage; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Projectiles; using Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition; -using Content.Server.Interfaces; using Content.Shared.Audio; using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.EntitySystems; @@ -43,7 +42,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels #pragma warning disable 649 [Dependency] private IGameTiming _gameTiming; [Dependency] private IRobustRandom _robustRandom; - [Dependency] private readonly IServerNotifyManager _notifyManager; #pragma warning restore 649 public override FireRateSelector FireRateSelector => _fireRateSelector; @@ -385,15 +383,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels projectileAngle = angle; } - var physicsComponent = projectile.GetComponent(); - physicsComponent.Status = BodyStatus.InAir; + var collidableComponent = projectile.GetComponent(); + collidableComponent.Status = BodyStatus.InAir; projectile.Transform.GridPosition = Owner.Transform.GridPosition; var projectileComponent = projectile.GetComponent(); projectileComponent.IgnoreEntity(shooter); projectile - .GetComponent() + .GetComponent() .EnsureController() .LinearVelocity = projectileAngle.ToVec() * velocity; diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs index ea9ca44ec1..a9a7899300 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs @@ -27,7 +27,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering #pragma warning disable 649 [Dependency] private IMapManager _mapManager; - [Dependency] private IEntityManager _entityManager; [Dependency] private IPauseManager _pauseManager; #pragma warning restore 649 private PathfindingSystem _pathfindingSystem; diff --git a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs index 71acf54c52..327104a148 100644 --- a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs @@ -17,18 +17,14 @@ namespace Content.Server.GameObjects.EntitySystems [UsedImplicitly] public class AtmosphereSystem : EntitySystem { -#pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IPauseManager _pauseManager = default!; -#pragma warning restore 649 public override void Initialize() { base.Initialize(); _mapManager.TileChanged += OnTileChanged; - EntityQuery = new MultipleTypeEntityQuery(new List(){typeof(IGridAtmosphereComponent)}); } public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId) @@ -36,7 +32,7 @@ namespace Content.Server.GameObjects.EntitySystems // TODO Return space grid atmosphere for invalid grids or grids with no atmos var grid = _mapManager.GetGrid(gridId); - if (!_entityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null; + if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null; return gridEnt.TryGetComponent(out IGridAtmosphereComponent atmos) ? atmos : null; } @@ -45,13 +41,12 @@ namespace Content.Server.GameObjects.EntitySystems { base.Update(frameTime); - foreach (var gridEnt in RelevantEntities) + foreach (var (mapGridComponent, gridAtmosphereComponent) in EntityManager.ComponentManager.EntityQuery()) { - var grid = gridEnt.GetComponent(); - if (_pauseManager.IsGridPaused(grid.GridIndex)) + if (_pauseManager.IsGridPaused(mapGridComponent.GridIndex)) continue; - gridEnt.GetComponent().Update(frameTime); + gridAtmosphereComponent.Update(frameTime); } } diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 35c99acd98..84250d4e91 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -58,23 +58,13 @@ namespace Content.Server.GameObjects.EntitySystems public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var (moverComponent, collidableComponent) in EntityManager.ComponentManager.EntityQuery()) { + var entity = moverComponent.Owner; if (_pauseManager.IsEntityPaused(entity)) - { continue; - } - var mover = entity.GetComponent(); - var physics = entity.GetComponent(); - if (entity.TryGetComponent(out var collider)) - { - UpdateKinematics(entity.Transform, mover, physics, collider); - } - else - { - UpdateKinematics(entity.Transform, mover, physics); - } + UpdateKinematics(entity.Transform, moverComponent, collidableComponent); } } @@ -93,7 +83,7 @@ namespace Content.Server.GameObjects.EntitySystems ev.Entity.RemoveComponent(); } - if (ev.Entity.TryGetComponent(out IPhysicsComponent physics) && + if (ev.Entity.TryGetComponent(out ICollidableComponent physics) && physics.TryGetController(out MoverController controller)) { controller.StopMoving(); diff --git a/Content.Server/Throw/ThrowHelper.cs b/Content.Server/Throw/ThrowHelper.cs index 6b62531a7f..ad8e76b4bf 100644 --- a/Content.Server/Throw/ThrowHelper.cs +++ b/Content.Server/Throw/ThrowHelper.cs @@ -85,7 +85,7 @@ namespace Content.Server.Throw projComp.StartThrow(angle.ToVec(), spd); if (throwSourceEnt != null && - throwSourceEnt.TryGetComponent(out var physics) && + throwSourceEnt.TryGetComponent(out var physics) && physics.TryGetController(out MoverController mover)) { var physicsMgr = IoCManager.Resolve(); @@ -136,7 +136,7 @@ namespace Content.Server.Throw var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length; var throwDuration = ThrownItemComponent.DefaultThrowTime; var mass = 1f; - if (thrownEnt.TryGetComponent(out IPhysicsComponent physicsComponent)) + if (thrownEnt.TryGetComponent(out ICollidableComponent physicsComponent)) { mass = physicsComponent.Mass; } diff --git a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs index 1ce14ae17f..9bcd7edbf0 100644 --- a/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs +++ b/Content.Shared/GameObjects/Components/Disposal/SharedDisposalUnitComponent.cs @@ -51,7 +51,7 @@ namespace Content.Shared.GameObjects.Components.Disposal } [Serializable, NetSerializable] - public enum State + public enum PressureState { Ready, Pressurizing diff --git a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs index da88fdd468..9c74d666bc 100644 --- a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs @@ -142,11 +142,11 @@ namespace Content.Shared.GameObjects.Components.Movement /// public override void OnAdd() { - // This component requires that the entity has a PhysicsComponent. - if (!Owner.HasComponent()) + // This component requires that the entity has a CollidableComponent. + if (!Owner.HasComponent()) Logger.Error( $"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" + - $" {nameof(IPhysicsComponent)}. "); + $" {nameof(ICollidableComponent)}. "); base.OnAdd(); } diff --git a/Content.Shared/GameObjects/Components/Movement/SharedSlipperyComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedSlipperyComponent.cs index 4181a2e36d..4d05195dba 100644 --- a/Content.Shared/GameObjects/Components/Movement/SharedSlipperyComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/SharedSlipperyComponent.cs @@ -50,13 +50,12 @@ namespace Content.Shared.GameObjects.Components.Movement || _slipped.Contains(entity.Uid) || !entity.TryGetComponent(out SharedStunnableComponent stun) || !entity.TryGetComponent(out ICollidableComponent otherBody) - || !entity.TryGetComponent(out IPhysicsComponent otherPhysics) || !Owner.TryGetComponent(out ICollidableComponent body)) { return false; } - if (otherPhysics.LinearVelocity.Length < RequiredSlipSpeed || stun.KnockedDown) + if (otherBody.LinearVelocity.Length < RequiredSlipSpeed || stun.KnockedDown) { return false; } diff --git a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs index 8c2cdcc9c3..7c9a4537a2 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs @@ -29,8 +29,6 @@ namespace Content.Shared.GameObjects.EntitySystems { base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(IMoverComponent)); - var moveUpCmdHandler = new MoverDirInputCmdHandler(Direction.North); var moveLeftCmdHandler = new MoverDirInputCmdHandler(Direction.West); var moveRightCmdHandler = new MoverDirInputCmdHandler(Direction.East); @@ -54,18 +52,17 @@ namespace Content.Shared.GameObjects.EntitySystems base.Shutdown(); } - protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, IPhysicsComponent physics, - ICollidableComponent? collider = null) + protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, ICollidableComponent collidable) { - physics.EnsureController(); + collidable.EnsureController(); var weightless = !transform.Owner.HasComponent() && _physicsManager.IsWeightless(transform.GridPosition); - if (weightless && collider != null) + if (weightless) { // No gravity: is our entity touching anything? - var touching = IsAroundCollider(transform, mover, collider); + var touching = IsAroundCollider(transform, mover, collidable); if (!touching) { @@ -78,18 +75,16 @@ namespace Content.Shared.GameObjects.EntitySystems var combined = walkDir + sprintDir; if (combined.LengthSquared < 0.001 || !ActionBlockerSystem.CanMove(mover.Owner) && !weightless) { - if (physics.TryGetController(out MoverController controller)) + if (collidable.TryGetController(out MoverController controller)) { controller.StopMoving(); } } else { - //Console.WriteLine($"{IoCManager.Resolve().TickStamp}: {combined}"); - if (weightless) { - if (physics.TryGetController(out MoverController controller)) + if (collidable.TryGetController(out MoverController controller)) { controller.Push(combined, mover.CurrentPushSpeed); } @@ -99,12 +94,13 @@ namespace Content.Shared.GameObjects.EntitySystems } var total = walkDir * mover.CurrentWalkSpeed + sprintDir * mover.CurrentSprintSpeed; - //Console.WriteLine($"{walkDir} ({mover.CurrentWalkSpeed}) + {sprintDir} ({mover.CurrentSprintSpeed}): {total}"); - {if (physics.TryGetController(out MoverController controller)) { - controller.Move(total, 1); - }} + if (collidable.TryGetController(out MoverController controller)) + { + controller.Move(total, 1); + } + } transform.LocalRotation = total.GetDir().ToAngle(); diff --git a/Content.Shared/Health/BodySystem/Mechanism/MechanismPrototype.cs b/Content.Shared/Health/BodySystem/Mechanism/MechanismPrototype.cs index 3a37046b20..acf2711f28 100644 --- a/Content.Shared/Health/BodySystem/Mechanism/MechanismPrototype.cs +++ b/Content.Shared/Health/BodySystem/Mechanism/MechanismPrototype.cs @@ -18,7 +18,6 @@ namespace Content.Shared.Health.BodySystem.Mechanism private string _name; private string _description; private string _examineMessage; - private string _spritePath; private string _rsiPath; private string _rsiState; private int _durability;