From ebb612446a9b8abaf35603b29cbb507175493d93 Mon Sep 17 00:00:00 2001 From: Zoldorf Date: Sun, 2 Apr 2023 13:46:46 -0600 Subject: [PATCH] Changes the SingularitySystem to use generic visualizers (#15057) --- .../Singularity/Systems/SingularitySystem.cs | 28 --------- .../Components/SingularityComponent.cs | 16 ----- .../EntitySystems/SharedSingularitySystem.cs | 4 +- ...ityVisuals.cs => SingularityVisualKeys.cs} | 4 +- .../Generation/Singularity/singularity.yml | 58 ++++++++++++++----- 5 files changed, 49 insertions(+), 61 deletions(-) rename Content.Shared/Singularity/{SingularityVisuals.cs => SingularityVisualKeys.cs} (67%) diff --git a/Content.Client/Singularity/Systems/SingularitySystem.cs b/Content.Client/Singularity/Systems/SingularitySystem.cs index afc9c5bb22..3ff0f7c11a 100644 --- a/Content.Client/Singularity/Systems/SingularitySystem.cs +++ b/Content.Client/Singularity/Systems/SingularitySystem.cs @@ -20,7 +20,6 @@ public sealed class SingularitySystem : SharedSingularitySystem base.Initialize(); SubscribeLocalEvent(HandleSingularityState); - SubscribeLocalEvent(OnAppearanceChange); } /// @@ -36,31 +35,4 @@ public sealed class SingularitySystem : SharedSingularitySystem SetLevel(uid, state.Level, comp); } - - /// - /// Handles ensuring that the singularity has a sprite to see. - /// - protected override void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args) - { - base.OnSingularityStartup(uid, comp, args); - if (TryComp(uid, out var sprite)) - { - sprite.LayerMapReserveBlank(comp.Layer); - } - } - - /// - /// Handles updating the visible state of the singularity to reflect its current level. - /// - private void OnAppearanceChange(EntityUid uid, SingularityComponent comp, ref AppearanceChangeEvent args) - { - if (args.Sprite == null) - return; - - if(!_appearanceSystem.TryGetData(uid, SingularityVisuals.Level, out var level, args.Component)) - return; - - args.Sprite.LayerSetSprite(comp.Layer, - new SpriteSpecifier.Rsi(new ResourcePath($"{comp.BaseSprite.RsiPath}_{level}.rsi"), $"{comp.BaseSprite.RsiState}_{level}")); - } } diff --git a/Content.Shared/Singularity/Components/SingularityComponent.cs b/Content.Shared/Singularity/Components/SingularityComponent.cs index 8753a88609..fbe1c69b96 100644 --- a/Content.Shared/Singularity/Components/SingularityComponent.cs +++ b/Content.Shared/Singularity/Components/SingularityComponent.cs @@ -82,22 +82,6 @@ public sealed class SingularityComponent : Component #endregion Audio - #region Appearance - - /// - /// The sprite layer the singularity appearance is attached to. - /// - [DataField("layer")] - public int Layer { get; } = 0; - - /// - /// The base sprite file and state of the singularity. - /// - [DataField("baseSprite")] - public SpriteSpecifier.Rsi BaseSprite = new SpriteSpecifier.Rsi(new ResourcePath("Structures/Power/Generation/Singularity/singularity"), "singularity"); - - #endregion Appearance - #region Update Timing /// diff --git a/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs b/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs index 2b200fe10a..c720330ee7 100644 --- a/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs +++ b/Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs @@ -126,7 +126,7 @@ public abstract class SharedSingularitySystem : EntitySystem RaiseLocalEvent(uid, new SingularityLevelChangedEvent(singularity.Level, oldValue, singularity)); if (singularity.Level <= 0) - EntityManager.DeleteEntity(singularity.Owner); + QueueDel(uid); } /// @@ -366,7 +366,7 @@ public abstract class SharedSingularitySystem : EntitySystem /// The event arguments. private void UpdateAppearance(EntityUid uid, AppearanceComponent comp, SingularityLevelChangedEvent args) { - _visualizer.SetData(uid, SingularityVisuals.Level, args.NewValue, comp); + _visualizer.SetData(uid, SingularityAppearanceKeys.Singularity, args.NewValue, comp); } /// diff --git a/Content.Shared/Singularity/SingularityVisuals.cs b/Content.Shared/Singularity/SingularityVisualKeys.cs similarity index 67% rename from Content.Shared/Singularity/SingularityVisuals.cs rename to Content.Shared/Singularity/SingularityVisualKeys.cs index f21bf113b6..d9c9d631b7 100644 --- a/Content.Shared/Singularity/SingularityVisuals.cs +++ b/Content.Shared/Singularity/SingularityVisualKeys.cs @@ -3,8 +3,8 @@ namespace Content.Shared.Singularity { [Serializable, NetSerializable] - public enum SingularityVisuals + public enum SingularityAppearanceKeys { - Level + Singularity } } diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml index d19dbe8cf3..18e5d98b9b 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml @@ -11,13 +11,18 @@ path: /Audio/Effects/singularity.ogg - type: Physics bodyType: Dynamic + - type: EventHorizon # To make the singularity consume things. + radius: 0.5 + canBreachContainment: false + horizonFixtureId: EventHorizon + - type: GravityWell # To make the singularity attract things. - type: Fixtures fixtures: - id: EventHorizon shape: !type:PhysShapeCircle - radius: 0.5 - restitution: 0.9 + radius: 0.35 + restitution: 0.8 density: 99999 mask: - AllMask @@ -27,26 +32,53 @@ energy: 180 level: 1 radsPerLevel: 2 - - type: GravityWell # To make the singularity attract things. - - type: EventHorizon # To make the singularity consume things. - radius: 0.5 - canBreachContainment: false - horizonFixtureId: EventHorizon - type: RandomWalk # To make the singularity move around. - type: SingularityDistortion + intensity: 20 - type: RadiationSource slope: 0.2 # its emit really far away - - type: Sprite - sprite: Structures/Power/Generation/Singularity/singularity_1.rsi - state: singularity_1 - shader: unshaded - netsync: false - type: PointLight enabled: true radius: 10 - type: Appearance - type: GuideHelp - guides: [ Singularity, Power ] + guides: [ Singularity, Power ] # uhhh.. I would hoped they'd have read the manual before ever getting in viewing distance... - type: WarpPoint follow: true location: singularity + - type: Sprite + sprite: Structures/Power/Generation/Singularity/singularity_1.rsi + shader: unshaded + netsync: false + layers: + - map: [ "VisualLevel" ] + state: singularity_1 + - type: GenericVisualizer + visuals: + enum.SingularityAppearanceKeys.Singularity: + VisualLevel: + 1: + sprite: Structures/Power/Generation/Singularity/singularity_1.rsi + state: singularity_1 + scale: 1.0,1.0 + 2: + sprite: Structures/Power/Generation/Singularity/singularity_2.rsi + state: singularity_2 + scale: 1.0,1.0 + 3: + sprite: Structures/Power/Generation/Singularity/singularity_3.rsi + state: singularity_3 + scale: 1.0,1.0 + 4: + sprite: Structures/Power/Generation/Singularity/singularity_4.rsi + state: singularity_4 + scale: 1.0,1.0 + 5: + sprite: Structures/Power/Generation/Singularity/singularity_5.rsi + state: singularity_5 + scale: 1.5,1.5 + 6: + sprite: Structures/Power/Generation/Singularity/singularity_6.rsi + state: singularity_6 + scale: .9,.9 + -- 2.51.2