diff --git a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs index 90917d5b95..d30bcf6da9 100644 --- a/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Client/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -72,7 +72,7 @@ namespace Content.Client.GameObjects.Components.Instruments /// Changes the instrument the midi renderer will play. /// [ViewVariables(VVAccess.ReadWrite)] - public byte InstrumentProgram + public override byte InstrumentProgram { get => _instrumentProgram; set @@ -89,7 +89,7 @@ namespace Content.Client.GameObjects.Components.Instruments /// Changes the instrument bank the midi renderer will use. /// [ViewVariables(VVAccess.ReadWrite)] - public byte InstrumentBank + public override byte InstrumentBank { get => _instrumentBank; set @@ -103,7 +103,7 @@ namespace Content.Client.GameObjects.Components.Instruments } [ViewVariables(VVAccess.ReadWrite)] - public bool AllowPercussion + public override bool AllowPercussion { get => _allowPercussion; set @@ -117,7 +117,7 @@ namespace Content.Client.GameObjects.Components.Instruments } [ViewVariables(VVAccess.ReadWrite)] - public bool AllowProgramChange + public override bool AllowProgramChange { get => _allowProgramChange; set @@ -316,6 +316,11 @@ namespace Content.Client.GameObjects.Components.Instruments { EndRenderer(true); } + + AllowPercussion = state.AllowPercussion; + AllowProgramChange = state.AllowProgramChange; + InstrumentBank = state.InstrumentBank; + InstrumentProgram = state.InstrumentProgram; } /// diff --git a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs index 678acf50b0..89d6ca6711 100644 --- a/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs +++ b/Content.Server/GameObjects/Components/Instruments/InstrumentComponent.cs @@ -70,6 +70,47 @@ namespace Content.Server.GameObjects.Components.Instruments [ViewVariables] private int _midiEventCount = 0; + private byte _instrumentProgram; + private byte _instrumentBank; + private bool _allowPercussion; + private bool _allowProgramChange; + + [ViewVariables(VVAccess.ReadWrite)] + public override byte InstrumentProgram { get => _instrumentProgram; + set + { + _instrumentProgram = value; + Dirty(); + } + } + + [ViewVariables(VVAccess.ReadWrite)] + public override byte InstrumentBank { get => _instrumentBank; + set + { + _instrumentBank = value; + Dirty(); + } + } + + [ViewVariables(VVAccess.ReadWrite)] + public override bool AllowPercussion { get => _allowPercussion; + set + { + _allowPercussion = value; + Dirty(); + } + } + + [ViewVariables(VVAccess.ReadWrite)] + public override bool AllowProgramChange { get => _allowProgramChange; + set + { + _allowProgramChange = value; + Dirty(); + } + } + /// /// Whether the instrument is an item which can be held or not. /// @@ -130,11 +171,15 @@ namespace Content.Server.GameObjects.Components.Instruments { base.ExposeData(serializer); serializer.DataField(ref _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 ComponentState GetComponentState() { - return new InstrumentState(Playing, _lastSequencerTick); + return new InstrumentState(Playing, InstrumentProgram, InstrumentBank, AllowPercussion, AllowProgramChange, _lastSequencerTick); } public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null) diff --git a/Content.Shared/GameObjects/Components/Instruments/SharedInstrumentComponent.cs b/Content.Shared/GameObjects/Components/Instruments/SharedInstrumentComponent.cs index 87c1fa35f3..ed2292514f 100644 --- a/Content.Shared/GameObjects/Components/Instruments/SharedInstrumentComponent.cs +++ b/Content.Shared/GameObjects/Components/Instruments/SharedInstrumentComponent.cs @@ -2,6 +2,7 @@ using System; using Robust.Shared.Audio.Midi; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; namespace Content.Shared.GameObjects.Components.Instruments { @@ -17,6 +18,11 @@ namespace Content.Shared.GameObjects.Components.Instruments public override string Name => "Instrument"; public override uint? NetID => ContentNetIDs.INSTRUMENTS; + public virtual byte InstrumentProgram { get; set; } + public virtual byte InstrumentBank { get; set; } + public virtual bool AllowPercussion { get; set; } + public virtual bool AllowProgramChange { get ; set; } + public virtual void Update(float delta) { } @@ -58,10 +64,18 @@ namespace Content.Shared.GameObjects.Components.Instruments public class InstrumentState : ComponentState { public bool Playing { get; } + public byte InstrumentProgram { get; } + public byte InstrumentBank { get; } + public bool AllowPercussion { get; } + public bool AllowProgramChange { get; } - public InstrumentState(bool playing, uint sequencerTick = 0) : base(ContentNetIDs.INSTRUMENTS) + public InstrumentState(bool playing, byte instrumentProgram, byte instrumentBank, bool allowPercussion, bool allowProgramChange, uint sequencerTick = 0) : base(ContentNetIDs.INSTRUMENTS) { Playing = playing; + InstrumentProgram = instrumentProgram; + InstrumentBank = instrumentBank; + AllowPercussion = allowPercussion; + AllowProgramChange = allowProgramChange; } }