Мягкий свет для всякого (#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:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared._White.Lighting;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Prying.Components;
|
||||
@@ -120,6 +121,7 @@ public abstract class SharedAirlockSystem : EntitySystem
|
||||
|
||||
public void UpdateEmergencyLightStatus(EntityUid uid, AirlockComponent component)
|
||||
{
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(DoorVisuals.EmergencyLights, component.EmergencyAccess));
|
||||
Appearance.SetData(uid, DoorVisuals.EmergencyLights, component.EmergencyAccess);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared._White.Lighting;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Prying.Components;
|
||||
|
||||
@@ -55,7 +56,8 @@ public abstract partial class SharedDoorSystem
|
||||
|
||||
public void UpdateBoltLightStatus(Entity<DoorBoltComponent> ent)
|
||||
{
|
||||
AppearanceSystem.SetData(ent, DoorVisuals.BoltLights, GetBoltLightsVisible(ent));
|
||||
var value = GetBoltLightsVisible(ent);
|
||||
AppearanceSystem.SetData(ent, DoorVisuals.BoltLights, value);
|
||||
}
|
||||
|
||||
public bool GetBoltLightsVisible(Entity<DoorBoltComponent> ent)
|
||||
@@ -84,6 +86,8 @@ public abstract partial class SharedDoorSystem
|
||||
Dirty(ent, ent.Comp);
|
||||
UpdateBoltLightStatus(ent);
|
||||
|
||||
RaiseLocalEvent(ent, new DoorlightsChangedEvent(DoorVisuals.BoltLights, value), true);
|
||||
|
||||
var sound = value ? ent.Comp.BoltDownSound : ent.Comp.BoltUpSound;
|
||||
if (predicted)
|
||||
Audio.PlayPredicted(sound, ent, user: user);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Shared._White.Cult.Structures;
|
||||
using Content.Shared._White.Keyhole.Components;
|
||||
using Content.Shared._White.Lighting;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
@@ -116,6 +117,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
|| door.State == DoorState.Opening && !door.Partial;
|
||||
|
||||
SetCollidable(ent, collidable, door);
|
||||
|
||||
RaiseLocalEvent(ent, new DoorlightsChangedEvent(door.State, true), true);
|
||||
AppearanceSystem.SetData(ent, DoorVisuals.State, door.State);
|
||||
}
|
||||
|
||||
@@ -164,6 +167,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
_activeDoors.Add(ent);
|
||||
|
||||
RaiseLocalEvent(ent, new DoorStateChangedEvent(door.State));
|
||||
RaiseLocalEvent(ent, new DoorlightsChangedEvent(door.State, true), true);
|
||||
|
||||
AppearanceSystem.SetData(ent, DoorVisuals.State, door.State);
|
||||
}
|
||||
|
||||
@@ -212,7 +217,10 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
|
||||
door.State = state;
|
||||
Dirty(uid, door);
|
||||
|
||||
RaiseLocalEvent(uid, new DoorStateChangedEvent(state));
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(door.State, true), true);
|
||||
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, door.State);
|
||||
return true;
|
||||
}
|
||||
@@ -516,6 +524,8 @@ public abstract partial class SharedDoorSystem : EntitySystem
|
||||
{
|
||||
door.NextStateChange = GameTiming.CurTime + door.OpenTimeTwo;
|
||||
door.State = DoorState.Opening;
|
||||
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(door.State, true), true);
|
||||
AppearanceSystem.SetData(uid, DoorVisuals.State, DoorState.Opening);
|
||||
return false;
|
||||
}
|
||||
|
||||
13
Content.Shared/_White/Lighting/AppearanceChangedEvent.cs
Normal file
13
Content.Shared/_White/Lighting/AppearanceChangedEvent.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Content.Shared._White.Lighting;
|
||||
|
||||
public sealed class DoorlightsChangedEvent : EntityEventArgs
|
||||
{
|
||||
public Enum? State;
|
||||
public bool Value;
|
||||
|
||||
public DoorlightsChangedEvent(Enum? key, bool value)
|
||||
{
|
||||
State = key;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._White.Lighting.PointLight.Airlock;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class PointLightAirlockComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public string RedColor = "#D56C6C";
|
||||
|
||||
[ViewVariables]
|
||||
public string BlueColor = "#7F93C0";
|
||||
|
||||
[ViewVariables]
|
||||
public string YellowColor = "#BDC07F";
|
||||
|
||||
[ViewVariables]
|
||||
public string GreenColor = "#7FC080";
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using Content.Shared.Doors.Components;
|
||||
|
||||
namespace Content.Shared._White.Lighting.PointLight.Airlock;
|
||||
|
||||
//TODO: Когда-нибудь починить эту хуйню: Когда дверь открыта на аварийный доступ и ее болтируют, то свет будет желтым, хотя должен быть красным из-за болтов.
|
||||
|
||||
public sealed class SharedPointLightAirlockSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<PointLightAirlockComponent, DoorlightsChangedEvent>(OnDoorLightChanged);
|
||||
}
|
||||
|
||||
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 OnDoorLightChanged(EntityUid uid, PointLightAirlockComponent component, DoorlightsChangedEvent args)
|
||||
{
|
||||
if (!TryComp<DoorComponent>(uid, out var door))
|
||||
return;
|
||||
|
||||
if (TryComp<AirlockComponent>(uid, out var airlockComponent) && airlockComponent.EmergencyAccess && args.Value && args.State is not DoorVisuals.EmergencyLights && args.State != null)
|
||||
return; // While emergency access lights must be yellow no matter what
|
||||
|
||||
switch (args.State)
|
||||
{
|
||||
case DoorVisuals.BoltLights:
|
||||
if (args.Value)
|
||||
ToggleLight(uid, component.RedColor);
|
||||
else
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(door.State, true));
|
||||
break;
|
||||
|
||||
case DoorState.Denying:
|
||||
ToggleLight(uid, component.RedColor);
|
||||
break;
|
||||
|
||||
case DoorState.Closed:
|
||||
ToggleLight(uid, component.BlueColor);
|
||||
break;
|
||||
|
||||
case DoorVisuals.EmergencyLights:
|
||||
if (args.Value)
|
||||
ToggleLight(uid, component.YellowColor);
|
||||
else
|
||||
RaiseLocalEvent(uid, new DoorlightsChangedEvent(door.State, true));
|
||||
break;
|
||||
|
||||
case DoorState.Open:
|
||||
ToggleLight(uid, component.BlueColor);
|
||||
break;
|
||||
|
||||
case DoorState.Opening:
|
||||
ToggleLight(uid, component.GreenColor);
|
||||
break;
|
||||
|
||||
case DoorState.Closing:
|
||||
ToggleLight(uid, component.GreenColor);
|
||||
break;
|
||||
|
||||
default:
|
||||
ToggleLight(uid, "", false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._White.Lighting.PointLight.Locker;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class PointLightLockerComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables]
|
||||
public string RedColor = "#D56C6C";
|
||||
|
||||
[DataField, ViewVariables]
|
||||
public string GreenColor = "#7FC080";
|
||||
|
||||
[DataField, ViewVariables]
|
||||
public float ReduceEnergyOnOpen = 0.1f;
|
||||
|
||||
[DataField, ViewVariables]
|
||||
public float ReduceRadiusOnOpen = 0.1f;
|
||||
}
|
||||
@@ -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