fix: фикс света дверей

This commit is contained in:
Remuchi
2024-01-27 19:09:42 +07:00
parent 62145432f0
commit 117c4cbed1
3 changed files with 35 additions and 26 deletions

View File

@@ -28,35 +28,37 @@ public sealed class AirlockSystem : SharedAirlockSystem
private void OnComponentStartup(EntityUid uid, AirlockComponent comp, ComponentStartup args) 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. // 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)) if (!TryComp<DoorComponent>(uid, out var door))
return; return;
if (comp.OpenUnlitVisible) // Otherwise there are flashes of the fallback sprite between clicking on the door and the door closing animation starting. 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.BaseUnlit, comp.OpenSpriteState));
door.OpenSpriteStates.Add((DoorVisualLayers.BaseBolted, "bolted_open_unlit"));
door.ClosedSpriteStates.Add((DoorVisualLayers.BaseUnlit, comp.ClosedSpriteState)); door.ClosedSpriteStates.Add((DoorVisualLayers.BaseUnlit, comp.ClosedSpriteState));
door.ClosedSpriteStates.Add((DoorVisualLayers.BaseBolted, "bolted_unlit"));
} }
((Animation)door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick() ((Animation) door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
{ {
LayerKey = DoorVisualLayers.BaseUnlit, LayerKey = DoorVisualLayers.BaseUnlit,
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningSpriteState, 0f) }, KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningSpriteState, 0f) },
} }
); );
((Animation)door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick() ((Animation) door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
{ {
LayerKey = DoorVisualLayers.BaseUnlit, LayerKey = DoorVisualLayers.BaseUnlit,
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingSpriteState, 0f) }, KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingSpriteState, 0f) },
} }
); );
door.DenyingAnimation = new Animation() door.DenyingAnimation = new Animation
{ {
Length = TimeSpan.FromSeconds(comp.DenyAnimationTime), Length = TimeSpan.FromSeconds(comp.DenyAnimationTime),
AnimationTracks = AnimationTracks =
{ {
new AnimationTrackSpriteFlick() new AnimationTrackSpriteFlick
{ {
LayerKey = DoorVisualLayers.BaseUnlit, LayerKey = DoorVisualLayers.BaseUnlit,
KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.DenySpriteState, 0f) }, KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.DenySpriteState, 0f) },
@@ -64,19 +66,19 @@ public sealed class AirlockSystem : SharedAirlockSystem
} }
}; };
if(!comp.AnimatePanel) if (!comp.AnimatePanel)
return; return;
((Animation)door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick() ((Animation) door.OpeningAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
{ {
LayerKey = WiresVisualLayers.MaintenancePanel, LayerKey = WiresVisualLayers.MaintenancePanel,
KeyFrames = {new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningPanelSpriteState, 0f)}, KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.OpeningPanelSpriteState, 0f) },
}); });
((Animation)door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick ((Animation) door.ClosingAnimation).AnimationTracks.Add(new AnimationTrackSpriteFlick
{ {
LayerKey = WiresVisualLayers.MaintenancePanel, LayerKey = WiresVisualLayers.MaintenancePanel,
KeyFrames = {new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingPanelSpriteState, 0f)}, KeyFrames = { new AnimationTrackSpriteFlick.KeyFrame(comp.ClosingPanelSpriteState, 0f) },
}); });
} }
@@ -94,18 +96,24 @@ public sealed class AirlockSystem : SharedAirlockSystem
if (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.Powered, out var powered, args.Component) && powered) 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) boltedVisible =
&& lights && (state == DoorState.Closed || state == DoorState.Welded); _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.BoltLights, out var lights, args.Component)
&& lights && state is DoorState.Closed or DoorState.Welded;
emergencyLightsVisible =
_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.EmergencyLights, out var eaLights,
args.Component) && eaLights;
emergencyLightsVisible = _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.EmergencyLights, out var eaLights, args.Component) && eaLights;
unlitVisible = unlitVisible =
(state == DoorState.Closing (state == DoorState.Closing
|| state == DoorState.Opening || state == DoorState.Opening
|| state == DoorState.Denying || state == DoorState.Denying
|| state == DoorState.Welded || state == DoorState.Welded
|| (state == DoorState.Open && comp.OpenUnlitVisible) || state == DoorState.Open && comp.OpenUnlitVisible
|| (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights, args.Component) && closedLights)) || state == DoorState.Closed && comp.OpenUnlitVisible
&& !boltedVisible && !emergencyLightsVisible; ; || _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights,
args.Component) && closedLights)
&& !boltedVisible && !emergencyLightsVisible;
} }
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible); args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible);
@@ -114,10 +122,10 @@ public sealed class AirlockSystem : SharedAirlockSystem
{ {
args.Sprite.LayerSetVisible( args.Sprite.LayerSetVisible(
DoorVisualLayers.BaseEmergencyAccess, DoorVisualLayers.BaseEmergencyAccess,
emergencyLightsVisible emergencyLightsVisible
&& state != DoorState.Open && state != DoorState.Open
&& state != DoorState.Opening && state != DoorState.Opening
&& state != DoorState.Closing && state != DoorState.Closing
&& !boltedVisible && !boltedVisible
); );
} }

View File

@@ -72,8 +72,8 @@ public sealed partial class AirlockComponent : Component
/// <summary> /// <summary>
/// Whether the door lights should be visible. /// Whether the door lights should be visible.
/// </summary> /// </summary>
[DataField] [DataField("openUnlitVisible")]
public bool OpenUnlitVisible = false; public bool OpenUnlitVisible = true;
/// <summary> /// <summary>
/// Whether the door should display emergency access lights. /// Whether the door should display emergency access lights.

View File

@@ -64,6 +64,7 @@
- type: Weldable - type: Weldable
time: 3 time: 3
- type: Airlock - type: Airlock
openUnlitVisible: true
- type: NavMapDoor - type: NavMapDoor
- type: DoorBolt - type: DoorBolt
- type: Appearance - type: Appearance