Server EntitySystem cleanup (#1617)

* Server EntitySystem cleanup

I went after low-hanging fruit systems.

* Add / change to internal access modifiers to systems
* Use EntityQuery to get components instead
* Add sealed modifier to systems
* Remove unused imports
* Add jetbrains annotation for unused classes
* Removed some pragmas for dependencies

This should also fix a decent chunk of the server build warnings, at least the ones that matter.

* Also disposals

* Update Content.Server/GameObjects/EntitySystems/GravitySystem.cs

* Fix build

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2020-08-13 22:17:12 +10:00
committed by GitHub
parent f4bf71edfe
commit 619386a04a
36 changed files with 172 additions and 424 deletions

View File

@@ -33,9 +33,6 @@ namespace Content.Server.GameObjects.EntitySystems.AI
{ {
base.Initialize(); base.Initialize();
// register entity query
EntityQuery = new TypeEntityQuery(typeof(AiControllerComponent));
var processors = _reflectionManager.GetAllChildren<AiLogicProcessor>(); var processors = _reflectionManager.GetAllChildren<AiLogicProcessor>();
foreach (var processor in processors) foreach (var processor in processors)
{ {
@@ -49,18 +46,16 @@ namespace Content.Server.GameObjects.EntitySystems.AI
/// <inheritdoc /> /// <inheritdoc />
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
var entities = EntityManager.GetEntities(EntityQuery); foreach (var comp in ComponentManager.EntityQuery<AiControllerComponent>())
foreach (var entity in entities)
{ {
if (_pauseManager.IsEntityPaused(entity)) if (_pauseManager.IsEntityPaused(comp.Owner))
{ {
continue; continue;
} }
ProcessorInitialize(comp);
var aiComp = entity.GetComponent<AiControllerComponent>(); var processor = comp.Processor;
ProcessorInitialize(aiComp);
var processor = aiComp.Processor;
processor.Update(frameTime); processor.Update(frameTime);
} }

View File

@@ -581,7 +581,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
return Vector2.Zero; return Vector2.Zero;
} }
if (target.TryGetComponent(out IPhysicsComponent physicsComponent)) if (target.TryGetComponent(out ICollidableComponent physicsComponent))
{ {
var targetDistance = (targetPos.Position - entityPos.Position); var targetDistance = (targetPos.Position - entityPos.Position);
targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance); 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 // 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 // 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 // i.e. towards the right
if (physicsEntity.TryGetComponent(out IPhysicsComponent physicsComponent) && if (physicsEntity.TryGetComponent(out ICollidableComponent physicsComponent) &&
Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0) Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0)
{ {
continue; continue;
} }
var centerGrid = physicsEntity.Transform.GridPosition; 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 // 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); var additionalVector = (centerGrid.Position - entityGridCoords.Position);

View File

@@ -1,23 +1,17 @@
using Content.Server.GameObjects.Components.Power.Chargers; using Content.Server.GameObjects.Components.Power.Chargers;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<BaseCharger>())
{ {
entity.GetComponent<BaseCharger>().OnUpdate(frameTime); comp.OnUpdate(frameTime);
} }
} }
} }

View File

@@ -1,31 +1,26 @@
using Content.Server.GameObjects.Components.Power.PowerNetComponents; using Content.Server.GameObjects.Components.Power.PowerNetComponents;
using JetBrains.Annotations;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
internal class BatteryDischargerSystem : EntitySystem [UsedImplicitly]
internal sealed class BatteryDischargerSystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IPauseManager _pauseManager = default!;
[Dependency] private readonly IPauseManager _pauseManager;
#pragma warning restore 649
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(BatteryDischargerComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<BatteryDischargerComponent>())
{ {
if (_pauseManager.IsEntityPaused(entity)) if (_pauseManager.IsEntityPaused(comp.Owner))
{ {
continue; continue;
} }
entity.GetComponent<BatteryDischargerComponent>().Update(frameTime);
comp.Update(frameTime);
} }
} }
} }

View File

