Мягкий свет для всякого (#316)
* add: add small soft light to laser weapon + fix the bluest blue energy shield * git commit * boltlights done * add: HuetaSystem * add: Doorlights finally done * add: small light to lockers * add: small light to multitool * fix: fix naming * hui pizde * fix: fix parasha * add: small light to powercells * zabil * add: code light to welders * tweak: better energy and radius * add: better color parameters * add: less radius and energy for guns * add: better lights for vending machines * add: better light to consoles * add: better light for apc * shut up * fix: thank you neuro colleague
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using Content.Shared.Lock;
|
||||
using Content.Shared.Storage.Components;
|
||||
|
||||
namespace Content.Shared._White.Lighting.PointLight.Locker;
|
||||
|
||||
public sealed class PointLightLockerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightLockerComponent, ComponentInit>(OnComponentInit);
|
||||
|
||||
SubscribeLocalEvent<PointLightLockerComponent, LockToggledEvent>(OnLockToggled);
|
||||
SubscribeLocalEvent<PointLightLockerComponent, StorageAfterOpenEvent>(OnStorageAfterOpen);
|
||||
SubscribeLocalEvent<PointLightLockerComponent, StorageAfterCloseEvent>(OnStorageAfterClose);
|
||||
}
|
||||
|
||||
public void ToggleLight(EntityUid uid, string hex, bool enable = true)
|
||||
{
|
||||
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
|
||||
return;
|
||||
|
||||
if (enable)
|
||||
{
|
||||
var color = Color.FromHex(hex);
|
||||
_pointLightSystem.SetColor(uid, color, pointLightComponent);
|
||||
}
|
||||
|
||||
_pointLightSystem.SetEnabled(uid, enable, pointLightComponent);
|
||||
|
||||
RaiseLocalEvent(uid, new PointLightToggleEvent(enable), true);
|
||||
}
|
||||
|
||||
public void OnComponentInit(EntityUid uid, PointLightLockerComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp<LockComponent>(uid, out var locker))
|
||||
return;
|
||||
|
||||
ToggleLight(uid, locker.Locked ? component.RedColor : component.GreenColor, true);
|
||||
}
|
||||
|
||||
public void OnLockToggled(EntityUid uid, PointLightLockerComponent component, LockToggledEvent args)
|
||||
{
|
||||
ToggleLight(uid, args.Locked ? component.RedColor : component.GreenColor, true);
|
||||
}
|
||||
|
||||
public void OnStorageAfterOpen(EntityUid uid, PointLightLockerComponent component, StorageAfterOpenEvent args)
|
||||
{
|
||||
ChangeLightOnDoorToggled(uid, component, true);
|
||||
}
|
||||
|
||||
public void OnStorageAfterClose(EntityUid uid, PointLightLockerComponent component, StorageAfterCloseEvent args)
|
||||
{
|
||||
ChangeLightOnDoorToggled(uid, component, false);
|
||||
}
|
||||
|
||||
public void ChangeLightOnDoorToggled(EntityUid uid, PointLightLockerComponent component, bool status)
|
||||
{
|
||||
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
|
||||
return;
|
||||
|
||||
var factor = status ? 1f : -1f;
|
||||
|
||||
_pointLightSystem.SetEnergy(uid, pointLightComponent.Energy - component.ReduceEnergyOnOpen * factor);
|
||||
_pointLightSystem.SetRadius(uid, pointLightComponent.Radius- component.ReduceRadiusOnOpen * factor);
|
||||
|
||||
RaiseLocalEvent(uid, new PointLightToggleEvent(true), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user