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.
|
/// Changes the instrument the midi renderer will play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public byte InstrumentProgram
|
public override byte InstrumentProgram
|
||||||
{
|
{
|
||||||
get => _instrumentProgram;
|
get => _instrumentProgram;
|
||||||
set
|
set
|
||||||
@@ -89,7 +89,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
|||||||
/// Changes the instrument bank the midi renderer will use.
|
/// Changes the instrument bank the midi renderer will use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public byte InstrumentBank
|
public override byte InstrumentBank
|
||||||
{
|
{
|
||||||
get => _instrumentBank;
|
get => _instrumentBank;
|
||||||
set
|
set
|
||||||
@@ -103,7 +103,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool AllowPercussion
|
public override bool AllowPercussion
|
||||||
{
|
{
|
||||||
get => _allowPercussion;
|
get => _allowPercussion;
|
||||||
set
|
set
|
||||||
@@ -117,7 +117,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool AllowProgramChange
|
public override bool AllowProgramChange
|
||||||
{
|
{
|
||||||
get => _allowProgramChange;
|
get => _allowProgramChange;
|
||||||
set
|
set
|
||||||
@@ -316,6 +316,11 @@ namespace Content.Client.GameObjects.Components.Instruments
|
|||||||
{
|
{
|
||||||
EndRenderer(true);
|
EndRenderer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllowPercussion = state.AllowPercussion;
|
||||||
|
AllowProgramChange = state.AllowProgramChange;
|
||||||
|
InstrumentBank = state.InstrumentBank;
|
||||||
|
InstrumentProgram = state.InstrumentProgram;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="MidiRenderer.OpenInput"/>
|
/// <inheritdoc cref="MidiRenderer.OpenInput"/>
|
||||||
|
|||||||
@@ -70,6 +70,47 @@ namespace Content.Server.GameObjects.Components.Instruments
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private int _midiEventCount = 0;
|
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>
|
/// <summary>
|
||||||
/// Whether the instrument is an item which can be held or not.
|
/// Whether the instrument is an item which can be held or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -130,11 +171,15 @@ namespace Content.Server.GameObjects.Components.Instruments
|
|||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
serializer.DataField(ref _handheld, "handheld", false);
|
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()
|
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)
|
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.Audio.Midi;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Instruments
|
namespace Content.Shared.GameObjects.Components.Instruments
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,11 @@ namespace Content.Shared.GameObjects.Components.Instruments
|
|||||||
public override string Name => "Instrument";
|
public override string Name => "Instrument";
|
||||||
public override uint? NetID => ContentNetIDs.INSTRUMENTS;
|
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)
|
public virtual void Update(float delta)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -58,10 +64,18 @@ namespace Content.Shared.GameObjects.Components.Instruments
|
|||||||
public class InstrumentState : ComponentState
|
public class InstrumentState : ComponentState
|
||||||
{
|
{
|
||||||
public bool Playing { get; }
|
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;
|
Playing = playing;
|
||||||
|
InstrumentProgram = instrumentProgram;
|
||||||
|
InstrumentBank = instrumentBank;
|
||||||
|
AllowPercussion = allowPercussion;
|
||||||
|
AllowProgramChange = allowProgramChange;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user