]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Automatic holiday sprites (#22929)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Mon, 25 Dec 2023 06:52:43 +0000 (01:52 -0500)
committerGitHub <noreply@github.com>
Mon, 25 Dec 2023 06:52:43 +0000 (23:52 -0700)
25 files changed:
Content.Client/Holiday/HolidayRsiSwapComponent.cs [new file with mode: 0644]
Content.Client/Holiday/HolidaySystem.cs [new file with mode: 0644]
Content.Server/Entry/IgnoredComponents.cs
Content.Server/Holiday/HolidaySystem.cs
Content.Server/Holiday/HolidayVisualsComponent.cs [new file with mode: 0644]
Content.Shared/Holiday/HolidayVisuals.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Objects/Devices/nuke.yml
Resources/Prototypes/Entities/Objects/Misc/fluff_lights.yml
Resources/Prototypes/Entities/Objects/Weapons/Bombs/plastic.yml
Resources/Prototypes/Entities/Objects/Weapons/Throwable/throwing_stars.yml
Resources/Prototypes/Entities/Structures/Decoration/fireplace.yml
Resources/Textures/Objects/Devices/nuke.rsi/meta.json
Resources/Textures/Objects/Devices/nuke.rsi/nukefestive.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp-on.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp.png [new file with mode: 0644]
Resources/Textures/Objects/Misc/Lights/lamp.rsi/meta.json
Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-left.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-right.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/meta.json [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/primed.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Throwable/throwing_star.rsi/festive.png [new file with mode: 0644]
Resources/Textures/Objects/Weapons/Throwable/throwing_star.rsi/meta.json
Resources/Textures/Structures/Decoration/fireplace.rsi/fireplacefestive.png [new file with mode: 0644]
Resources/Textures/Structures/Decoration/fireplace.rsi/meta.json

diff --git a/Content.Client/Holiday/HolidayRsiSwapComponent.cs b/Content.Client/Holiday/HolidayRsiSwapComponent.cs
new file mode 100644 (file)
index 0000000..d84018d
--- /dev/null
@@ -0,0 +1,14 @@
+namespace Content.Client.Holiday;
+
+/// <summary>
+/// This is used for a component that swaps an entity's RSI based on HolidayVisuals
+/// </summary>
+[RegisterComponent]
+public sealed partial class HolidayRsiSwapComponent : Component
+{
+    /// <summary>
+    /// A dictionary of arbitrary visual keys to an rsi to swap the sprite to.
+    /// </summary>
+    [DataField]
+    public Dictionary<string, string> Sprite = new();
+}
diff --git a/Content.Client/Holiday/HolidaySystem.cs b/Content.Client/Holiday/HolidaySystem.cs
new file mode 100644 (file)
index 0000000..07ae98f
--- /dev/null
@@ -0,0 +1,34 @@
+using Content.Shared.Holiday;
+using Content.Shared.Item;
+using Robust.Client.GameObjects;
+using Robust.Client.Graphics;
+using Robust.Client.ResourceManagement;
+using Robust.Shared.Serialization.TypeSerializers.Implementations;
+
+namespace Content.Client.Holiday;
+
+public sealed class HolidaySystem : EntitySystem
+{
+    [Dependency] private readonly IResourceCache _rescache = default!;
+    [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+
+    /// <inheritdoc/>
+    public override void Initialize()
+    {
+        SubscribeLocalEvent<HolidayRsiSwapComponent, AppearanceChangeEvent>(OnAppearanceChange);
+    }
+
+    private void OnAppearanceChange(Entity<HolidayRsiSwapComponent> ent, ref AppearanceChangeEvent args)
+    {
+        if (!_appearance.TryGetData<string>(ent, HolidayVisuals.Holiday, out var data, args.Component))
+            return;
+
+        var comp = ent.Comp;
+        if (!comp.Sprite.TryGetValue(data, out var rsistring) || args.Sprite == null)
+            return;
+
+        var path = SpriteSpecifierSerializer.TextureRoot / rsistring;
+        if (_rescache.TryGetResource(path, out RSIResource? rsi))
+            args.Sprite.BaseRSI = rsi.RSI;
+    }
+}
index e1d744da2da1d4a2b0a342745dc37c9e91e16216..c1b646ec4f968bbef7dea2cd05363e2c32a080be 100644 (file)
@@ -18,6 +18,7 @@ namespace Content.Server.Entry
             "PdaBorderColor",
             "InventorySlots",
             "LightFade",
+            "HolidayRsiSwap",
         };
     }
 }