@@ -1,31 +1,26 @@
using Content.Server.GameObjects.Components.Power.PowerNetComponents; using Content.Server.GameObjects.Components.Power.PowerNetComponents;
using JetBrains.Annotations;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC; using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
internal class BatteryStorageSystem : EntitySystem [UsedImplicitly]
internal sealed class BatteryStorageSystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IPauseManager _pauseManager = default!;
[Dependency] private readonly IPauseManager _pauseManager;
#pragma warning restore 649
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(BatteryStorageComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<BatteryStorageComponent>())
{ {
if (_pauseManager.IsEntityPaused(entity)) if (_pauseManager.IsEntityPaused(comp.Owner))
{ {
continue; continue;
} }
entity.GetComponent<BatteryStorageComponent>().Update(frameTime);
comp.Update(frameTime);
} }
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects.Components.Metabolism; using Content.Server.GameObjects.Components.Metabolism;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
/// <summary> /// <summary>
/// Triggers metabolism updates for <see cref="BloodstreamComponent"/> /// Triggers metabolism updates for <see cref="BloodstreamComponent"/>
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public class BloodstreamSystem : EntitySystem internal sealed class BloodstreamSystem : EntitySystem
{ {
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(BloodstreamComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
@@ -23,12 +18,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
_accumulatedFrameTime += frameTime; _accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime > 1.0f) if (_accumulatedFrameTime > 1.0f)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<BloodstreamComponent>())
{ {
var comp = entity.GetComponent<BloodstreamComponent>(); component.OnUpdate(_accumulatedFrameTime);
comp.OnUpdate(_accumulatedFrameTime);
} }
_accumulatedFrameTime = 0.0f; _accumulatedFrameTime -= 1.0f;
} }
} }
} }

View File

@@ -2,36 +2,25 @@
using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.GameObjects.EntitySystems.Click;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public class BuckleSystem : EntitySystem internal sealed class BuckleSystem : EntitySystem
{ {
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(BuckleComponent));
UpdatesAfter.Add(typeof(InteractionSystem)); UpdatesAfter.Add(typeof(InteractionSystem));
UpdatesAfter.Add(typeof(InputSystem)); UpdatesAfter.Add(typeof(InputSystem));
} }
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var buckle in ComponentManager.EntityQuery<BuckleComponent>())
{ {
if (!entity.TryGetComponent(out BuckleComponent buckle))
{
continue;
}
buckle.Update(); buckle.Update();
} }
} }

View File

@@ -1,33 +1,19 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Conveyor; using Content.Server.GameObjects.Components.Conveyor;
using Content.Shared.GameObjects.Components.Conveyor; using Content.Shared.GameObjects.Components.Conveyor;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<ConveyorComponent>())
{ {
if (!entity.TryGetComponent(out ConveyorComponent conveyor)) comp.Update(frameTime);
{
continue;
}
conveyor.Update(frameTime);
} }
} }
} }

View File

@@ -1,25 +1,18 @@
using Content.Server.GameObjects.Components.Disposal; using Content.Server.GameObjects.Components.Disposal;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var disposable in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<DisposalHolderComponent>())
{ {
disposable.GetComponent<DisposalHolderComponent>().Update(frameTime); comp.Update(frameTime);
} }
} }
} }

View File

@@ -1,25 +1,17 @@
using Content.Server.GameObjects.Components.Disposal; using Content.Server.GameObjects.Components.Disposal;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<DisposalUnitComponent>())
{ {
entity.GetComponent<DisposalUnitComponent>().Update(frameTime); comp.Update(frameTime);
} }
} }
} }

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.Gravity; using Content.Server.GameObjects.Components.Gravity;
@@ -6,9 +5,7 @@ using Content.Server.GameObjects.Components.Mobs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -19,42 +16,34 @@ using Robust.Shared.Random;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly] [UsedImplicitly]
public class GravitySystem: EntitySystem internal sealed class GravitySystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IMapManager _mapManager; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPlayerManager _playerManager; [Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IRobustRandom _random;
#pragma warning restore 649
private const float GravityKick = 100.0f; private const float GravityKick = 100.0f;
private const uint ShakeTimes = 10; private const uint ShakeTimes = 10;
private Dictionary<GridId, uint> _gridsToShake; private Dictionary<GridId, uint> _gridsToShake = new Dictionary<GridId, uint>();
private float internalTimer = 0.0f; private float _internalTimer = 0.0f;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery<GravityGeneratorComponent>();
_gridsToShake = new Dictionary<GridId, uint>();
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
internalTimer += frameTime; _internalTimer += frameTime;
var gridsWithGravity = new List<GridId>(); var gridsWithGravity = new List<GridId>();
foreach (var entity in RelevantEntities) foreach (var generator in ComponentManager.EntityQuery<GravityGeneratorComponent>())
{ {
var generator = entity.GetComponent<GravityGeneratorComponent>();
if (generator.NeedsUpdate) if (generator.NeedsUpdate)
{ {
generator.UpdateState(); generator.UpdateState();
} }
if (generator.Status == GravityGeneratorStatus.On) 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(); ShakeGrids();
internalTimer = 0.0f; _internalTimer = 0.0f;
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects.Components.Interactable; using Content.Server.GameObjects.Components.Interactable;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<HandheldLightComponent>())
{ {
var comp = entity.GetComponent<HandheldLightComponent>();
comp.OnUpdate(frameTime); comp.OnUpdate(frameTime);
} }
} }

