Automatic holiday sprites (#22929)

This commit is contained in:
Nemanja
2023-12-25 01:52:43 -05:00
committed by GitHub
parent 2d213b8ab0
commit 00813171c1
25 changed files with 237 additions and 9 deletions

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -18,6 +18,7 @@ namespace Content.Server.Entry
"PdaBorderColor",
"InventorySlots",
"LightFade",
"HolidayRsiSwap",
};
}
}

View 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>

View File

@@ -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();
}

View File

@@ -0,0 +1,9 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Holiday;
[Serializable, NetSerializable]
public enum HolidayVisuals : byte
{
Holiday
}

View 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
@@ -90,7 +104,21 @@
- 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

View File

@@ -62,12 +62,24 @@
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
@@ -93,12 +105,28 @@
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

View File

@@ -11,7 +11,6 @@
- state: icon
map: ["base"]
- type: Item
sprite: Objects/Weapons/Bombs/c4.rsi
size: Small
- type: OnUseTimerTrigger
delay: 10
@@ -54,6 +53,13 @@
- !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:

View 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:

View 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

View 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
@@ -10,6 +10,15 @@
{
"name": "nuclearbomb_deployed"
},
{
"name": "nukefestive",
"delays": [
[
0.25,
0.25
]
]
},
{
"name": "nuclearbomb_timing",
"delays": [

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

View 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
@@ -11,6 +11,12 @@
"name": "lamp",
"directions": 4
},
{
"name": "christmaslamp"
},
{
"name": "christmaslamp-on"
},
{
"name": "lamp-on",
"directions": 4

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

View File

@@ -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
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

View 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"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View 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,