index 86cd3001019a2603097ab9a514cd673a4d77d593..4224b01491a5f03c404064e55e1bfe6ce7bbb846 100644 (file)
@@ -2,6 +2,7 @@ using System.Linq;
 using Content.Server.Chat.Managers;
 using Content.Server.GameTicking;
 using Content.Shared.CCVar;
+using Content.Shared.Holiday;
 using Robust.Shared.Configuration;
 using Robust.Shared.Prototypes;
 
@@ -12,6 +13,7 @@ namespace Content.Server.Holiday
         [Dependency] private readonly IConfigurationManager _configManager = default!;
         [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
         [Dependency] private readonly IChatManager _chatManager = default!;
+        [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
 
         [ViewVariables]
         private readonly List<HolidayPrototype> _currentHolidays = new();
@@ -24,6 +26,7 @@ namespace Content.Server.Holiday
             _configManager.OnValueChanged(CCVars.HolidaysEnabled, OnHolidaysEnableChange, true);
 
             SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRunLevelChanged);
+            SubscribeLocalEvent<HolidayVisualsComponent, ComponentInit>(OnVisualsInit);
         }
 
         public void RefreshCurrentHolidays()
@@ -102,6 +105,17 @@ namespace Content.Server.Holiday
                     break;
             }
         }
+
+        private void OnVisualsInit(Entity<HolidayVisualsComponent> ent, ref ComponentInit args)
+        {
+            foreach (var (key, holidays) in ent.Comp.Holidays)
+            {
+                if (!holidays.Any(h => IsCurrentlyHoliday(h)))
+                    continue;
+                _appearance.SetData(ent, HolidayVisuals.Holiday, key);
+                break;
+            }
+        }
     }
 
     /// <summary>
diff --git a/Content.Server/Holiday/HolidayVisualsComponent.cs b/Content.Server/Holiday/HolidayVisualsComponent.cs
new file mode 100644 (file)
index 0000000..9603226
--- /dev/null
@@ -0,0 +1,17 @@
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.Holiday;
+
+/// <summary>
+/// This is used for an entity that enables unique visuals on specified holidays.
+/// </summary>
+[RegisterComponent]
+public sealed partial class HolidayVisualsComponent : Component
+{
+    /// <summary>
+    /// A dictionary relating a generic key to a list of holidays.
+    /// If any of the holidays are being celebrated, that key will be set for holiday visuals.
+    /// </summary>
+    [DataField]
+    public Dictionary<string, List<ProtoId<HolidayPrototype>>> Holidays = new();
+}
diff --git a/Content.Shared/Holiday/HolidayVisuals.cs b/Content.Shared/Holiday/HolidayVisuals.cs
new file mode 100644 (file)
index 0000000..4af1efa
--- /dev/null
@@ -0,0 +1,9 @@
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Holiday;
+
+[Serializable, NetSerializable]
+public enum HolidayVisuals : byte
+{
+    Holiday
+}
index 63e28648c3dae7d067af7a2d109a6dad2cda8778..b61787b574b32ee130dfbd2e3760026d869ca37d 100644 (file)
@@ -9,7 +9,21 @@
   - type: Sprite
     sprite: Objects/Devices/nuke.rsi
     noRot: true
-    state: nuclearbomb_base
+    layers:
+    - state: nuclearbomb_base
+    - state: nukefestive
+      map: ["christmas"]
+      visible: false
+  - type: Appearance
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        christmas:
+          festive: { visible: true }
   - type: Physics
     bodyType: Static
   - type: Fixtures
   - type: NukeLabel
   - type: Sprite
     sprite: Objects/Devices/nuke.rsi
-    state: nuclearbomb_base
+    layers:
+    - state: nuclearbomb_base
+    - state: nukefestive
+      map: ["christmas"]
+      visible: false
+  - type: Appearance
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        christmas:
+          festive: { visible: true }
   - type: Physics
     bodyType: Dynamic
   - type: Fixtures
index 83701249d0ceca7af2eb1811722e42c62d7ebe48..ec9a94de864e15626b3957f76a03a6415cb7b88c 100644 (file)
     sprite: Objects/Misc/Lights/lamp.rsi
     layers:
       - state: lamp
+        map: [ "base" ]
       - state: lamp-on
         shader: unshaded
         visible: false
         map: [ "light" ]
   - type: Item
     sprite: Objects/Misc/Lights/lamp.rsi
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        base:
+          festive: { state: christmaslamp }
+        light:
+          festive: { state: christmaslamp-on }
 
 - type: entity
   name: banana lamp
     sprite: Objects/Misc/Lights/lampgreen.rsi
     layers:
       - state: lampgreen
