Fixes PDAs dissapearing when inhand (#13966)
This commit is contained in:
@@ -9,6 +9,7 @@ public sealed class PDASystem : SharedPDASystem
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PDAComponent, AppearanceChangeEvent>(OnAppearanceChange);
|
||||
}
|
||||
|
||||
@@ -17,13 +18,26 @@ public sealed class PDASystem : SharedPDASystem
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
args.Sprite.LayerSetState(PDAVisualLayers.Base, component.State);
|
||||
if (_appearance.TryGetData<bool>(uid, UnpoweredFlashlightVisuals.LightOn, out var isFlashlightOn, args.Component))
|
||||
args.Sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
|
||||
|
||||
if (_appearance.TryGetData<bool>(uid, PDAVisuals.IDCardInserted, out var isCardInserted, args.Component))
|
||||
args.Sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
|
||||
}
|
||||
|
||||
protected override void OnComponentInit(EntityUid uid, PDAComponent component, ComponentInit args)
|
||||
{
|
||||
base.OnComponentInit(uid, component, args);
|
||||
|
||||
if(!TryComp<SpriteComponent>(uid, out var sprite))
|
||||
return;
|
||||
|
||||
if (component.State != null)
|
||||
sprite.LayerSetState(PDAVisualLayers.Base, component.State);
|
||||
|
||||
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, component.FlashlightOn);
|
||||
sprite.LayerSetVisible(PDAVisualLayers.IDLight, component.IdSlot.StartingItem != null);
|
||||
}
|
||||
}
|
||||
|
||||
enum PDAVisualLayers : byte
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.PDA
|
||||
{
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class PDAComponent : Component
|
||||
{
|
||||
public const string PDAIdSlotId = "PDA-id";
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
- type: Appearance
|
||||
- type: Sprite
|
||||
sprite: Objects/Devices/pda.rsi
|
||||
netsync: false
|
||||
layers:
|
||||
- map: [ "enum.PDAVisualLayers.Base" ]
|
||||
- map: [ "enum.PDAVisualLayers.Flashlight" ]
|
||||
- state: "light_overlay"
|
||||
map: [ "enum.PDAVisualLayers.Flashlight" ]
|
||||
shader: "unshaded"
|
||||
visible: false
|
||||
- state: "id_overlay"
|
||||
@@ -417,7 +419,6 @@
|
||||
state: pda-ce
|
||||
- type: PDABorderColor
|
||||
borderColor: "#949137"
|
||||
state: pda-ce
|
||||
accentHColor: "#447987"
|
||||
- type: Icon
|
||||
state: pda-ce
|
||||
@@ -623,7 +624,6 @@
|
||||
state: pda-ert
|
||||
- type: PDABorderColor
|
||||
borderColor: "#A32D26"
|
||||
state: pda-ert
|
||||
accentHColor: "#447987"
|
||||
- type: Icon
|
||||
state: pda-ert
|
||||
|
||||
Reference in New Issue
Block a user