Instrument band support, submodule update to 138.0.0 (#17995)

This commit is contained in:
Vera Aguilera Puerto
2023-07-16 21:12:53 +02:00
committed by GitHub
parent 69ff0ae2e6
commit a2893dd6c3
16 changed files with 722 additions and 178 deletions

View File

@@ -1,33 +1,38 @@
using System.Collections;
using Robust.Shared.Audio.Midi;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Instruments;
[NetworkedComponent, Access(typeof(SharedInstrumentSystem))]
public abstract class SharedInstrumentComponent : Component
[NetworkedComponent]
[AutoGenerateComponentState(true)]
[Access(typeof(SharedInstrumentSystem))]
public abstract partial class SharedInstrumentComponent : Component
{
[ViewVariables]
[ViewVariables, AutoNetworkedField]
public bool Playing { get; set; }
[DataField("program"), ViewVariables(VVAccess.ReadWrite)]
[DataField("program"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public byte InstrumentProgram { get; set; }
[DataField("bank"), ViewVariables(VVAccess.ReadWrite)]
[DataField("bank"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public byte InstrumentBank { get; set; }
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite)]
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool AllowPercussion { get; set; }
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite)]
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool AllowProgramChange { get ; set; }
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite)]
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public bool RespectMidiLimits { get; set; } = true;
[ViewVariables(VVAccess.ReadWrite)]
[Access(typeof(SharedInstrumentSystem), Other = AccessPermissions.ReadWrite)] // FIXME Friends
public bool DirtyRenderer { get; set; }
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public EntityUid? Master { get; set; } = null;
[ViewVariables, AutoNetworkedField]
public BitArray FilteredChannels { get; set; } = new(RobustMidiEvent.MaxChannels, true);
}
@@ -45,6 +50,40 @@ public sealed class InstrumentStopMidiEvent : EntityEventArgs
}
}
/// <summary>
/// Send from the client to the server to set a master instrument.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentSetMasterEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public EntityUid? Master { get; }
public InstrumentSetMasterEvent(EntityUid uid, EntityUid? master)
{
Uid = uid;
Master = master;
}
}
/// <summary>
/// Send from the client to the server to set a master instrument channel.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentSetFilteredChannelEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public int Channel { get; }
public bool Value { get; }
public InstrumentSetFilteredChannelEvent(EntityUid uid, int channel, bool value)
{
Uid = uid;
Channel = channel;
Value = value;
}
}
/// <summary>
/// This message is sent to the client to start the synth.
/// </summary>
@@ -75,27 +114,6 @@ public sealed class InstrumentMidiEventEvent : EntityEventArgs
}
}
[Serializable, NetSerializable]
public sealed class InstrumentState : ComponentState
{
public bool Playing { get; }
public byte InstrumentProgram { get; }
public byte InstrumentBank { get; }
public bool AllowPercussion { get; }
public bool AllowProgramChange { get; }
public bool RespectMidiLimits { get; }
public InstrumentState(bool playing, byte instrumentProgram, byte instrumentBank, bool allowPercussion, bool allowProgramChange, bool respectMidiLimits)
{
Playing = playing;
InstrumentProgram = instrumentProgram;
InstrumentBank = instrumentBank;
AllowPercussion = allowPercussion;
AllowProgramChange = allowProgramChange;
RespectMidiLimits = respectMidiLimits;
}
}
[NetSerializable, Serializable]
public enum InstrumentUiKey
{