+        map: [ "base" ]
       - state: lampgreen-on
         shader: unshaded
         visible: false
         map: [ "light" ]
   - type: Item
     sprite: Objects/Misc/Lights/lampgreen.rsi
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        base:
+          festive:
+            sprite: Objects/Misc/Lights/lamp.rsi
+            state: christmaslamp
+        light:
+          festive:
+            sprite: Objects/Misc/Lights/lamp.rsi
+            state: christmaslamp-on
 
 - type: entity
   name: interrogator lamp
index e3581370f03d7f6b1d4e5baa347a2db38277828b..ac675f6cd281226e75c3099187df11cc47a895b7 100644 (file)
@@ -11,7 +11,6 @@
     - state: icon
       map: ["base"]
   - type: Item
-    sprite: Objects/Weapons/Bombs/c4.rsi
     size: Small
   - type: OnUseTimerTrigger
     delay: 10
           - !type:ExplodeBehavior
   - type: StickyVisualizer
   - type: Appearance
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: HolidayRsiSwap
+    sprite:
+      festive: Objects/Weapons/Bombs/c4gift.rsi
   - type: GenericVisualizer
     visuals:
       enum.Trigger.TriggerVisuals.VisualState:
index b0fa94d4404070dd34ef91cab67b89bf70e3a589..48138452b238ae52222f6fc7c46aedae4c8c699a 100644 (file)
@@ -6,7 +6,19 @@
   components:
   - type: Sprite
     sprite: Objects/Weapons/Throwable/throwing_star.rsi
-    state: icon
+    layers:
+    - state: icon
+      map: ["base"]
+  - type: Appearance
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        base:
+          festive: { state: festive }
   - type: Fixtures
     fixtures:
       fix1:
index 03851318e1f4a62d91655cec413841a6caf615eb..f5bbafa40c69d8e6ae5923ee93cbaabfc9fae577 100644 (file)
@@ -8,10 +8,23 @@
     sprite: Structures/Decoration/fireplace.rsi
     layers:
       - state: fireplace
+      - state: fireplacefestive
+        map: ["christmas"]
+        visible: false
       - state: fireplace_fire4
         shader: unshaded
       - state: fireplace_glow
         shader: unshaded
+  - type: Appearance
+  - type: HolidayVisuals
+    holidays:
+      festive:
+      - FestiveSeason
+  - type: GenericVisualizer
+    visuals:
+      enum.HolidayVisuals.Holiday:
+        christmas:
+          festive: { visible: true }
   - type: AmbientSound
     volume: -6
     range: 5
