Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,50 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Light.Components;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.Light.EntitySystems
{
[UsedImplicitly]
internal sealed class HandHeldLightSystem : EntitySystem
{
// TODO: Ideally you'd be able to subscribe to power stuff to get events at certain percentages.. or something?
// But for now this will be better anyway.
private HashSet<HandheldLightComponent> _activeLights = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ActivateHandheldLightMessage>(HandleActivate);
SubscribeLocalEvent<DeactivateHandheldLightMessage>(HandleDeactivate);
}
public override void Shutdown()
{
base.Shutdown();
_activeLights.Clear();
UnsubscribeLocalEvent<ActivateHandheldLightMessage>();
UnsubscribeLocalEvent<DeactivateHandheldLightMessage>();
}
private void HandleActivate(ActivateHandheldLightMessage message)
{
_activeLights.Add(message.Component);
}
private void HandleDeactivate(DeactivateHandheldLightMessage message)
{
_activeLights.Remove(message.Component);
}
public override void Update(float frameTime)
{
foreach (var handheld in _activeLights.ToArray())
{
if (handheld.Deleted || handheld.Paused) continue;
handheld.OnUpdate(frameTime);
}
}
}
}