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:
@@ -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<HungerComponent>())
|
||||
{
|
||||
var comp = entity.GetComponent<HungerComponent>();
|
||||
comp.OnUpdate(_accumulatedFrameTime);
|
||||
}
|
||||
_accumulatedFrameTime = 0.0f;
|
||||
_accumulatedFrameTime -= 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user