diff --git a/Content.Server/White/Fluff/Components/ClothingMidiComponent.cs b/Content.Server/White/Fluff/Components/ClothingMidiComponent.cs new file mode 100644 index 0000000000..e4e04526a7 --- /dev/null +++ b/Content.Server/White/Fluff/Components/ClothingMidiComponent.cs @@ -0,0 +1,10 @@ +using Content.Shared.Actions.ActionTypes; + +namespace Content.Server.White.Fluff.Components; + +[RegisterComponent] +public sealed class ClothingMidiComponent : Component +{ + [DataField("midiAction", required: true, serverOnly: true)] // server only, as it uses a server-BUI event !type + public InstantAction? MidiAction; +} diff --git a/Content.Server/White/Fluff/Systems/ClothingMidiSystem.cs b/Content.Server/White/Fluff/Systems/ClothingMidiSystem.cs new file mode 100644 index 0000000000..a3505f2158 --- /dev/null +++ b/Content.Server/White/Fluff/Systems/ClothingMidiSystem.cs @@ -0,0 +1,57 @@ +using System.Linq; +using Content.Server.White.Fluff.Components; +using Content.Shared.Actions; +using Content.Shared.Inventory.Events; +using Robust.Server.GameObjects; + +namespace Content.Server.White.Fluff.Systems; + +public sealed class ClothingMidiSystem : EntitySystem +{ + [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; + [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnEquip); + SubscribeLocalEvent(OnUnequip); + + } + + private void OnEquip(EntityUid uid, ClothingMidiComponent component, GotEquippedEvent args) + { + if (component.MidiAction != null) + { + if (!TryComp(args.Equipment, out var ui) || ui.Interfaces.Count == 0) + return; + var comp = EnsureComp(args.Equipee); + comp.Interfaces.Add(ui.Interfaces.First().Key, ui.Interfaces.First().Value); + + _actionsSystem.AddAction(args.Equipee, component.MidiAction, null); + } + } + + private void OnUnequip(EntityUid uid, ClothingMidiComponent component, GotUnequippedEvent args) + { + if (component.MidiAction != null) + { + _actionsSystem.RemoveAction(args.Equipee, component.MidiAction); + + if (!TryComp(args.Equipment, out var ui) || ui.Interfaces.Count == 0) + return; + + if (!TryComp(args.Equipee, out var personUi)) + return; + + if (personUi.Interfaces.Count is 0 or 1) + { + RemComp(args.Equipee); + return; + } + + personUi.Interfaces.Remove(ui.Interfaces.First().Key); + } + } +} diff --git a/Resources/Prototypes/White/Fluff/fluff.yml b/Resources/Prototypes/White/Fluff/fluff.yml index 32108e5784..c9fd6d7c7a 100644 --- a/Resources/Prototypes/White/Fluff/fluff.yml +++ b/Resources/Prototypes/White/Fluff/fluff.yml @@ -382,3 +382,36 @@ - type: TemperatureProtection coefficient: 0.005 +#koitorra +- type: entity + parent: ClothingMaskGas + id: ClothingMaskGasKoitorra + name: бионическая нейрочелюсть + description: "Жесткая и темная. По центру шеи расположен светодиод, обрамлённый металлическими вставками, что плавно двигаются вниз. На краю шеи есть еле видное обозначение модели: 'JawV-02, Роджер Фенелон'." + components: + - type: Sprite + sprite: White/Fluff/koitorra/koitorra_mask.rsi + - type: Item + sprite: White/Fluff/koitorra/koitorra_mask.rsi + - type: Clothing + sprite: + - type: VoiceMasker + default: ClothingMaskGas + - type: UserInterface + interfaces: + - key: enum.InstrumentUiKey.Key + type: InstrumentBoundUserInterface + - type: ClothingMidi + midiAction: + name: MIDI + checkCanInteract: false + icon: White/Fluff/koitorra/koitorra_mask.rsi/icon.png + description: Проиграть MIDI. + event: !type:OpenUiActionEvent + key: enum.InstrumentUiKey.Key + - type: Instrument + allowPercussion: false + handheld: false + bank: 1 + program: 2 + diff --git a/Resources/Prototypes/White/Fluff/sponsor.yml b/Resources/Prototypes/White/Fluff/sponsor.yml index 16f888ae68..155da7cf6d 100644 --- a/Resources/Prototypes/White/Fluff/sponsor.yml +++ b/Resources/Prototypes/White/Fluff/sponsor.yml @@ -137,3 +137,9 @@ id: derderiotSynthesizerLoadout entity: SuperSynthesizerInstrumentDerderiot sponsorOnly: true + +# koitorra +- type: loadout + id: koitorraMaskLoadout + entity: ClothingMaskGasKoitorra + sponsorOnly: true diff --git a/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/equipped-MASK.png b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/equipped-MASK.png new file mode 100644 index 0000000000..554d7f47b1 Binary files /dev/null and b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/equipped-MASK.png differ diff --git a/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/icon.png b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/icon.png new file mode 100644 index 0000000000..a73e1c4e83 Binary files /dev/null and b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/icon.png differ diff --git a/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-left.png b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-left.png new file mode 100644 index 0000000000..0e209c0f9f Binary files /dev/null and b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-left.png differ diff --git a/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-right.png b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-right.png new file mode 100644 index 0000000000..73eccff0dd Binary files /dev/null and b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/inhand-right.png differ diff --git a/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/meta.json b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/meta.json new file mode 100644 index 0000000000..c8b32bd059 --- /dev/null +++ b/Resources/Textures/White/Fluff/koitorra/koitorra_mask.rsi/meta.json @@ -0,0 +1,26 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Copyright @koitorra", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + }, + { + "name": "equipped-MASK", + "directions": 4 + }, + { + "name": "inhand-left", + "directions": 4 + }, + { + "name": "inhand-right", + "directions": 4 + } + ] +}