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

@@ -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.
/// </summary>
[UsedImplicitly]
public class PowerSolarControlConsoleSystem : EntitySystem
internal sealed class PowerSolarControlConsoleSystem : EntitySystem
{
/// <summary>
/// Timer used to avoid updating the UI state every frame (which would be overkill)
/// </summary>
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<SolarControlConsoleComponent>())
{
entity.GetComponent<SolarControlConsoleComponent>().UpdateUIState();
component.UpdateUIState();
}
}
}