Instrument State now syncs more instrument values.
For adminbus purposes, mostly.
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
/// Changes the instrument the midi renderer will play.
|
||||
/// </summary>
|
||||
[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.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="MidiRenderer.OpenInput"/>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the instrument is an item which can be held or not.
|
||||
/// </summary>
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user