View File

@@ -1,30 +1,24 @@
using Content.Server.GameObjects.Components.Nutrition; using Content.Server.GameObjects.Components.Nutrition;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly] [UsedImplicitly]
public class HungerSystem : EntitySystem internal sealed class HungerSystem : EntitySystem
{ {
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(HungerComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
_accumulatedFrameTime += frameTime; _accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime > 1.0f) if (_accumulatedFrameTime > 1.0f)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<HungerComponent>())
{ {
var comp = entity.GetComponent<HungerComponent>();
comp.OnUpdate(_accumulatedFrameTime); comp.OnUpdate(_accumulatedFrameTime);
} }
_accumulatedFrameTime = 0.0f; _accumulatedFrameTime -= 1.0f;
} }
} }
} }

View File

@@ -1,24 +1,19 @@
using Content.Server.GameObjects.Components.Instruments; using Content.Server.GameObjects.Components.Instruments;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems 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) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<InstrumentComponent>())
{ {
entity.GetComponent<InstrumentComponent>().Update(frameTime); component.Update(frameTime);
} }
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects.Components.Research; using Content.Server.GameObjects.Components.Research;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<LatheComponent>())
{ {
var comp = entity.GetComponent<LatheComponent>();
if (comp.Producing == false && comp.Queue.Count > 0) if (comp.Producing == false && comp.Queue.Count > 0)
{ {
comp.Produce(comp.Queue.Dequeue()); comp.Produce(comp.Queue.Dequeue());

View File

@@ -1,37 +1,23 @@
using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map; using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using System;
using System.Collections.Generic;
using System.Text;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
class ListeningSystem : EntitySystem internal sealed class ListeningSystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IMapManager _mapManager = default!;
[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));
}
public void PingListeners(IEntity source, GridCoordinates sourcePos, string message) public void PingListeners(IEntity source, GridCoordinates sourcePos, string message)
{ {
foreach (var listener in RelevantEntities) foreach (var listener in ComponentManager.EntityQuery<ListeningComponent>())
{ {
var dist = sourcePos.Distance(_mapManager, listener.Transform.GridPosition); var dist = sourcePos.Distance(_mapManager, listener.Owner.Transform.GridPosition);
listener.GetComponent<ListeningComponent>() listener.PassSpeechData(message, source, dist);
.PassSpeechData(message, source, dist);
} }
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects.Components.Medical; using Content.Server.GameObjects.Components.Medical;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<MedicalScannerComponent>())
{ {
var comp = entity.GetComponent<MedicalScannerComponent>();
comp.Update(frameTime); comp.Update(frameTime);
} }
} }

View File

@@ -1,23 +1,17 @@
using Content.Server.GameObjects.Components.Kitchen; using Content.Server.GameObjects.Components.Kitchen;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<MicrowaveComponent>())
{ {
var comp = entity.GetComponent<MicrowaveComponent>();
comp.OnUpdate(); comp.OnUpdate();
} }
} }

View File

