]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Changes the SingularitySystem to use generic visualizers (#15057)
authorZoldorf <silvertorch5@gmail.com>
Sun, 2 Apr 2023 19:46:46 +0000 (13:46 -0600)
committerGitHub <noreply@github.com>
Sun, 2 Apr 2023 19:46:46 +0000 (05:46 +1000)
Content.Client/Singularity/Systems/SingularitySystem.cs
Content.Shared/Singularity/Components/SingularityComponent.cs
Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs
Content.Shared/Singularity/SingularityVisualKeys.cs [moved from Content.Shared/Singularity/SingularityVisuals.cs with 67% similarity]
Resources/Prototypes/Entities/Structures/Power/Generation/Singularity/singularity.yml

index afc9c5bb22b40b58a38197692294b1af065f535f..3ff0f7c11a4fe80d6a2c67a5d67b4cd4c457bdef 100644 (file)
@@ -20,7 +20,6 @@ public sealed class SingularitySystem : SharedSingularitySystem
         base.Initialize();
 
         SubscribeLocalEvent<SingularityComponent, ComponentHandleState>(HandleSingularityState);
-        SubscribeLocalEvent<SingularityComponent, AppearanceChangeEvent>(OnAppearanceChange);
     }
 
     /// <summary>
@@ -36,31 +35,4 @@ public sealed class SingularitySystem : SharedSingularitySystem
 
         SetLevel(uid, state.Level, comp);
     }
-
-    /// <summary>
-    /// Handles ensuring that the singularity has a sprite to see.
-    /// </summary>
-    protected override void OnSingularityStartup(EntityUid uid, SingularityComponent comp, ComponentStartup args)
-    {
-        base.OnSingularityStartup(uid, comp, args);
-        if (TryComp<SpriteComponent>(uid, out var sprite))
-        {
-            sprite.LayerMapReserveBlank(comp.Layer);
-        }
-    }
-
-    /// <summary>
-    /// Handles updating the visible state of the singularity to reflect its current level.
-    /// </summary>
-    private void OnAppearanceChange(EntityUid uid, SingularityComponent comp, ref AppearanceChangeEvent args)
-    {
-        if (args.Sprite == null)
-            return;
-
-        if(!_appearanceSystem.TryGetData<byte>(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}"));
-    }
 }
index 8753a886095ff16b4776d263d19f2e017d595fe8..fbe1c69b967293f886cdfb73b12bcac55b03b4e1 100644 (file)
@@ -82,22 +82,6 @@ public sealed class SingularityComponent : Component
 
     #endregion Audio
 
-    #region Appearance
-
-    /// <summary>
-    /// The sprite layer the singularity appearance is attached to.
-    /// </summary>
-    [DataField("layer")]
-    public int Layer { get; } = 0;
-
-    /// <summary>
-    /// The base sprite file and state of the singularity.
-    /// </summary>
-    [DataField("baseSprite")]
-    public SpriteSpecifier.Rsi BaseSprite = new SpriteSpecifier.Rsi(new ResourcePath("Structures/Power/Generation/Singularity/singularity"), "singularity");
-
-    #endregion Appearance
-
     #region Update Timing
 
     /// <summary>
index 2b200fe10a552775d421ce033f1512725b0bf8f5..c720330ee7274c7cbf65348565a63423402f62f1 100644 (file)
@@ -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);
     }
 
     /// <summary>
@@ -366,7 +366,7 @@ public abstract class SharedSingularitySystem : EntitySystem
     /// <param name="args">The event arguments.</param>
     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);
     }
 
     /// <summary>
similarity index 67%
rename from Content.Shared/Singularity/SingularityVisuals.cs
rename to Content.Shared/Singularity/SingularityVisualKeys.cs
index f21bf113b6583757f1ee22e82a3b3e66389cd0ab..d9c9d631b77f6ff664770c398d1e7f169ecd64ef 100644 (file)
@@ -3,8 +3,8 @@
 namespace Content.Shared.Singularity
 {
     [Serializable, NetSerializable]
-    public enum SingularityVisuals
+    public enum SingularityAppearanceKeys
     {
-        Level
+        Singularity
     }
 }
index d19dbe8cf3baa148158f2b98211d40e0b9a5df52..18e5d98b9b0746c975433586ecda955ce4afb3a2 100644 (file)
       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
     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
+