Мягкий свет для всякого (#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,47 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Lightning;
|
||||
using Content.Shared.PowerCell;
|
||||
using Content.Shared.PowerCell.Components;
|
||||
using Content.Shared.Weapons.Ranged.Components;
|
||||
|
||||
namespace Content.Server._White.Lighting.Pointlight.Battery;
|
||||
|
||||
public sealed class PointLightBatterySystem : SharedLightningSystem
|
||||
{
|
||||
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
|
||||
[Dependency] private readonly SharedPowerCellSystem _cell = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightBatteryComponent, PowerCellChangedEvent>(OnBatteryLoose);
|
||||
SubscribeLocalEvent<PointLightBatteryComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
|
||||
}
|
||||
|
||||
private void OnBatteryLoose(EntityUid uid, PointLightBatteryComponent component, PowerCellChangedEvent args)
|
||||
{
|
||||
if (!component.RequireBattery)
|
||||
return;
|
||||
|
||||
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
|
||||
return;
|
||||
|
||||
var isBatteryCharged = _cell.HasDrawCharge(uid);
|
||||
_pointLightSystem.SetEnabled(uid, isBatteryCharged && !args.Ejected, pointLightComponent);
|
||||
|
||||
RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged && !args.Ejected), true);
|
||||
}
|
||||
|
||||
private void OnBatteryChargeChanged(EntityUid uid, PointLightBatteryComponent component, ChargeChangedEvent args)
|
||||
{
|
||||
if (!component.RequireBattery)
|
||||
return;
|
||||
|
||||
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
|
||||
return;
|
||||
|
||||
var isBatteryCharged = TryComp<ProjectileBatteryAmmoProviderComponent>(uid, out var projectileBattery) && projectileBattery.Shots > 0;
|
||||
_pointLightSystem.SetEnabled(uid, isBatteryCharged, pointLightComponent);
|
||||
|
||||
RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user