@@ -24,14 +24,12 @@ using Robust.Shared.Players;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public class PointingSystem : EntitySystem internal sealed class PointingSystem : EntitySystem
{ {
#pragma warning disable 649
[Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!; [Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
#pragma warning restore 649
private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f); private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f);
@@ -156,8 +154,6 @@ namespace Content.Server.GameObjects.EntitySystems
_playerManager.PlayerStatusChanged += OnPlayerStatusChanged; _playerManager.PlayerStatusChanged += OnPlayerStatusChanged;
EntityQuery = new TypeEntityQuery(typeof(PointingArrowComponent));
CommandBinds.Builder CommandBinds.Builder
.Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint)) .Bind(ContentKeyFunctions.Point, new PointerInputCmdHandler(TryPoint))
.Register<PointingSystem>(); .Register<PointingSystem>();
@@ -173,9 +169,9 @@ namespace Content.Server.GameObjects.EntitySystems
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<PointingArrowComponent>())
{ {
entity.GetComponent<PointingArrowComponent>().Update(frameTime); component.Update(frameTime);
} }
} }
} }

View File

@@ -1,23 +1,17 @@
using Content.Server.GameObjects.Components.Movement; using Content.Server.GameObjects.Components.Movement;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly] [UsedImplicitly]
public class PortalSystem : EntitySystem internal sealed class PortalSystem : EntitySystem
{ {
public override void Initialize() // TODO: Someone refactor portals
{
EntityQuery = new TypeEntityQuery(typeof(ServerPortalComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<ServerPortalComponent>())
{ {
var comp = entity.GetComponent<ServerPortalComponent>();
comp.OnUpdate(); comp.OnUpdate();
} }
} }

View File

@@ -1,37 +1,32 @@
using Content.Server.GameObjects.Components.Power.ApcNetComponents; using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Server.GameObjects.Components.NodeContainer.NodeGroups; using Content.Server.GameObjects.Components.NodeContainer.NodeGroups;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Server.Interfaces.Timing; using Robust.Server.Interfaces.Timing;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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 = default!;
[Dependency] private readonly IPauseManager _pauseManager;
#pragma warning restore 649
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(ApcComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
var uniqueApcNets = new HashSet<IApcNet>(); //could be improved by maintaining set instead of getting collection every frame var uniqueApcNets = new HashSet<IApcNet>(); //could be improved by maintaining set instead of getting collection every frame
foreach (var entity in RelevantEntities) foreach (var apc in ComponentManager.EntityQuery<ApcComponent>())
{ {
if (_pauseManager.IsEntityPaused(entity)) if (_pauseManager.IsEntityPaused(apc.Owner))
{ {
continue; continue;
} }
var apc = entity.GetComponent<ApcComponent>();
uniqueApcNets.Add(apc.Net); uniqueApcNets.Add(apc.Net);
entity.GetComponent<ApcComponent>().Update(); apc.Update();
} }
foreach (var apcNet in uniqueApcNets) foreach (var apcNet in uniqueApcNets)
{ {
apcNet.Update(frameTime); apcNet.Update(frameTime);

View File

@@ -1,21 +1,18 @@
using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Power;
using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly]
internal class PowerSmesSystem : EntitySystem internal class PowerSmesSystem : EntitySystem
{ {
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(SmesComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<SmesComponent>())
{ {
entity.GetComponent<SmesComponent>().OnUpdate(); comp.OnUpdate();
} }
} }
} }

View File

@@ -1,16 +1,6 @@
using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Power;
using JetBrains.Annotations; using JetBrains.Annotations;
using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; 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 namespace Content.Server.GameObjects.EntitySystems
{ {
@@ -18,27 +8,22 @@ namespace Content.Server.GameObjects.EntitySystems
/// Responsible for updating solar control consoles. /// Responsible for updating solar control consoles.
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public class PowerSolarControlConsoleSystem : EntitySystem internal sealed class PowerSolarControlConsoleSystem : EntitySystem
{ {
/// <summary> /// <summary>
/// Timer used to avoid updating the UI state every frame (which would be overkill) /// Timer used to avoid updating the UI state every frame (which would be overkill)
/// </summary> /// </summary>
private float UpdateTimer = 0f; private float _updateTimer;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(SolarControlConsoleComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
UpdateTimer += frameTime; _updateTimer += frameTime;
if (UpdateTimer >= 1) if (_updateTimer >= 1)
{ {
UpdateTimer = 0; _updateTimer -= 1;
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<SolarControlConsoleComponent>())
{ {
entity.GetComponent<SolarControlConsoleComponent>().UpdateUIState(); component.UpdateUIState();
} }
} }
} }

View File

@@ -1,13 +1,11 @@
using Content.Server.GameObjects.Components.Power; using Content.Server.GameObjects.Components.Power;
using JetBrains.Annotations; using JetBrains.Annotations;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics; using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Random; using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.Physics;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using System; using System;
@@ -19,12 +17,10 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
/// Responsible for maintaining the solar-panel sun angle and updating <see cref='SolarPanelComponent'/> coverage. /// Responsible for maintaining the solar-panel sun angle and updating <see cref='SolarPanelComponent'/> coverage.
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public class PowerSolarSystem : EntitySystem internal sealed class PowerSolarSystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private IGameTiming _gameTiming; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private IRobustRandom _robustRandom;
#pragma warning restore 649
/// <summary> /// <summary>
/// The current sun angle. /// The current sun angle.
@@ -75,7 +71,6 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
public override void Initialize() public override void Initialize()
{ {
EntityQuery = new TypeEntityQuery(typeof(SolarPanelComponent));
// Initialize the sun to something random // Initialize the sun to something random
TowardsSun = MathHelper.TwoPi * _robustRandom.NextDouble(); TowardsSun = MathHelper.TwoPi * _robustRandom.NextDouble();
SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05)); SunAngularVelocity = Angle.FromDegrees(0.1 + ((_robustRandom.NextDouble() - 0.5) * 0.05));
@@ -91,12 +86,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
TotalPanelPower = 0; TotalPanelPower = 0;
foreach (var entity in RelevantEntities) foreach (var panel in ComponentManager.EntityQuery<SolarPanelComponent>())
{ {
// There's supposed to be rotational logic here, but that implies putting it somewhere. // There's supposed to be rotational logic here, but that implies putting it somewhere.
entity.Transform.WorldRotation = TargetPanelRotation; panel.Owner.Transform.WorldRotation = TargetPanelRotation;
var panel = entity.GetComponent<SolarPanelComponent>();
if (panel.TimeOfNextCoverageUpdate < _gameTiming.CurTime) if (panel.TimeOfNextCoverageUpdate < _gameTiming.CurTime)
{ {
// Setup the next coverage check. // Setup the next coverage check.

View File

@@ -1,6 +1,5 @@
using Content.Server.GameObjects.Components.Projectiles; using Content.Server.GameObjects.Components.Projectiles;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
@@ -8,25 +7,17 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
[UsedImplicitly] [UsedImplicitly]
internal sealed class ProjectileSystem : EntitySystem internal sealed class ProjectileSystem : EntitySystem
{ {
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(ProjectileComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<ProjectileComponent>())
{ {
var component = entity.GetComponent<ProjectileComponent>();
component.TimeLeft -= frameTime; component.TimeLeft -= frameTime;
if (component.TimeLeft <= 0) if (component.TimeLeft <= 0)
{ {
entity.Delete(); component.Owner.Delete();
} }
} }
} }

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.Components.Fluids; using Content.Server.GameObjects.Components.Fluids;
using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform; using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
@@ -8,12 +9,12 @@ using Robust.Shared.Map;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
public class PuddleSystem : EntitySystem [UsedImplicitly]
internal sealed class PuddleSystem : EntitySystem
{ {
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(PuddleComponent));
var mapManager = IoCManager.Resolve<IMapManager>(); var mapManager = IoCManager.Resolve<IMapManager>();
mapManager.TileChanged += HandleTileChanged; mapManager.TileChanged += HandleTileChanged;
} }
@@ -28,17 +29,14 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
private void HandleTileChanged(object sender, TileChangedEventArgs eventArgs) 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. // 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 (puddle, snapGrid) in ComponentManager.EntityQuery<PuddleComponent, SnapGridComponent>())
foreach (var entity in entities)
{ {
// If the tile becomes space then delete it (potentially change by design) // If the tile becomes space then delete it (potentially change by design)
if (eventArgs.NewTile.GridIndex == entity.Transform.GridID && if (eventArgs.NewTile.GridIndex == puddle.Owner.Transform.GridID &&
entity.TryGetComponent(out SnapGridComponent snapGridComponent) && snapGrid.Position == eventArgs.NewTile.GridIndices &&
snapGridComponent.Position == eventArgs.NewTile.GridIndices &&
eventArgs.NewTile.Tile.IsEmpty) eventArgs.NewTile.Tile.IsEmpty)
{ {
entity.Delete(); puddle.Owner.Delete();
break; // Currently it's one puddle per tile, if that changes remove this break; // Currently it's one puddle per tile, if that changes remove this
} }
} }

View File

@@ -1,27 +1,13 @@
using Content.Server.GameObjects.Components.Interactable; 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.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.GameObjects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
class RadioSystem : EntitySystem internal sealed class RadioSystem : EntitySystem
{ {
private List<string> _messages; private readonly List<string> _messages = new List<string>();
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(RadioComponent));
_messages = new List<string>();
}
public void SpreadMessage(IEntity source, string message) public void SpreadMessage(IEntity source, string message)
{ {
@@ -32,10 +18,9 @@ namespace Content.Server.GameObjects.EntitySystems
_messages.Add(message); _messages.Add(message);
foreach (var radioEntity in RelevantEntities) foreach (var radio in ComponentManager.EntityQuery<RadioComponent>())
{ {
var radio = radioEntity.GetComponent<RadioComponent>(); if (radio.Owner == source || !radio.RadioOn)
if (radioEntity == source || !radio.RadioOn)
{ {
continue; continue;
} }

View File

@@ -1,25 +1,17 @@
using Content.Server.GameObjects.Components.Recycling; using Content.Server.GameObjects.Components.Recycling;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<RecyclerComponent>())
{ {
entity.GetComponent<RecyclerComponent>().Update(frameTime); component.Update(frameTime);
} }
} }
} }

View File

@@ -1,25 +1,17 @@
using Content.Server.GameObjects.Components.Pointing; using Content.Server.GameObjects.Components.Pointing;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<RoguePointingArrowComponent>())
{ {
entity.GetComponent<RoguePointingArrowComponent>().Update(frameTime); component.Update(frameTime);
} }
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects.Components.Nutrition; using Content.Server.GameObjects.Components.Nutrition;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
/// <summary> /// <summary>
/// Triggers digestion updates on <see cref="StomachComponent"/> /// Triggers digestion updates on <see cref="StomachComponent"/>
/// </summary> /// </summary>
[UsedImplicitly] [UsedImplicitly]
public class StomachSystem : EntitySystem internal sealed class StomachSystem : EntitySystem
{ {
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(StomachComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
@@ -23,12 +18,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
_accumulatedFrameTime += frameTime; _accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime > 1.0f) if (_accumulatedFrameTime > 1.0f)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<StomachComponent>())
{ {
var comp = entity.GetComponent<StomachComponent>(); component.OnUpdate(_accumulatedFrameTime);
comp.OnUpdate(_accumulatedFrameTime);
} }
_accumulatedFrameTime = 0.0f; _accumulatedFrameTime -= 1.0f;
} }
} }
} }

