Мягкий свет для всякого (#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,24 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared._White.Lighting;
|
||||
using Content.Shared._White.Lighting.PointLight.Airlock;
|
||||
using Content.Shared.Doors.Components;
|
||||
|
||||
namespace Content.Server._White.Lighting.Pointlight.Airlock;
|
||||
|
||||
public sealed class PointLightAirlockSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightAirlockComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, PointLightAirlockComponent component, PowerChangedEvent args)
|
||||
{
|
||||
if (!TryComp<DoorComponent>(uid, out var door))
|
||||
return;
|
||||
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(args.Powered ? door.State : null, args.Powered), true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server._White.Lighting;
|
||||
namespace Content.Server._White.Lighting.Pointlight.Battery;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PointLightBatteryComponent : Component
|
||||
@@ -1,8 +1,10 @@
|
||||
using Content.Shared.Lightning;
|
||||
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;
|
||||
namespace Content.Server._White.Lighting.Pointlight.Battery;
|
||||
|
||||
public sealed class PointLightBatterySystem : SharedLightningSystem
|
||||
{
|
||||
@@ -12,6 +14,7 @@ public sealed class PointLightBatterySystem : SharedLightningSystem
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightBatteryComponent, PowerCellChangedEvent>(OnBatteryLoose);
|
||||
SubscribeLocalEvent<PointLightBatteryComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
|
||||
}
|
||||
|
||||
private void OnBatteryLoose(EntityUid uid, PointLightBatteryComponent component, PowerCellChangedEvent args)
|
||||
@@ -27,4 +30,18 @@ public sealed class PointLightBatterySystem : SharedLightningSystem
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.PowerCell;
|
||||
using Content.Shared.Rounding;
|
||||
|
||||
namespace Content.Server._White.Lighting.PointLight.RealBattery;
|
||||
|
||||
public sealed class PointLightRealBatterySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightRealBatteryComponent, ChargeChangedEvent>(OnChargeChanged);
|
||||
SubscribeLocalEvent<PointLightRealBatteryComponent, ComponentInit>(OnComponentInit);
|
||||
}
|
||||
|
||||
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, PointLightRealBatteryComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp<BatteryComponent>(uid, out var battery))
|
||||
return;
|
||||
|
||||
var ev = new ChargeChangedEvent(battery.CurrentCharge, battery.MaxCharge);
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
}
|
||||
public void OnChargeChanged(EntityUid uid, PointLightRealBatteryComponent component, ChargeChangedEvent args)
|
||||
{
|
||||
var frac = args.Charge / args.MaxCharge;
|
||||
var level = (byte) ContentHelpers.RoundToNearestLevels(frac, 1, PowerCellComponent.PowerCellVisualsLevels);
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case 2:
|
||||
ToggleLight(uid, component.GreenColor);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ToggleLight(uid, component.YellowColor);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
ToggleLight(uid, string.Empty, false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Content.Server._White.Lighting.PointLight.RealBattery;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class PointLightRealBatteryComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables]
|
||||
public string RedColor = "#D56C6C";
|
||||
|
||||
[DataField, ViewVariables]
|
||||
public string GreenColor = "#7FC080";
|
||||
|
||||
[DataField, ViewVariables]
|
||||
public string YellowColor = "#BDC07F";
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user