diff --git a/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs index 0c1a8d1c68..dbca826f84 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/AiSystem.cs @@ -33,9 +33,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI { base.Initialize(); - // register entity query - EntityQuery = new TypeEntityQuery(typeof(AiControllerComponent)); - var processors = _reflectionManager.GetAllChildren(); foreach (var processor in processors) { @@ -49,18 +46,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI /// public override void Update(float frameTime) { - var entities = EntityManager.GetEntities(EntityQuery); - foreach (var entity in entities) + foreach (var comp in ComponentManager.EntityQuery()) { - if (_pauseManager.IsEntityPaused(entity)) + if (_pauseManager.IsEntityPaused(comp.Owner)) { continue; } + + ProcessorInitialize(comp); - var aiComp = entity.GetComponent(); - ProcessorInitialize(aiComp); - - var processor = aiComp.Processor; + var processor = comp.Processor; processor.Update(frameTime); } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs index 0bdd56c9cb..c6296a98cc 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs @@ -581,7 +581,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering return Vector2.Zero; } - if (target.TryGetComponent(out IPhysicsComponent physicsComponent)) + if (target.TryGetComponent(out ICollidableComponent physicsComponent)) { var targetDistance = (targetPos.Position - entityPos.Position); targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance); @@ -640,11 +640,12 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering // if we're moving in the same direction then ignore // So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction // i.e. towards the right - if (physicsEntity.TryGetComponent(out IPhysicsComponent physicsComponent) && + if (physicsEntity.TryGetComponent(out ICollidableComponent physicsComponent) && Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0) { continue; } + var centerGrid = physicsEntity.Transform.GridPosition; // Check how close we are to center of tile and get the inverse; if we're closer this is stronger var additionalVector = (centerGrid.Position - entityGridCoords.Position); diff --git a/Content.Server/GameObjects/EntitySystems/BaseChargerSystem.cs b/Content.Server/GameObjects/EntitySystems/BaseChargerSystem.cs index 7e59153404..2d763020b4 100644 --- a/Content.Server/GameObjects/EntitySystems/BaseChargerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BaseChargerSystem.cs @@ -1,23 +1,17 @@ using Content.Server.GameObjects.Components.Power.Chargers; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { [UsedImplicitly] - internal class BaseChargerSystem : EntitySystem + internal sealed class BaseChargerSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(BaseCharger)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - entity.GetComponent().OnUpdate(frameTime); + comp.OnUpdate(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/BatteryDischargerSystem.cs b/Content.Server/GameObjects/EntitySystems/BatteryDischargerSystem.cs index a17571a1b7..22fc2b7215 100644 --- a/Content.Server/GameObjects/EntitySystems/BatteryDischargerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BatteryDischargerSystem.cs @@ -1,31 +1,26 @@ using Content.Server.GameObjects.Components.Power.PowerNetComponents; +using JetBrains.Annotations; using Robust.Server.Interfaces.Timing; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.IoC; namespace Content.Server.GameObjects.EntitySystems { - internal class BatteryDischargerSystem : EntitySystem + [UsedImplicitly] + internal sealed class BatteryDischargerSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IPauseManager _pauseManager; -#pragma warning restore 649 - - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(BatteryDischargerComponent)); - } + [Dependency] private readonly IPauseManager _pauseManager = default!; public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - if (_pauseManager.IsEntityPaused(entity)) + if (_pauseManager.IsEntityPaused(comp.Owner)) { continue; } - entity.GetComponent().Update(frameTime); + + comp.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/BatteryStorageSystem.cs b/Content.Server/GameObjects/EntitySystems/BatteryStorageSystem.cs index 38fe005dcd..6f5ac89a8b 100644 --- a/Content.Server/GameObjects/EntitySystems/BatteryStorageSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BatteryStorageSystem.cs @@ -1,31 +1,26 @@ using Content.Server.GameObjects.Components.Power.PowerNetComponents; +using JetBrains.Annotations; using Robust.Server.Interfaces.Timing; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.IoC; namespace Content.Server.GameObjects.EntitySystems { - internal class BatteryStorageSystem : EntitySystem + [UsedImplicitly] + internal sealed class BatteryStorageSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IPauseManager _pauseManager; -#pragma warning restore 649 - - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(BatteryStorageComponent)); - } + [Dependency] private readonly IPauseManager _pauseManager = default!; public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - if (_pauseManager.IsEntityPaused(entity)) + if (_pauseManager.IsEntityPaused(comp.Owner)) { continue; } - entity.GetComponent().Update(frameTime); + + comp.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/BloodstreamSystem.cs b/Content.Server/GameObjects/EntitySystems/BloodstreamSystem.cs index 69b432084b..5a1587b626 100644 --- a/Content.Server/GameObjects/EntitySystems/BloodstreamSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BloodstreamSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects.Components.Metabolism; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { /// - /// Triggers metabolism updates for + /// Triggers metabolism updates for /// [UsedImplicitly] - public class BloodstreamSystem : EntitySystem + internal sealed class BloodstreamSystem : EntitySystem { private float _accumulatedFrameTime; - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(BloodstreamComponent)); - } public override void Update(float frameTime) { @@ -23,12 +18,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction _accumulatedFrameTime += frameTime; if (_accumulatedFrameTime > 1.0f) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); - comp.OnUpdate(_accumulatedFrameTime); + component.OnUpdate(_accumulatedFrameTime); } - _accumulatedFrameTime = 0.0f; + _accumulatedFrameTime -= 1.0f; } } } diff --git a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs index 0f5719d500..9fbb049322 100644 --- a/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/BuckleSystem.cs @@ -2,36 +2,25 @@ using Content.Server.GameObjects.EntitySystems.Click; using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystems; -using Robust.Shared.GameObjects; -using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.Map; -using Robust.Shared.IoC; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class BuckleSystem : EntitySystem + internal sealed class BuckleSystem : EntitySystem { public override void Initialize() { base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(BuckleComponent)); - UpdatesAfter.Add(typeof(InteractionSystem)); UpdatesAfter.Add(typeof(InputSystem)); } public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var buckle in ComponentManager.EntityQuery()) { - if (!entity.TryGetComponent(out BuckleComponent buckle)) - { - continue; - } - buckle.Update(); } } diff --git a/Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs b/Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs index 6d75e5bcd8..d65b266d1f 100644 --- a/Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ConveyorSystem.cs @@ -1,33 +1,19 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Content.Server.GameObjects.Components.Conveyor; using Content.Shared.GameObjects.Components.Conveyor; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class ConveyorSystem : EntitySystem + internal sealed class ConveyorSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(ConveyorComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - if (!entity.TryGetComponent(out ConveyorComponent conveyor)) - { - continue; - } - - conveyor.Update(frameTime); + comp.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/DisposableSystem.cs b/Content.Server/GameObjects/EntitySystems/DisposableSystem.cs index fd2bef87bf..536f0dfda4 100644 --- a/Content.Server/GameObjects/EntitySystems/DisposableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/DisposableSystem.cs @@ -1,25 +1,18 @@ using Content.Server.GameObjects.Components.Disposal; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class DisposableSystem : EntitySystem + internal sealed class DisposableSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(DisposalHolderComponent)); - } public override void Update(float frameTime) { - foreach (var disposable in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - disposable.GetComponent().Update(frameTime); + comp.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/DisposalUnitSystem.cs b/Content.Server/GameObjects/EntitySystems/DisposalUnitSystem.cs index cf668534bb..ecac19f19e 100644 --- a/Content.Server/GameObjects/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/DisposalUnitSystem.cs @@ -1,25 +1,17 @@ using Content.Server.GameObjects.Components.Disposal; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class DisposalUnitSystem : EntitySystem + internal sealed class DisposalUnitSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(DisposalUnitComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + comp.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/GravitySystem.cs b/Content.Server/GameObjects/EntitySystems/GravitySystem.cs index f87d303d05..eac786be6c 100644 --- a/Content.Server/GameObjects/EntitySystems/GravitySystem.cs +++ b/Content.Server/GameObjects/EntitySystems/GravitySystem.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Gravity; @@ -6,9 +5,7 @@ using Content.Server.GameObjects.Components.Mobs; using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.Player; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; @@ -19,42 +16,34 @@ using Robust.Shared.Random; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { [UsedImplicitly] - public class GravitySystem: EntitySystem + internal sealed class GravitySystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IMapManager _mapManager; - [Dependency] private readonly IPlayerManager _playerManager; - [Dependency] private readonly IRobustRandom _random; -#pragma warning restore 649 + [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IRobustRandom _random = default!; private const float GravityKick = 100.0f; private const uint ShakeTimes = 10; - private Dictionary _gridsToShake; + private Dictionary _gridsToShake = new Dictionary(); - private float internalTimer = 0.0f; - - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(); - _gridsToShake = new Dictionary(); - } + private float _internalTimer = 0.0f; public override void Update(float frameTime) { - internalTimer += frameTime; + _internalTimer += frameTime; var gridsWithGravity = new List(); - foreach (var entity in RelevantEntities) + foreach (var generator in ComponentManager.EntityQuery()) { - var generator = entity.GetComponent(); if (generator.NeedsUpdate) { generator.UpdateState(); } + if (generator.Status == GravityGeneratorStatus.On) { - gridsWithGravity.Add(entity.Transform.GridID); + gridsWithGravity.Add(generator.Owner.Transform.GridID); } } @@ -71,10 +60,10 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction } } - if (internalTimer > 0.2f) + if (_internalTimer > 0.2f) { ShakeGrids(); - internalTimer = 0.0f; + _internalTimer = 0.0f; } } diff --git a/Content.Server/GameObjects/EntitySystems/HandHeldLightSystem.cs b/Content.Server/GameObjects/EntitySystems/HandHeldLightSystem.cs index 8dd40458c3..0ffd887de5 100644 --- a/Content.Server/GameObjects/EntitySystems/HandHeldLightSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandHeldLightSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects.Components.Interactable; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class HandHeldLightSystem : EntitySystem + [UsedImplicitly] + internal sealed class HandHeldLightSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(HandheldLightComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.OnUpdate(frameTime); } } diff --git a/Content.Server/GameObjects/EntitySystems/HungerSystem.cs b/Content.Server/GameObjects/EntitySystems/HungerSystem.cs index 08d2c9bf98..4cc7972528 100644 --- a/Content.Server/GameObjects/EntitySystems/HungerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HungerSystem.cs @@ -1,30 +1,24 @@ using Content.Server.GameObjects.Components.Nutrition; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { [UsedImplicitly] - public class HungerSystem : EntitySystem + internal sealed class HungerSystem : EntitySystem { private float _accumulatedFrameTime; - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(HungerComponent)); - } - + public override void Update(float frameTime) { _accumulatedFrameTime += frameTime; if (_accumulatedFrameTime > 1.0f) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.OnUpdate(_accumulatedFrameTime); } - _accumulatedFrameTime = 0.0f; + _accumulatedFrameTime -= 1.0f; } } } diff --git a/Content.Server/GameObjects/EntitySystems/InstrumentSystem.cs b/Content.Server/GameObjects/EntitySystems/InstrumentSystem.cs index a64f1fec01..e95f9016b5 100644 --- a/Content.Server/GameObjects/EntitySystems/InstrumentSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/InstrumentSystem.cs @@ -1,24 +1,19 @@ using Content.Server.GameObjects.Components.Instruments; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { - public class InstrumentSystem : EntitySystem + [UsedImplicitly] + internal sealed class InstrumentSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(InstrumentComponent)); - } - public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + component.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/LatheSystem.cs b/Content.Server/GameObjects/EntitySystems/LatheSystem.cs index 7c39ae0cc3..7c4c96d9a1 100644 --- a/Content.Server/GameObjects/EntitySystems/LatheSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/LatheSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects.Components.Research; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class LatheSystem : EntitySystem + [UsedImplicitly] + internal sealed class LatheSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(LatheComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); if (comp.Producing == false && comp.Queue.Count > 0) { comp.Produce(comp.Queue.Dequeue()); diff --git a/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs b/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs index e4e518e1a8..f69477e089 100644 --- a/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ListeningSystem.cs @@ -1,37 +1,23 @@ using Content.Server.GameObjects.Components; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Map; using Robust.Shared.IoC; using Robust.Shared.Map; -using System; -using System.Collections.Generic; -using System.Text; namespace Content.Server.GameObjects.EntitySystems { - class ListeningSystem : EntitySystem + internal sealed class ListeningSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IMapManager _mapManager; - [Dependency] private readonly IEntitySystemManager _entitySystemManager; -#pragma warning restore 649 - - public override void Initialize() - { - base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(ListeningComponent)); - } + [Dependency] private readonly IMapManager _mapManager = default!; public void PingListeners(IEntity source, GridCoordinates sourcePos, string message) { - foreach (var listener in RelevantEntities) + foreach (var listener in ComponentManager.EntityQuery()) { - var dist = sourcePos.Distance(_mapManager, listener.Transform.GridPosition); + var dist = sourcePos.Distance(_mapManager, listener.Owner.Transform.GridPosition); - listener.GetComponent() - .PassSpeechData(message, source, dist); + listener.PassSpeechData(message, source, dist); } } } diff --git a/Content.Server/GameObjects/EntitySystems/MedicalScannerSystem.cs b/Content.Server/GameObjects/EntitySystems/MedicalScannerSystem.cs index 8dc8379b0d..9e84644d4f 100644 --- a/Content.Server/GameObjects/EntitySystems/MedicalScannerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MedicalScannerSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects.Components.Medical; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class MedicalScannerSystem : EntitySystem + [UsedImplicitly] + internal sealed class MedicalScannerSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(MedicalScannerComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.Update(frameTime); } } diff --git a/Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs b/Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs index 8bb7d80bdd..3231d4db5e 100644 --- a/Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MicrowaveSystem.cs @@ -1,23 +1,17 @@ using Content.Server.GameObjects.Components.Kitchen; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class MicrowaveSystem : EntitySystem + [UsedImplicitly] + internal sealed class MicrowaveSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(MicrowaveComponent)); - } - public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.OnUpdate(); } } diff --git a/Content.Server/GameObjects/EntitySystems/PointingSystem.cs b/Content.Server/GameObjects/EntitySystems/PointingSystem.cs index 6352aafef9..898ed90475 100644 --- a/Content.Server/GameObjects/EntitySystems/PointingSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PointingSystem.cs @@ -24,14 +24,12 @@ using Robust.Shared.Players; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class PointingSystem : EntitySystem + internal sealed class PointingSystem : EntitySystem { -#pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; -#pragma warning restore 649 private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f); @@ -156,8 +154,6 @@ namespace Content.Server.GameObjects.EntitySystems _playerManager.PlayerStatusChanged += OnPlayerStatusChanged; - EntityQuery = new TypeEntityQuery(typeof(PointingArrowComponent)); - CommandBinds.Builder .Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint)) .Register(); @@ -173,9 +169,9 @@ namespace Content.Server.GameObjects.EntitySystems public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + component.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/PortalSystem.cs b/Content.Server/GameObjects/EntitySystems/PortalSystem.cs index 7ffc532422..fc16603c09 100644 --- a/Content.Server/GameObjects/EntitySystems/PortalSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PortalSystem.cs @@ -1,23 +1,17 @@ using Content.Server.GameObjects.Components.Movement; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { [UsedImplicitly] - public class PortalSystem : EntitySystem + internal sealed class PortalSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(ServerPortalComponent)); - } - + // TODO: Someone refactor portals public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.OnUpdate(); } } diff --git a/Content.Server/GameObjects/EntitySystems/PowerApcSystem.cs b/Content.Server/GameObjects/EntitySystems/PowerApcSystem.cs index cbaaaa981e..2bdb58b2a2 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerApcSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerApcSystem.cs @@ -1,37 +1,32 @@ using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using System.Collections.Generic; +using JetBrains.Annotations; using Robust.Shared.IoC; using Robust.Server.Interfaces.Timing; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public sealed class ApcSystem : EntitySystem + [UsedImplicitly] + internal sealed class PowerApcSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IPauseManager _pauseManager; -#pragma warning restore 649 - - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(ApcComponent)); - } + [Dependency] private readonly IPauseManager _pauseManager = default!; public override void Update(float frameTime) { var uniqueApcNets = new HashSet(); //could be improved by maintaining set instead of getting collection every frame - foreach (var entity in RelevantEntities) + foreach (var apc in ComponentManager.EntityQuery()) { - if (_pauseManager.IsEntityPaused(entity)) + if (_pauseManager.IsEntityPaused(apc.Owner)) { continue; } - var apc = entity.GetComponent(); + uniqueApcNets.Add(apc.Net); - entity.GetComponent().Update(); + apc.Update(); } + foreach (var apcNet in uniqueApcNets) { apcNet.Update(frameTime); diff --git a/Content.Server/GameObjects/EntitySystems/PowerSmesSystem.cs b/Content.Server/GameObjects/EntitySystems/PowerSmesSystem.cs index 84f87f76b7..3f75198dbe 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerSmesSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerSmesSystem.cs @@ -1,21 +1,18 @@ using Content.Server.GameObjects.Components.Power; +using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { + [UsedImplicitly] internal class PowerSmesSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(SmesComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - entity.GetComponent().OnUpdate(); + comp.OnUpdate(); } } } diff --git a/Content.Server/GameObjects/EntitySystems/PowerSolarControlConsoleSystem.cs b/Content.Server/GameObjects/EntitySystems/PowerSolarControlConsoleSystem.cs index c823080a65..d2fb4e4255 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerSolarControlConsoleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerSolarControlConsoleSystem.cs @@ -1,16 +1,6 @@ using Content.Server.GameObjects.Components.Power; using JetBrains.Annotations; -using Content.Shared.Physics; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.Interfaces.Physics; -using Robust.Shared.Interfaces.Random; -using Robust.Shared.Interfaces.Timing; -using Robust.Shared.Physics; -using Robust.Shared.IoC; -using Robust.Shared.Maths; -using System; namespace Content.Server.GameObjects.EntitySystems { @@ -18,27 +8,22 @@ namespace Content.Server.GameObjects.EntitySystems /// Responsible for updating solar control consoles. /// [UsedImplicitly] - public class PowerSolarControlConsoleSystem : EntitySystem + internal sealed class PowerSolarControlConsoleSystem : EntitySystem { /// /// Timer used to avoid updating the UI state every frame (which would be overkill) /// - private float UpdateTimer = 0f; - - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(SolarControlConsoleComponent)); - } + private float _updateTimer; public override void Update(float frameTime) { - UpdateTimer += frameTime; - if (UpdateTimer >= 1) + _updateTimer += frameTime; + if (_updateTimer >= 1) { - UpdateTimer = 0; - foreach (var entity in RelevantEntities) + _updateTimer -= 1; + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().UpdateUIState(); + component.UpdateUIState(); } } } diff --git a/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs b/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs index 433c7661f2..4a5244302c 100644 --- a/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PowerSolarSystem.cs @@ -1,13 +1,11 @@ using Content.Server.GameObjects.Components.Power; using JetBrains.Annotations; using Content.Shared.Physics; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Timing; -using Robust.Shared.Physics; using Robust.Shared.IoC; using Robust.Shared.Maths; using System; @@ -19,12 +17,10 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction /// Responsible for maintaining the solar-panel sun angle and updating coverage. /// [UsedImplicitly] - public class PowerSolarSystem : EntitySystem + internal sealed class PowerSolarSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private IGameTiming _gameTiming; - [Dependency] private IRobustRandom _robustRandom; -#pragma warning restore 649 + [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; /// /// The current sun angle. @@ -75,7 +71,6 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction public override void Initialize() { - EntityQuery = new TypeEntityQuery(typeof(SolarPanelComponent)); // Initialize the sun to something random TowardsSun = MathHelper.TwoPi * _robustRandom.NextDouble(); SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05)); @@ -91,12 +86,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction TotalPanelPower = 0; - foreach (var entity in RelevantEntities) + foreach (var panel in ComponentManager.EntityQuery()) { // There's supposed to be rotational logic here, but that implies putting it somewhere. - entity.Transform.WorldRotation = TargetPanelRotation; - - var panel = entity.GetComponent(); + panel.Owner.Transform.WorldRotation = TargetPanelRotation; + if (panel.TimeOfNextCoverageUpdate < _gameTiming.CurTime) { // Setup the next coverage check. diff --git a/Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs b/Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs index 6dd87f8b24..86d9151657 100644 --- a/Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ProjectileSystem.cs @@ -1,6 +1,5 @@ using Content.Server.GameObjects.Components.Projectiles; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction @@ -8,25 +7,17 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction [UsedImplicitly] internal sealed class ProjectileSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(ProjectileComponent)); - } - public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - var component = entity.GetComponent(); component.TimeLeft -= frameTime; if (component.TimeLeft <= 0) { - entity.Delete(); + component.Owner.Delete(); } } } diff --git a/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs b/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs index 77133b8462..866ad39de9 100644 --- a/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/PuddleSystem.cs @@ -1,4 +1,5 @@ using Content.Server.GameObjects.Components.Fluids; +using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Systems; @@ -8,12 +9,12 @@ using Robust.Shared.Map; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class PuddleSystem : EntitySystem + [UsedImplicitly] + internal sealed class PuddleSystem : EntitySystem { public override void Initialize() { base.Initialize(); - EntityQuery = new TypeEntityQuery(typeof(PuddleComponent)); var mapManager = IoCManager.Resolve(); mapManager.TileChanged += HandleTileChanged; } @@ -28,17 +29,14 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction private void HandleTileChanged(object sender, TileChangedEventArgs eventArgs) { // If this gets hammered you could probably queue up all the tile changes every tick but I doubt that would ever happen. - var entities = EntityManager.GetEntities(EntityQuery); - - foreach (var entity in entities) + foreach (var (puddle, snapGrid) in ComponentManager.EntityQuery()) { // If the tile becomes space then delete it (potentially change by design) - if (eventArgs.NewTile.GridIndex == entity.Transform.GridID && - entity.TryGetComponent(out SnapGridComponent snapGridComponent) && - snapGridComponent.Position == eventArgs.NewTile.GridIndices && + if (eventArgs.NewTile.GridIndex == puddle.Owner.Transform.GridID && + snapGrid.Position == eventArgs.NewTile.GridIndices && eventArgs.NewTile.Tile.IsEmpty) { - entity.Delete(); + puddle.Owner.Delete(); break; // Currently it's one puddle per tile, if that changes remove this } } diff --git a/Content.Server/GameObjects/EntitySystems/RadioSystem.cs b/Content.Server/GameObjects/EntitySystems/RadioSystem.cs index 0d8ddf85db..59f2e27c2f 100644 --- a/Content.Server/GameObjects/EntitySystems/RadioSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/RadioSystem.cs @@ -1,27 +1,13 @@ using Content.Server.GameObjects.Components.Interactable; -using JetBrains.Annotations; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Content.Server.GameObjects.EntitySystems { - class RadioSystem : EntitySystem + internal sealed class RadioSystem : EntitySystem { - private List _messages; - - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(RadioComponent)); - _messages = new List(); - } + private readonly List _messages = new List(); public void SpreadMessage(IEntity source, string message) { @@ -32,10 +18,9 @@ namespace Content.Server.GameObjects.EntitySystems _messages.Add(message); - foreach (var radioEntity in RelevantEntities) + foreach (var radio in ComponentManager.EntityQuery()) { - var radio = radioEntity.GetComponent(); - if (radioEntity == source || !radio.RadioOn) + if (radio.Owner == source || !radio.RadioOn) { continue; } diff --git a/Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs b/Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs index 82029d4f08..c0904a1271 100644 --- a/Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/RecyclerSystem.cs @@ -1,25 +1,17 @@ using Content.Server.GameObjects.Components.Recycling; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class RecyclerSystem : EntitySystem + internal sealed class RecyclerSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(RecyclerComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + component.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/RoguePointingSystem.cs b/Content.Server/GameObjects/EntitySystems/RoguePointingSystem.cs index 7fcb5a06e7..7686fb1e3a 100644 --- a/Content.Server/GameObjects/EntitySystems/RoguePointingSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/RoguePointingSystem.cs @@ -1,25 +1,17 @@ using Content.Server.GameObjects.Components.Pointing; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class RoguePointingSystem : EntitySystem + internal sealed class RoguePointingSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(RoguePointingArrowComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + component.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/StomachSystem.cs b/Content.Server/GameObjects/EntitySystems/StomachSystem.cs index bbdc796c98..a6b6cad130 100644 --- a/Content.Server/GameObjects/EntitySystems/StomachSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StomachSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects.Components.Nutrition; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { /// - /// Triggers digestion updates on + /// Triggers digestion updates on /// [UsedImplicitly] - public class StomachSystem : EntitySystem + internal sealed class StomachSystem : EntitySystem { private float _accumulatedFrameTime; - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(StomachComponent)); - } public override void Update(float frameTime) { @@ -23,12 +18,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction _accumulatedFrameTime += frameTime; if (_accumulatedFrameTime > 1.0f) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); - comp.OnUpdate(_accumulatedFrameTime); + component.OnUpdate(_accumulatedFrameTime); } - _accumulatedFrameTime = 0.0f; + _accumulatedFrameTime -= 1.0f; } } } diff --git a/Content.Server/GameObjects/EntitySystems/StorageSystem.cs b/Content.Server/GameObjects/EntitySystems/StorageSystem.cs index 5d8793c72e..e33b958a93 100644 --- a/Content.Server/GameObjects/EntitySystems/StorageSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StorageSystem.cs @@ -1,16 +1,15 @@ using System.Collections.Generic; -using Content.Server.GameObjects; using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.EntitySystems.Click; +using JetBrains.Annotations; using Robust.Server.GameObjects.EntitySystemMessages; using Robust.Server.Interfaces.Player; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - class StorageSystem : EntitySystem + [UsedImplicitly] + internal sealed class StorageSystem : EntitySystem { private readonly List _sessionCache = new List(); @@ -19,16 +18,14 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction { SubscribeLocalEvent(HandleEntityRemovedFromContainer); SubscribeLocalEvent(HandleEntityInsertedIntoContainer); - - EntityQuery = new TypeEntityQuery(typeof(ServerStorageComponent)); } /// public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - CheckSubscribedEntities(entity); + CheckSubscribedEntities(component); } } @@ -52,9 +49,8 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction } } - private void CheckSubscribedEntities(IEntity entity) + private void CheckSubscribedEntities(ServerStorageComponent storageComp) { - var storageComp = entity.GetComponent(); // We have to cache the set of sessions because Unsubscribe modifies the original. _sessionCache.Clear(); @@ -63,8 +59,8 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction if (_sessionCache.Count == 0) return; - var storagePos = entity.Transform.WorldPosition; - var storageMap = entity.Transform.MapID; + var storagePos = storageComp.Owner.Transform.WorldPosition; + var storageMap = storageComp.Owner.Transform.MapID; foreach (var session in _sessionCache) { diff --git a/Content.Server/GameObjects/EntitySystems/StressTestMovementSystem.cs b/Content.Server/GameObjects/EntitySystems/StressTestMovementSystem.cs index 6539c17679..abdda79a09 100644 --- a/Content.Server/GameObjects/EntitySystems/StressTestMovementSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StressTestMovementSystem.cs @@ -1,30 +1,21 @@ using System; using Content.Server.GameObjects.Components; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Maths; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class StressTestMovementSystem : EntitySystem + internal sealed class StressTestMovementSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(); - } - public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var stressTest in ComponentManager.EntityQuery()) { - var stressTest = entity.GetComponent(); - var transform = entity.Transform; + var transform = stressTest.Owner.Transform; stressTest.Progress += frameTime; diff --git a/Content.Server/GameObjects/EntitySystems/StunSystem.cs b/Content.Server/GameObjects/EntitySystems/StunSystem.cs index ad5db08de4..8278b73b29 100644 --- a/Content.Server/GameObjects/EntitySystems/StunSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/StunSystem.cs @@ -1,27 +1,19 @@ using Content.Server.GameObjects.Components.Mobs; -using Content.Shared.GameObjects.Components.Mobs; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; -using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - public class StunSystem : EntitySystem + [UsedImplicitly] + internal sealed class StunSystem : EntitySystem { - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(StunnableComponent)); - } - public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - entity.GetComponent().Update(frameTime); + component.Update(frameTime); } } } diff --git a/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs b/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs index a60c561bdf..27652ad9f1 100644 --- a/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs @@ -1,21 +1,16 @@ using Content.Server.GameObjects; -using Robust.Shared.GameObjects; +using JetBrains.Annotations; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { - class TemperatureSystem : EntitySystem + [UsedImplicitly] + internal sealed class TemperatureSystem : EntitySystem { - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(TemperatureComponent)); - } - public override void Update(float frameTime) { - foreach (var entity in RelevantEntities) + foreach (var comp in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); comp.OnUpdate(frameTime); } } diff --git a/Content.Server/GameObjects/EntitySystems/ThirstSystem.cs b/Content.Server/GameObjects/EntitySystems/ThirstSystem.cs index fa2b860f70..dfc2294909 100644 --- a/Content.Server/GameObjects/EntitySystems/ThirstSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/ThirstSystem.cs @@ -1,30 +1,24 @@ using Content.Server.GameObjects.Components.Nutrition; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.Interfaces.GameObjects.Components.Interaction { [UsedImplicitly] - public class ThirstSystem : EntitySystem + internal sealed class ThirstSystem : EntitySystem { private float _accumulatedFrameTime; - public override void Initialize() - { - EntityQuery = new TypeEntityQuery(typeof(ThirstComponent)); - } public override void Update(float frameTime) { _accumulatedFrameTime += frameTime; if (_accumulatedFrameTime > 1.0f) { - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - var comp = entity.GetComponent(); - comp.OnUpdate(_accumulatedFrameTime); + component.OnUpdate(_accumulatedFrameTime); } - _accumulatedFrameTime = 0.0f; + _accumulatedFrameTime -= 1.0f; } } } diff --git a/Content.Server/GameObjects/EntitySystems/TimedOverlayRemovalSystem.cs b/Content.Server/GameObjects/EntitySystems/TimedOverlayRemovalSystem.cs index ceb07b97b1..4994837d09 100644 --- a/Content.Server/GameObjects/EntitySystems/TimedOverlayRemovalSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/TimedOverlayRemovalSystem.cs @@ -1,7 +1,6 @@ using Content.Server.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs; using JetBrains.Annotations; -using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; @@ -9,33 +8,24 @@ using Robust.Shared.IoC; namespace Content.Server.GameObjects.EntitySystems { [UsedImplicitly] - public class TimedOverlayRemovalSystem : EntitySystem + internal sealed class TimedOverlayRemovalSystem : EntitySystem { -#pragma warning disable 649 - [Dependency] private readonly IGameTiming _gameTiming; -#pragma warning restore 649 - - public override void Initialize() - { - base.Initialize(); - - EntityQuery = new TypeEntityQuery(typeof(ServerOverlayEffectsComponent)); - } + [Dependency] private readonly IGameTiming _gameTiming = default!; public override void Update(float frameTime) { base.Update(frameTime); - foreach (var entity in RelevantEntities) + foreach (var component in ComponentManager.EntityQuery()) { - var effectsComponent = entity.GetComponent(); - foreach (var overlay in effectsComponent.ActiveOverlays.ToArray()) + + foreach (var overlay in component.ActiveOverlays.ToArray()) { if (overlay.TryGetOverlayParameter(out var parameter)) { if (parameter.StartedAt + parameter.Length <= _gameTiming.CurTime.TotalMilliseconds) { - effectsComponent.RemoveOverlay(overlay); + component.RemoveOverlay(overlay); } } }