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