View File

@@ -1,16 +1,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.GameObjects;
using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.EntitySystems.Click; using Content.Server.GameObjects.EntitySystems.Click;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystemMessages; using Robust.Server.GameObjects.EntitySystemMessages;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
class StorageSystem : EntitySystem [UsedImplicitly]
internal sealed class StorageSystem : EntitySystem
{ {
private readonly List<IPlayerSession> _sessionCache = new List<IPlayerSession>(); private readonly List<IPlayerSession> _sessionCache = new List<IPlayerSession>();
@@ -19,16 +18,14 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer); SubscribeLocalEvent<EntRemovedFromContainerMessage>(HandleEntityRemovedFromContainer);
SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer); SubscribeLocalEvent<EntInsertedIntoContainerMessage>(HandleEntityInsertedIntoContainer);
EntityQuery = new TypeEntityQuery(typeof(ServerStorageComponent));
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<ServerStorageComponent>())
{ {
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<ServerStorageComponent>();
// We have to cache the set of sessions because Unsubscribe modifies the original. // We have to cache the set of sessions because Unsubscribe modifies the original.
_sessionCache.Clear(); _sessionCache.Clear();
@@ -63,8 +59,8 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
if (_sessionCache.Count == 0) if (_sessionCache.Count == 0)
return; return;
var storagePos = entity.Transform.WorldPosition; var storagePos = storageComp.Owner.Transform.WorldPosition;
var storageMap = entity.Transform.MapID; var storageMap = storageComp.Owner.Transform.MapID;
foreach (var session in _sessionCache) foreach (var session in _sessionCache)
{ {

View File

@@ -1,30 +1,21 @@
using System; using System;
using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Maths; using Robust.Shared.Maths;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public class StressTestMovementSystem : EntitySystem internal sealed class StressTestMovementSystem : EntitySystem
{ {
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery<StressTestMovementComponent>();
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var stressTest in ComponentManager.EntityQuery<StressTestMovementComponent>())
{ {
var stressTest = entity.GetComponent<StressTestMovementComponent>(); var transform = stressTest.Owner.Transform;
var transform = entity.Transform;
stressTest.Progress += frameTime; stressTest.Progress += frameTime;

View File

@@ -1,27 +1,19 @@
using Content.Server.GameObjects.Components.Mobs; 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.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<StunnableComponent>())
{ {
entity.GetComponent<StunnableComponent>().Update(frameTime); component.Update(frameTime);
} }
} }
} }

View File

@@ -1,21 +1,16 @@
using Content.Server.GameObjects; using Content.Server.GameObjects;
using Robust.Shared.GameObjects; using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction 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) public override void Update(float frameTime)
{ {
foreach (var entity in RelevantEntities) foreach (var comp in ComponentManager.EntityQuery<TemperatureComponent>())
{ {
var comp = entity.GetComponent<TemperatureComponent>();
comp.OnUpdate(frameTime); comp.OnUpdate(frameTime);
} }
} }

View File

@@ -1,30 +1,24 @@
using Content.Server.GameObjects.Components.Nutrition; using Content.Server.GameObjects.Components.Nutrition;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
namespace Content.Server.Interfaces.GameObjects.Components.Interaction namespace Content.Server.Interfaces.GameObjects.Components.Interaction
{ {
[UsedImplicitly] [UsedImplicitly]
public class ThirstSystem : EntitySystem internal sealed class ThirstSystem : EntitySystem
{ {
private float _accumulatedFrameTime; private float _accumulatedFrameTime;
public override void Initialize()
{
EntityQuery = new TypeEntityQuery(typeof(ThirstComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
_accumulatedFrameTime += frameTime; _accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime > 1.0f) if (_accumulatedFrameTime > 1.0f)
{ {
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<ThirstComponent>())
{ {
var comp = entity.GetComponent<ThirstComponent>(); component.OnUpdate(_accumulatedFrameTime);
comp.OnUpdate(_accumulatedFrameTime);
} }
_accumulatedFrameTime = 0.0f; _accumulatedFrameTime -= 1.0f;
} }
} }
} }

View File

@@ -1,7 +1,6 @@
using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.Components.Mobs;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems; using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Timing; using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -9,33 +8,24 @@ using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems namespace Content.Server.GameObjects.EntitySystems
{ {
[UsedImplicitly] [UsedImplicitly]
public class TimedOverlayRemovalSystem : EntitySystem internal sealed class TimedOverlayRemovalSystem : EntitySystem
{ {
#pragma warning disable 649 [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
public override void Initialize()
{
base.Initialize();
EntityQuery = new TypeEntityQuery(typeof(ServerOverlayEffectsComponent));
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
base.Update(frameTime); base.Update(frameTime);
foreach (var entity in RelevantEntities) foreach (var component in ComponentManager.EntityQuery<ServerOverlayEffectsComponent>())
{ {
var effectsComponent = entity.GetComponent<ServerOverlayEffectsComponent>();
foreach (var overlay in effectsComponent.ActiveOverlays.ToArray()) foreach (var overlay in component.ActiveOverlays.ToArray())
{ {
if (overlay.TryGetOverlayParameter<TimedOverlayParameter>(out var parameter)) if (overlay.TryGetOverlayParameter<TimedOverlayParameter>(out var parameter))
{ {
if (parameter.StartedAt + parameter.Length <= _gameTiming.CurTime.TotalMilliseconds) if (parameter.StartedAt + parameter.Length <= _gameTiming.CurTime.TotalMilliseconds)
{ {
effectsComponent.RemoveOverlay(overlay); component.RemoveOverlay(overlay);
} }
} }
} }