From 60c529140d9bb4f267ceb66a5a248129acafbedb Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:04:48 +0000 Subject: [PATCH] mediborg candy refactor (#2639) refactor borg candy and move to shared _DV namespace Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Borgs/FabricateCandyComponent.cs | 25 ---------- .../Abilities/Borgs/FabricateCandySystem.cs | 47 ------------------ .../Actions/FabricateCandyEvent.cs | 4 -- .../Silicons/Borgs/FabricateCandyComponent.cs | 46 +++++++++++++++++ .../Silicons/Borgs/FabricateCandySystem.cs | 45 +++++++++++++++++ .../en-US/nyanotrasen/abilities/borgs.ftl | 5 -- .../Prototypes/Nyanotrasen/Actions/types.yml | 21 -------- Resources/Prototypes/_DV/Actions/borgs.yml | 22 ++++++++ .../Objects/Consumable/Food/candy.yml | 28 ++++++----- Resources/Prototypes/borg_types.yml | 5 +- .../Consumable/Food/candy.rsi/meta.json | 34 ------------- .../Food/candy.rsi/gumball-shine.png | Bin .../Consumable/Food/candy.rsi/gumball.png | Bin .../Food/candy.rsi/lollipop-ball.png | Bin .../lollipop-equipped-MASK-vulpkanin.png | Bin .../Food/candy.rsi/lollipop-equipped-MASK.png | Bin .../Food/candy.rsi/lollipop-stickandshine.png | Bin .../Consumable/Food/candy.rsi/lollipop.png | Bin .../Consumable/Food/candy.rsi/meta.json | 34 +++++++++++++ 19 files changed, 167 insertions(+), 149 deletions(-) delete mode 100644 Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandyComponent.cs delete mode 100644 Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandySystem.cs delete mode 100644 Content.Shared/Nyanotrasen/Actions/FabricateCandyEvent.cs create mode 100644 Content.Shared/_DV/Silicons/Borgs/FabricateCandyComponent.cs create mode 100644 Content.Shared/_DV/Silicons/Borgs/FabricateCandySystem.cs delete mode 100644 Resources/Locale/en-US/nyanotrasen/abilities/borgs.ftl create mode 100644 Resources/Prototypes/_DV/Actions/borgs.yml rename Resources/Prototypes/{Nyanotrasen => _DV}/Entities/Objects/Consumable/Food/candy.yml (73%) delete mode 100644 Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/meta.json rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/gumball-shine.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/gumball.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/lollipop-ball.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK-vulpkanin.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/lollipop-stickandshine.png (100%) rename Resources/Textures/{Nyanotrasen => _DV}/Objects/Consumable/Food/candy.rsi/lollipop.png (100%) create mode 100644 Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/meta.json diff --git a/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandyComponent.cs b/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandyComponent.cs deleted file mode 100644 index 36546359829..00000000000 --- a/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandyComponent.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Robust.Shared.Audio; - -namespace Content.Server.Abilities.Borgs; - -[RegisterComponent] -public sealed partial class FabricateCandyComponent : Component -{ - [DataField] - public EntityUid? LollipopAction; - - [DataField] - public EntityUid? GumballAction; - - /// - /// The sound played when fabricating candy. - /// - [DataField] - public SoundSpecifier FabricationSound = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg") - { - Params = new AudioParams - { - Volume = -2f - } - }; -} diff --git a/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandySystem.cs b/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandySystem.cs deleted file mode 100644 index b9c7540d750..00000000000 --- a/Content.Server/Nyanotrasen/Abilities/Borgs/FabricateCandySystem.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Robust.Server.Audio; -using Robust.Shared.Prototypes; -using Content.Shared.Actions; -using Content.Shared.Actions.Events; - -namespace Content.Server.Abilities.Borgs; - -public sealed partial class FabricateCandySystem : EntitySystem -{ - [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; - [Dependency] private readonly AudioSystem _audioSystem = default!; - - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnInit); - SubscribeLocalEvent(OnLollipop); - SubscribeLocalEvent(OnGumball); - } - - private void OnInit(EntityUid uid, FabricateCandyComponent component, ComponentInit args) - { - if (component.LollipopAction != null || component.GumballAction != null) - return; - - _actionsSystem.AddAction(uid, ref component.LollipopAction, "ActionFabricateLollipop"); - _actionsSystem.AddAction(uid, ref component.GumballAction, "ActionFabricateGumball"); - } - - private void OnLollipop(FabricateLollipopActionEvent args) - { - OnCandy("FoodLollipop", args); - } - - private void OnGumball(FabricateGumballActionEvent args) - { - OnCandy("FoodGumball", args); - } - - private void OnCandy(EntProtoId proto, BaseActionEvent evt) - { - Spawn(proto, Transform(evt.Performer).Coordinates); - if (TryComp(evt.Performer, out FabricateCandyComponent? comp)) - _audioSystem.PlayPvs(comp.FabricationSound, evt.Performer); - evt.Handled = true; - } -} diff --git a/Content.Shared/Nyanotrasen/Actions/FabricateCandyEvent.cs b/Content.Shared/Nyanotrasen/Actions/FabricateCandyEvent.cs deleted file mode 100644 index 3c9371d27eb..00000000000 --- a/Content.Shared/Nyanotrasen/Actions/FabricateCandyEvent.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Content.Shared.Actions.Events; - -public sealed partial class FabricateLollipopActionEvent : InstantActionEvent {} -public sealed partial class FabricateGumballActionEvent : InstantActionEvent {} diff --git a/Content.Shared/_DV/Silicons/Borgs/FabricateCandyComponent.cs b/Content.Shared/_DV/Silicons/Borgs/FabricateCandyComponent.cs new file mode 100644 index 00000000000..bec671c42c5 --- /dev/null +++ b/Content.Shared/_DV/Silicons/Borgs/FabricateCandyComponent.cs @@ -0,0 +1,46 @@ +using Content.Shared.Actions; +using Robust.Shared.Audio; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared._DV.Silicons.Borgs; + +/// +/// Lets a medical borg spawn a number of candy items using actions. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class FabricateCandyComponent : Component +{ + /// + /// Actions to add to the entity. + /// + [DataField(required: true)] + public List Actions = new(); + + /// + /// The sound played when fabricating candy. + /// + [DataField] + public SoundSpecifier FabricationSound = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg") + { + Params = new AudioParams + { + Volume = -2f + } + }; +} + +/// +/// Action event to use for candy fabrication actions. +/// +public sealed partial class FabricateCandyActionEvent : InstantActionEvent +{ + /// + /// The item to spawn at the borg. + /// + /// + /// The client only sends a , no exploits possible with this being in the event. + /// + [DataField(required: true)] + public EntProtoId Item; +} diff --git a/Content.Shared/_DV/Silicons/Borgs/FabricateCandySystem.cs b/Content.Shared/_DV/Silicons/Borgs/FabricateCandySystem.cs new file mode 100644 index 00000000000..c1e7cc3402f --- /dev/null +++ b/Content.Shared/_DV/Silicons/Borgs/FabricateCandySystem.cs @@ -0,0 +1,45 @@ +using Content.Shared.Actions; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Network; +using Robust.Shared.Prototypes; + +namespace Content.Shared._DV.Silicons.Borgs; + +public sealed partial class FabricateCandySystem : EntitySystem +{ + [Dependency] private readonly INetManager _net = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; + [Dependency] private readonly SharedActionsSystem _actions = default!; + [Dependency] private readonly SharedAudioSystem _audio = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnMapInit); + SubscribeLocalEvent(OnFabricate); + } + + private void OnMapInit(Entity ent, ref MapInitEvent args) + { + var (uid, comp) = ent; + foreach (var id in comp.Actions) + { + _actions.AddAction(uid, id); + } + } + + private void OnFabricate(Entity ent, ref FabricateCandyActionEvent args) + { + _audio.PlayPredicted(ent.Comp.FabricationSound, ent, ent); + args.Handled = true; + + if (_net.IsClient) + return; + + var spawned = Spawn(args.Item, Transform(ent).Coordinates); + _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(ent):player} fabricated {ToPrettyString(spawned):item}"); + } +} diff --git a/Resources/Locale/en-US/nyanotrasen/abilities/borgs.ftl b/Resources/Locale/en-US/nyanotrasen/abilities/borgs.ftl deleted file mode 100644 index 833ba59885f..00000000000 --- a/Resources/Locale/en-US/nyanotrasen/abilities/borgs.ftl +++ /dev/null @@ -1,5 +0,0 @@ -action-name-fabricate-lollipop = Fabricate Lollipop -action-description-fabricate-lollipop = Fabricate a lollipop that contains a small dose of Omnizine. - -action-name-fabricate-gumball = Fabricate Gumball -action-description-fabricate-gumball = Fabricate a gumball full of sugar and medicine to treat small injuries. diff --git a/Resources/Prototypes/Nyanotrasen/Actions/types.yml b/Resources/Prototypes/Nyanotrasen/Actions/types.yml index 6cf81a5f88d..31ea8f5316f 100644 --- a/Resources/Prototypes/Nyanotrasen/Actions/types.yml +++ b/Resources/Prototypes/Nyanotrasen/Actions/types.yml @@ -142,24 +142,3 @@ - type: InstantAction icon: Nyanotrasen/Interface/VerbIcons/psionic_invisibility_off.png event: !type:RemovePsionicInvisibilityOffPowerActionEvent - -- type: entity - id: ActionFabricateLollipop - name: action-name-fabricate-lollipop - description: action-description-fabricate-lollipop - components: - - type: InstantAction - icon: { sprite: Nyanotrasen/Objects/Consumable/Food/candy.rsi, state: lollipop } - useDelay: 120 - event: !type:FabricateLollipopActionEvent - -- type: entity - id: ActionFabricateGumball - name: action-name-fabricate-gumball - description: action-description-fabricate-gumball - components: - - type: InstantAction - icon: { sprite: Nyanotrasen/Objects/Consumable/Food/candy.rsi, state: gumball } - iconColor: '#FFAED7' - useDelay: 40 - event: !type:FabricateGumballActionEvent diff --git a/Resources/Prototypes/_DV/Actions/borgs.yml b/Resources/Prototypes/_DV/Actions/borgs.yml new file mode 100644 index 00000000000..126e48d3e13 --- /dev/null +++ b/Resources/Prototypes/_DV/Actions/borgs.yml @@ -0,0 +1,22 @@ +- type: entity + id: ActionFabricateLollipop + name: Fabricate Lollipop + description: Fabricate a lollipop that contains a small dose of Omnizine. + components: + - type: InstantAction + icon: { sprite: _DV/Objects/Consumable/Food/candy.rsi, state: lollipop } + useDelay: 120 + event: !type:FabricateCandyActionEvent + item: FoodLollipop + +- type: entity + id: ActionFabricateGumball + name: Fabricate Gumball + description: Fabricate a gumball full of sugar and medicine to treat small injuries. + components: + - type: InstantAction + icon: { sprite: _DV/Objects/Consumable/Food/candy.rsi, state: gumball } + iconColor: '#FFAED7' + useDelay: 40 + event: !type:FabricateCandyActionEvent + item: FoodGumball diff --git a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Consumable/Food/candy.yml b/Resources/Prototypes/_DV/Entities/Objects/Consumable/Food/candy.yml similarity index 73% rename from Resources/Prototypes/Nyanotrasen/Entities/Objects/Consumable/Food/candy.yml rename to Resources/Prototypes/_DV/Entities/Objects/Consumable/Food/candy.yml index 971748013b3..c29eef468ed 100644 --- a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Consumable/Food/candy.yml +++ b/Resources/Prototypes/_DV/Entities/Objects/Consumable/Food/candy.yml @@ -1,5 +1,15 @@ - type: entity + abstract: true parent: FoodBase + id: FoodCandyBase + components: + - type: Sprite + sprite: _DV/Objects/Consumable/Food/candy.rsi + - type: Appearance + - type: RandomizedCandy + +- type: entity + parent: FoodCandyBase id: FoodLollipop name: lollipop description: For being such a good sport! It's enriched with potent yet mostly safe-to-eat medicine. @@ -7,7 +17,7 @@ - type: SolutionContainerManager solutions: food: - maxVol: 15 + maxVol: 17 # 2 extra reagents: - ReagentId: Sugar Quantity: 3 @@ -20,29 +30,26 @@ - ReagentId: Vitamin Quantity: 3 - type: Sprite - sprite: Nyanotrasen/Objects/Consumable/Food/candy.rsi layers: - state: lollipop-ball map: [ "enum.CandyVisualLayers.Ball" ] - state: lollipop-stickandshine - type: Clothing - sprite: Nyanotrasen/Objects/Consumable/Food/candy.rsi + sprite: _DV/Objects/Consumable/Food/candy.rsi slots: [ mask ] equippedPrefix: lollipop - quickEquip: false # would block eating otherwise - - type: Appearance - - type: RandomizedCandy + quickEquip: false # would block eating otherwise - type: entity - parent: FoodBase + parent: FoodCandyBase id: FoodGumball name: gumball - description: Try as you might, you can't blow bubbles with it... it's enriched with medicine for minor ailments. + description: "Try as you might, you can't blow bubbles with it... it's enriched with medicine for minor ailments." components: - type: SolutionContainerManager solutions: food: - maxVol: 15 + maxVol: 15 # 1 extra reagents: - ReagentId: Sugar Quantity: 5 @@ -53,10 +60,7 @@ - ReagentId: Dylovene Quantity: 3 - type: Sprite - sprite: Nyanotrasen/Objects/Consumable/Food/candy.rsi layers: - state: gumball map: [ "enum.CandyVisualLayers.Ball" ] - state: gumball-shine - - type: Appearance - - type: RandomizedCandy diff --git a/Resources/Prototypes/borg_types.yml b/Resources/Prototypes/borg_types.yml index 99c5f4ee764..f5816b6956b 100644 --- a/Resources/Prototypes/borg_types.yml +++ b/Resources/Prototypes/borg_types.yml @@ -172,7 +172,10 @@ - type: ShowHealthIcons damageContainers: - Biological - - type: FabricateCandy # Nyanotrasen - The medical cyborg can generate candies filled with medicine. + - type: FabricateCandy # DeltaV - The medical cyborg can generate candies filled with medicine. + actions: + - ActionFabricateLollipop + - ActionFabricateGumball - type: SurgeryTarget # Shitmed - type: Sanitized # Shitmed diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/meta.json b/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/meta.json deleted file mode 100644 index a81452e8c26..00000000000 --- a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/meta.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "version": 1, - "license": "CC-BY-SA-3.0", - "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/c6e3401f2e7e1e55c57060cdf956a98ef1fefc24, made colorable by pissdemon, equip sprites made by pissdemon based on cigarette.rsi taken from tgstation and paradise (see attributions in Resources/Textures/Objects/Consumable/Smokeables/Cigarettes/cigarette.rsi)", - "size": { - "x": 32, - "y": 32 - }, - "states": [ - { - "name": "gumball" - }, - { - "name": "gumball-shine" - }, - { - "name": "lollipop" - }, - { - "name": "lollipop-ball" - }, - { - "name": "lollipop-stickandshine" - }, - { - "name": "lollipop-equipped-MASK", - "directions": 4 - }, - { - "name": "lollipop-equipped-MASK-vulpkanin", - "directions": 4 - } - ] -} diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/gumball-shine.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/gumball-shine.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/gumball-shine.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/gumball-shine.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/gumball.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/gumball.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/gumball.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/gumball.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-ball.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-ball.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-ball.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-ball.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK-vulpkanin.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK-vulpkanin.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK-vulpkanin.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK-vulpkanin.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-equipped-MASK.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-stickandshine.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-stickandshine.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop-stickandshine.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop-stickandshine.png diff --git a/Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop.png b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop.png similarity index 100% rename from Resources/Textures/Nyanotrasen/Objects/Consumable/Food/candy.rsi/lollipop.png rename to Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/lollipop.png diff --git a/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/meta.json b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/meta.json new file mode 100644 index 00000000000..a3788448bfa --- /dev/null +++ b/Resources/Textures/_DV/Objects/Consumable/Food/candy.rsi/meta.json @@ -0,0 +1,34 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/c6e3401f2e7e1e55c57060cdf956a98ef1fefc24, made colorable by pissdemon, equip sprites made by pissdemon based on cigarette.rsi taken from tgstation and paradise (see attributions in Resources/Textures/Objects/Consumable/Smokeables/Cigarettes/cigarette.rsi)", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "gumball" + }, + { + "name": "gumball-shine" + }, + { + "name": "lollipop" + }, + { + "name": "lollipop-ball" + }, + { + "name": "lollipop-stickandshine" + }, + { + "name": "lollipop-equipped-MASK", + "directions": 4 + }, + { + "name": "lollipop-equipped-MASK-vulpkanin", + "directions": 4 + } + ] +}