Files
OldThink/Content.Shared/Instruments/SharedInstrumentComponent.cs

141 lines
3.5 KiB
C#
Raw Permalink Normal View History

using System.Collections;
using Robust.Shared.Audio.Midi;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
2021-11-28 01:47:36 +01:00
namespace Content.Shared.Instruments;
[NetworkedComponent]
[Access(typeof(SharedInstrumentSystem))]
public abstract partial class SharedInstrumentComponent : Component
{
2023-09-12 14:43:06 +10:00
[ViewVariables]
2021-11-28 01:47:36 +01:00
public bool Playing { get; set; }
2023-09-12 14:43:06 +10:00
[DataField("program"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public byte InstrumentProgram { get; set; }
2023-09-12 14:43:06 +10:00
[DataField("bank"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public byte InstrumentBank { get; set; }
2023-09-12 14:43:06 +10:00
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public bool AllowPercussion { get; set; }
2023-09-12 14:43:06 +10:00
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public bool AllowProgramChange { get ; set; }
2023-09-12 14:43:06 +10:00
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite)]
public bool RespectMidiLimits { get; set; } = true;
2023-09-12 14:43:06 +10:00
[ViewVariables(VVAccess.ReadWrite)]
public EntityUid? Master { get; set; } = null;
2023-09-12 14:43:06 +10:00
[ViewVariables]
public BitArray FilteredChannels { get; set; } = new(RobustMidiEvent.MaxChannels, true);
2021-11-28 01:47:36 +01:00
}
2023-09-12 14:43:06 +10:00
[Serializable, NetSerializable]
public sealed class InstrumentComponentState : ComponentState
{
public bool Playing;
public byte InstrumentProgram;
public byte InstrumentBank;
public bool AllowPercussion;
public bool AllowProgramChange;
public bool RespectMidiLimits;
public NetEntity? Master;
public BitArray FilteredChannels = default!;
}
2020-05-20 17:13:49 +02:00
2021-11-28 01:47:36 +01:00
/// <summary>
/// This message is sent to the client to completely stop midi input and midi playback.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentStopMidiEvent : EntityEventArgs
2021-11-28 01:47:36 +01:00
{
public NetEntity Uid { get; }
2020-05-20 15:15:17 +02:00
public InstrumentStopMidiEvent(NetEntity uid)
{
2021-11-28 01:47:36 +01:00
Uid = uid;
}
}
/// <summary>
/// Send from the client to the server to set a master instrument.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentSetMasterEvent : EntityEventArgs
{
public NetEntity Uid { get; }
public NetEntity? Master { get; }
public InstrumentSetMasterEvent(NetEntity uid, NetEntity? 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 NetEntity Uid { get; }
public int Channel { get; }
public bool Value { get; }
public InstrumentSetFilteredChannelEvent(NetEntity uid, int channel, bool value)
{
Uid = uid;
Channel = channel;
Value = value;
}
}
2021-11-28 01:47:36 +01:00
/// <summary>
/// This message is sent to the client to start the synth.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentStartMidiEvent : EntityEventArgs
2021-11-28 01:47:36 +01:00
{
public NetEntity Uid { get; }
2021-11-28 01:47:36 +01:00
public InstrumentStartMidiEvent(NetEntity uid)
2021-11-28 01:47:36 +01:00
{
Uid = uid;
}
2021-11-28 01:47:36 +01:00
}
/// <summary>
/// This message carries a MidiEvent to be played on clients.
/// </summary>
[Serializable, NetSerializable]
public sealed class InstrumentMidiEventEvent : EntityEventArgs
2021-11-28 01:47:36 +01:00
{
public NetEntity Uid { get; }
public RobustMidiEvent[] MidiEvent { get; }
public InstrumentMidiEventEvent(NetEntity uid, RobustMidiEvent[] midiEvent)
2020-05-21 15:20:37 +02:00
{
2021-11-28 01:47:36 +01:00
Uid = uid;
MidiEvent = midiEvent;
2020-05-21 15:20:37 +02:00
}
2021-11-28 01:47:36 +01:00
}
2020-05-21 15:20:37 +02:00
2021-11-28 01:47:36 +01:00
[NetSerializable, Serializable]
public enum InstrumentUiKey
{
Key,
}