* 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
140 lines
5.8 KiB
C#
140 lines
5.8 KiB
C#
using Content.Client.Wires.Visualizers;
|
|
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Doors.Systems;
|
|
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Doors;
|
|
|
|
public sealed class AirlockSystem : SharedAirlockSystem
|
|
{
|
|
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<AirlockComponent, ComponentStartup>(OnComponentStartup);
|
|
SubscribeLocalEvent<AirlockComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
|
}
|
|
|
|
private void OnComponentStartup(EntityUid uid, AirlockComponent comp, ComponentStartup args)
|
|
{
|
|
// Has to be on component startup because we don't know what order components initialize in and running this before DoorComponent inits _will_ crash.
|
|
if (!TryComp<DoorComponent>(uid, out var door))
|
|
return;
|
|
|
|
if (comp.OpenUnlitVisible) // Otherwise there are flashes of the fallback sprite between clicking on the door and the door closing animation starting.
|
|
{
|
|
door.OpenSpriteStates.Add((DoorVisualLayers.BaseUnlit, comp.OpenSpriteState));
|
|
door.OpenSpriteStates.Add((DoorVisualLayers.BaseBolted, comp.OpenBoltedSpriteState));
|
|
door.OpenSpriteStates.Add((DoorVisualLayers.BaseEmergencyAccess, comp.OpenEmergencySpriteState));
|
|
door.ClosedSpriteStates.Add((DoorVisualLayers.BaseUnlit, comp.ClosedSpriteState));
|
|
door.ClosedSpriteStates.Add((DoorVisualLayers.BaseBolted, comp.ClosedBoltedSpriteState));
|
|
door.ClosedSpriteStates.Add((DoorVisualLayers.BaseEmergencyAccess, comp.ClosedEmergencySpriteState));
|
|
}
|
|
|
|
((Animation) door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.BaseUnlit,
|
|
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningSpriteState, 0f) },
|
|
}
|
|
);
|
|
|
|
((Animation) door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.BaseUnlit,
|
|
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingSpriteState, 0f) },
|
|
}
|
|
);
|
|
|
|
door.DenyingAnimation = new Animation
|
|
{
|
|
Length = TimeSpan.FromSeconds(comp.DenyAnimationTime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = DoorVisualLayers.BaseUnlit,
|
|
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.DenySpriteState, 0f) },
|
|
}
|
|
}
|
|
};
|
|
|
|
if (!comp.AnimatePanel)
|
|
return;
|
|
|
|
((Animation) door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = WiresVisualLayers.MaintenancePanel,
|
|
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningPanelSpriteState, 0f) },
|
|
});
|
|
|
|
((Animation) door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = WiresVisualLayers.MaintenancePanel,
|
|
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingPanelSpriteState, 0f) },
|
|
});
|
|
}
|
|
|
|
private void OnAppearanceChange(EntityUid uid, AirlockComponent comp, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null)
|
|
return;
|
|
|
|
var boltedVisible = false;
|
|
var emergencyLightsVisible = false;
|
|
var unlitVisible = false;
|
|
|
|
if (!_appearanceSystem.TryGetData<DoorState>(uid, DoorVisuals.State, out var state, args.Component))
|
|
state = DoorState.Closed;
|
|
|
|
if (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.Powered, out var powered, args.Component) && powered)
|
|
{
|
|
boltedVisible =
|
|
_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.BoltLights, out var lights, args.Component)
|
|
&& lights && state is DoorState.Closed or DoorState.Welded or DoorState.Open;
|
|
|
|
emergencyLightsVisible =
|
|
_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.EmergencyLights, out var eaLights,
|
|
args.Component) && eaLights;
|
|
|
|
unlitVisible =
|
|
(state == DoorState.Closing
|
|
|| state == DoorState.Opening
|
|
|| state == DoorState.Denying
|
|
|| state == DoorState.Welded
|
|
|| state == DoorState.Open && comp.OpenUnlitVisible
|
|
|| state == DoorState.Closed && comp.OpenUnlitVisible
|
|
|| _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights,
|
|
args.Component) && closedLights)
|
|
&& !boltedVisible && !emergencyLightsVisible;
|
|
}
|
|
|
|
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible);
|
|
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseBolted, boltedVisible);
|
|
|
|
if (comp.EmergencyAccessLayer)
|
|
{
|
|
args.Sprite.LayerSetVisible(
|
|
DoorVisualLayers.BaseEmergencyAccess,
|
|
emergencyLightsVisible
|
|
&& state != DoorState.Opening
|
|
&& state != DoorState.Closing
|
|
&& !boltedVisible
|
|
);
|
|
}
|
|
|
|
switch (state)
|
|
{
|
|
case DoorState.Open:
|
|
args.Sprite.LayerSetState(DoorVisualLayers.BaseUnlit, comp.ClosingSpriteState);
|
|
args.Sprite.LayerSetAnimationTime(DoorVisualLayers.BaseUnlit, 0);
|
|
break;
|
|
case DoorState.Closed:
|
|
args.Sprite.LayerSetState(DoorVisualLayers.BaseUnlit, comp.OpeningSpriteState);
|
|
args.Sprite.LayerSetAnimationTime(DoorVisualLayers.BaseUnlit, 0);
|
|
break;
|
|
}
|
|
}
|
|
}
|