index 6e44a5417fc6d0717bca62af7069e63b478888d5..2828b13ddba8033e50d3501fdc290fc7c68fe1bd 100644 (file)
@@ -1,7 +1,7 @@
 {
   "version": 1,
   "license": "CC-BY-SA-3.0",
-  "copyright": "Taken from https://github.com/vgstation-coders/vgstation13/blob/835fd60545178a19064f5df9981dac6e1b220775/icons/obj/stationobjs.dmi",
+  "copyright": "Taken from https://github.com/vgstation-coders/vgstation13/blob/835fd60545178a19064f5df9981dac6e1b220775/icons/obj/stationobjs.dmi, nukefestive by Alekshhh (Github)",
   "size": {
     "x": 32,
     "y": 32
     {
       "name": "nuclearbomb_deployed"
     },
+    {
+      "name": "nukefestive",
+      "delays": [
+        [
+          0.25,
+          0.25
+        ]
+      ]
+    },
     {
       "name": "nuclearbomb_timing",
       "delays": [
diff --git a/Resources/Textures/Objects/Devices/nuke.rsi/nukefestive.png b/Resources/Textures/Objects/Devices/nuke.rsi/nukefestive.png
new file mode 100644 (file)
index 0000000..f9c58ac
Binary files /dev/null and b/Resources/Textures/Objects/Devices/nuke.rsi/nukefestive.png differ
diff --git a/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp-on.png b/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp-on.png
new file mode 100644 (file)
index 0000000..df2434f
Binary files /dev/null and b/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp-on.png differ
diff --git a/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp.png b/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp.png
new file mode 100644 (file)
index 0000000..c461a42
Binary files /dev/null and b/Resources/Textures/Objects/Misc/Lights/lamp.rsi/christmaslamp.png differ
index 1cfaa8f91d1cd7b083354fee178a32f78044e583..c18be3fd62ba0a86f1477d209994553405223cb9 100644 (file)
@@ -1,7 +1,7 @@
 {
   "version": 1,
   "license": "CC-BY-SA-3.0",
-  "copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/e1142f20f5e4661cb6845cfcf2dd69f864d67432",
+  "copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/commit/e1142f20f5e4661cb6845cfcf2dd69f864d67432, christmaslamp by Alekshhh (Github)",
   "size": {
     "x": 32,
     "y": 32
         "name": "lamp",
         "directions": 4
     },
+    {
+      "name": "christmaslamp"
+    },
+    {
+      "name": "christmaslamp-on"
+    },
     {
         "name": "lamp-on",
         "directions": 4
diff --git a/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/icon.png b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/icon.png
new file mode 100644 (file)
index 0000000..915d1c0
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/icon.png differ
diff --git a/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-left.png b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-left.png
new file mode 100644 (file)
index 0000000..cb782d5
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-left.png differ
diff --git a/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-right.png b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-right.png
new file mode 100644 (file)
index 0000000..6ceb49c
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/inhand-right.png differ
diff --git a/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/meta.json b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/meta.json
new file mode 100644 (file)
index 0000000..a24d3ba
--- /dev/null
@@ -0,0 +1,31 @@
+{
+    "version": 1,
+       "license": "CC-BY-SA-3.0",
+       "copyright": "Created by Alekshhh (Github) for SS14",
+    "size": {
+        "x": 32,
+        "y": 32
+    },
+    "states": [
+        {
+            "name": "icon"
+        },
+        {
+            "name": "primed",
+            "delays": [
+                [
+                    0.1,
+                    0.1
+                ]
+            ]
+        },
+        {
+            "name": "inhand-left",
+            "directions": 4
+               },
+        {
+            "name": "inhand-right",
+            "directions": 4
+               }
+    ]
+}
diff --git a/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/primed.png b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/primed.png
new file mode 100644 (file)
index 0000000..84c96e0
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Bombs/c4gift.rsi/primed.png differ
diff --git a/Resources/Textures/Objects/Weapons/Throwable/throwing_star.rsi/festive.png b/Resources/Textures/Objects/Weapons/Throwable/throwing_star.rsi/festive.png
new file mode 100644 (file)
index 0000000..cd62feb
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Throwable/throwing_star.rsi/festive.png differ
index 44d65d9d5e22b98031cebfbc5df92dd81b03a60e..c7167105328929ac52681852a30dbb7e1abdf508 100644 (file)
@@ -1,7 +1,7 @@
 {
   "version": 1,
   "license": "CC0-1.0",
-  "copyright": "Created for SS14 by deltanedas (github)",
+  "copyright": "Created for SS14 by deltanedas (github), festive by Alekshhh (Github)",
   "size": {
     "x": 32,
     "y": 32
@@ -9,6 +9,9 @@
   "states": [
     {
       "name": "icon"
+    },
+    {
+      "name": "festive"
     }
   ]
 }
diff --git a/Resources/Textures/Structures/Decoration/fireplace.rsi/fireplacefestive.png b/Resources/Textures/Structures/Decoration/fireplace.rsi/fireplacefestive.png
new file mode 100644 (file)
index 0000000..bea2ae8
Binary files /dev/null and b/Resources/Textures/Structures/Decoration/fireplace.rsi/fireplacefestive.png differ
index e5fffc1852a76f404ac60d38ce2bccc24b4829fa..276eabd6244865059de9dda9361a992bd31a10b7 100644 (file)
@@ -1,7 +1,7 @@
 {
   "version": 1,
   "license": "CC-BY-SA-3.0",
-  "copyright": "https://github.com/tgstation/tgstation/commit/6449b65d307312a111deb592e7a1bb4093e085e4",
+  "copyright": "https://github.com/tgstation/tgstation/commit/6449b65d307312a111deb592e7a1bb4093e085e4, fireplacefestive by Alekshhh (Github)",
   "size": {
     "x": 64,
     "y": 64
@@ -11,6 +11,9 @@
       "name": "fireplace",
       "directions": 1
     },
+    {
+      "name": "fireplacefestive"
+    },
     {
       "name": "fireplace_fire4",
       "directions": 4,
@@ -60,4 +63,4 @@
       ]
     }
   ]
-}
\ No newline at end of file
+}