* Station AI overlay * implement * Bunch of ports * Fix a heap of bugs and basic scouting * helldivers * Shuffle interactions a bit * navmap stuff * Revert "navmap stuff" This reverts commit d1f89dd4be83233e22cf5dd062b2581f3c6da062. * AI wires implemented * Fix examines * Optimise the overlay significantly * Back to old static * BUI radial working * lots of work * Saving work * thanks fork * alright * pc * AI upload console * AI upload * stuff * Fix copy-paste shitcode * AI actions * navmap work * Fixes * first impressions * a * reh * Revert "navmap work" This reverts commit 6f63fea6e9245e189f368f97be3e32e9b210580e. # Conflicts: # Content.Client/Silicons/StationAi/StationAiOverlay.cs * OD * radar * weh * Fix examines * scoop mine eyes * fixes * reh * Optimise * Final round of optimisations * Fixes * fixes
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using Content.Shared.Light.Components;
|
|
using Content.Shared.Power;
|
|
using Content.Shared.Power.EntitySystems;
|
|
|
|
namespace Content.Shared.Light.EntitySystems;
|
|
|
|
public sealed class SlimPoweredLightSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedPowerReceiverSystem _receiver = default!;
|
|
[Dependency] private readonly SharedPointLightSystem _lights = default!;
|
|
|
|
private bool _setting;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<SlimPoweredLightComponent, AttemptPointLightToggleEvent>(OnLightAttempt);
|
|
SubscribeLocalEvent<SlimPoweredLightComponent, PowerChangedEvent>(OnLightPowerChanged);
|
|
}
|
|
|
|
private void OnLightAttempt(Entity<SlimPoweredLightComponent> ent, ref AttemptPointLightToggleEvent args)
|
|
{
|
|
// Early-out to avoid having to trycomp stuff if we're the caller setting it
|
|
if (_setting)
|
|
return;
|
|
|
|
if (args.Enabled && !_receiver.IsPowered(ent.Owner))
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void OnLightPowerChanged(Entity<SlimPoweredLightComponent> ent, ref PowerChangedEvent args)
|
|
{
|
|
// Early out if we don't need to trycomp.
|
|
if (args.Powered)
|
|
{
|
|
if (!ent.Comp.Enabled)
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (!ent.Comp.Enabled)
|
|
return;
|
|
}
|
|
|
|
if (!_lights.TryGetLight(ent.Owner, out var light))
|
|
return;
|
|
|
|
var enabled = ent.Comp.Enabled && args.Powered;
|
|
_setting = true;
|
|
_lights.SetEnabled(ent.Owner, enabled, light);
|
|
_setting = false;
|
|
}
|
|
|
|
public void SetEnabled(Entity<SlimPoweredLightComponent?> entity, bool enabled)
|
|
{
|
|
if (!Resolve(entity.Owner, ref entity.Comp, false))
|
|
return;
|
|
|
|
if (entity.Comp.Enabled == enabled)
|
|
return;
|
|
|
|
entity.Comp.Enabled = enabled;
|
|
Dirty(entity);
|
|
_lights.SetEnabled(entity.Owner, enabled);
|
|
}
|
|
}
|