Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert AME Visualizers #9037

Merged
merged 4 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Content.Client/AME/AMEControllerVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Client.AME.Components;
using Robust.Client.GameObjects;
using static Content.Shared.AME.SharedAMEControllerComponent;

namespace Content.Client.AME;

public sealed class AMEControllerVisualizerSystem : VisualizerSystem<AMEControllerVisualsComponent>
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AMEControllerVisualsComponent, ComponentInit>(OnComponentInit);
}

private void OnComponentInit(EntityUid uid, AMEControllerVisualsComponent component, ComponentInit args)
{
if(TryComp<SpriteComponent>(uid, out var sprite))
{
sprite.LayerMapSet(AMEControllerVisualLayers.Display, sprite.AddLayerState("control_on"));
sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false);
}
}

protected override void OnAppearanceChange(EntityUid uid, AMEControllerVisualsComponent component, ref AppearanceChangeEvent args)
{
base.OnAppearanceChange(uid, component, ref args);

if(args.Sprite != null
&& args.Component.TryGetData<string>(AMEControllerVisuals.DisplayState, out var state))
{
switch(state)
{
case "on":
args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_on");
args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true);
break;
case "critical":
args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_critical");
args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true);
break;
case "fuck":
args.Sprite.LayerSetState(AMEControllerVisualLayers.Display, "control_fuck");
args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, true);
break;
case "off":
args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false);
break;
default:
args.Sprite.LayerSetVisible(AMEControllerVisualLayers.Display, false);
break;
}
}
}
}

public enum AMEControllerVisualLayers : byte
{
Display
}

70 changes: 70 additions & 0 deletions Content.Client/AME/AMEShieldingVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Content.Client.AME.Components;
using Robust.Client.GameObjects;
using static Content.Shared.AME.SharedAMEShieldComponent;

namespace Content.Client.AME;

public sealed class AMEShieldingVisualizerSystem : VisualizerSystem<AMEShieldingVisualsComponent>
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AMEShieldingVisualsComponent, ComponentInit>(OnComponentInit);
}

private void OnComponentInit(EntityUid uid, AMEShieldingVisualsComponent component, ComponentInit args)
{
if(TryComp<SpriteComponent>(uid, out var sprite))
{
sprite.LayerMapSet(AMEShieldingVisualsLayer.Core, sprite.AddLayerState("core"));
sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, false);
sprite.LayerMapSet(AMEShieldingVisualsLayer.CoreState, sprite.AddLayerState("core_weak"));
sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, false);
}
}

protected override void OnAppearanceChange(EntityUid uid, AMEShieldingVisualsComponent component, ref AppearanceChangeEvent args)
{
if(args.Sprite == null)
return;

if(args.Component.TryGetData<string>(AMEShieldVisuals.Core, out var core))
{
if (core == "isCore")
{
args.Sprite.LayerSetState(AMEShieldingVisualsLayer.Core, "core");
args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, true);

}
else
{
args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.Core, false);
}
}

if(args.Component.TryGetData<string>(AMEShieldVisuals.CoreState, out var coreState))
{
switch(coreState)
{
case "weak":
args.Sprite.LayerSetState(AMEShieldingVisualsLayer.CoreState, "core_weak");
args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, true);
break;
case "strong":
args.Sprite.LayerSetState(AMEShieldingVisualsLayer.CoreState, "core_strong");
args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, true);
break;
case "off":
args.Sprite.LayerSetVisible(AMEShieldingVisualsLayer.CoreState, false);
break;
}
}
}
}

public enum AMEShieldingVisualsLayer : byte
{
Core,
CoreState,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.ComponentModel.DataAnnotations;
using Robust.Shared.GameObjects;

namespace Content.Client.AME.Components;

[RegisterComponent]
public sealed class AMEControllerVisualsComponent : Component
{
}
9 changes: 9 additions & 0 deletions Content.Client/AME/Components/AMEShieldingVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.ComponentModel.DataAnnotations;
using Robust.Shared.GameObjects;

namespace Content.Client.AME.Components;

[RegisterComponent]
public sealed class AMEShieldingVisualsComponent : Component
{
}
56 changes: 0 additions & 56 deletions Content.Client/AME/Visualizers/AMEControllerVisualizer.cs

This file was deleted.

62 changes: 0 additions & 62 deletions Content.Client/AME/Visualizers/AMEVisualizer.cs

This file was deleted.

2 changes: 2 additions & 0 deletions Content.Server/Entry/IgnoredComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static class IgnoredComponents
"PaperVisuals",
"SurveillanceCameraVisuals",
"KudzuVisuals",
"AMEControllerVisuals",
"AMEShieldingVisuals",
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- type: Clickable
- type: InteractionOutline
- type: Sprite
netsync: false
sprite: Structures/Power/Generation/ame.rsi
state: control
- type: Physics
Expand Down Expand Up @@ -54,8 +55,7 @@
- key: enum.AMEControllerUiKey.Key
type: AMEControllerBoundUserInterface
- type: Appearance
visuals:
- type: AMEControllerVisualizer
- type: AMEControllerVisuals
- type: NodeContainer
examinable: true
nodes:
Expand Down Expand Up @@ -89,6 +89,7 @@
- type: Clickable
- type: InteractionOutline
- type: Sprite
netsync: false
drawdepth: Walls
sprite: Structures/Power/Generation/ame.rsi
state: shield_0
Expand Down Expand Up @@ -136,8 +137,7 @@
energy: 0.5
color: "#00AAFF"
- type: Appearance
visuals:
- type: AMEVisualizer
- type: AMEShieldingVisuals
- type: Construction
graph: AMEShielding
node: ameShielding