diff --git a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs index 0a0356c977..90917d5b95 100644 --- a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -42,6 +42,10 @@ namespace Content.Client.GameObjects.Components.Instruments private uint _sequenceStartTick; + private bool _allowPercussion; + + private bool _allowProgramChange; + /// /// A queue of MidiEvents to be sent to the server. /// @@ -98,6 +102,34 @@ namespace Content.Client.GameObjects.Components.Instruments } } + [ViewVariables(VVAccess.ReadWrite)] + public bool AllowPercussion + { + get => _allowPercussion; + set + { + _allowPercussion = value; + if (_renderer != null) + { + _renderer.DisablePercussionChannel = !_allowPercussion; + } + } + } + + [ViewVariables(VVAccess.ReadWrite)] + public bool AllowProgramChange + { + get => _allowProgramChange; + set + { + _allowProgramChange = value; + if (_renderer != null) + { + _renderer.DisableProgramChangeEvent = !_allowProgramChange; + } + } + } + /// /// Whether this instrument is handheld or not. /// @@ -128,7 +160,7 @@ namespace Content.Client.GameObjects.Components.Instruments IoCManager.InjectDependencies(this); } - protected void SetupRenderer(bool fromStateChange = false) + protected virtual void SetupRenderer(bool fromStateChange = false) { if (IsRendererAlive) return; @@ -142,6 +174,8 @@ namespace Content.Client.GameObjects.Components.Instruments _renderer.MidiBank = _instrumentBank; _renderer.MidiProgram = _instrumentProgram; _renderer.TrackingEntity = Owner; + _renderer.DisablePercussionChannel = !_allowPercussion; + _renderer.DisableProgramChangeEvent = !_allowProgramChange; _renderer.OnMidiPlayerFinished += () => { OnMidiPlaybackEnded?.Invoke(); @@ -196,6 +230,8 @@ namespace Content.Client.GameObjects.Components.Instruments serializer.DataField(this, x => Handheld, "handheld", false); serializer.DataField(ref _instrumentProgram, "program", (byte) 1); serializer.DataField(ref _instrumentBank, "bank", (byte) 0); + serializer.DataField(ref _allowPercussion, "allowPercussion", false); + serializer.DataField(ref _allowProgramChange, "allowProgramChange", false); } public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null) diff --git a/Resources/Prototypes/Entities/Objects/Fun/instruments.yml b/Resources/Prototypes/Entities/Objects/Fun/instruments.yml index b52cec6f8e..6656842ab9 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/instruments.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/instruments.yml @@ -206,3 +206,20 @@ - type: Item size: 24 sprite: Objects/Fun/Instruments/bike_horn.rsi + +- type: entity + name: super synthesizer + description: Blasting the ghetto with Touhou MIDIs since 2020. + parent: BaseHandheldInstrument + id: SuperSynthesizerInstrument + components: + - type: Instrument + allowPercussion: true + allowProgramChange: true + - type: Sprite + sprite: Objects/Fun/Instruments/h_synthesizer.rsi + state: icon + + - type: Item + size: 24 + sprite: Objects/Fun/Instruments/h_synthesizer.rsi