using Content.Server.Ghost; using Content.Shared.Light.Components; using Content.Shared.Light.EntitySystems; namespace Content.Server.Light.EntitySystems; /// /// System for the PoweredLightComponents /// public sealed class PoweredLightSystem : SharedPoweredLightSystem { public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnGhostBoo); } private void OnGhostBoo(EntityUid uid, PoweredLightComponent light, GhostBooEvent args) { if (light.IgnoreGhostsBoo) return; // check cooldown first to prevent abuse var time = GameTiming.CurTime; if (light.LastGhostBlink != null) { if (time <= light.LastGhostBlink + light.GhostBlinkingCooldown) return; } light.LastGhostBlink = time; ToggleBlinkingLight(uid, light, true); uid.SpawnTimer(light.GhostBlinkingTime, () => { ToggleBlinkingLight(uid, light, false); }); args.Handled = true; } private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args) { // TODO: Use ContainerFill dog if (light.HasLampOnSpawn != null) { var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent(uid).Coordinates); ContainerSystem.Insert(entity, light.LightBulbContainer); } // need this to update visualizers UpdateLight(uid, light); } }