Files
tbd-station-14/Content.Shared/Instruments/SharedInstrumentComponent.cs
2021-11-28 01:47:36 +01:00

113 lines
2.9 KiB
C#

using System;
using Robust.Shared.Analyzers;
using Robust.Shared.Audio.Midi;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Instruments;
[NetworkedComponent, Friend(typeof(SharedInstrumentSystem))]
public class SharedInstrumentComponent : Component
{
public override string Name => "Instrument";
[ViewVariables]
public bool Playing { get; set; }
[ViewVariables]
public uint LastSequencerTick { get; set; }
[DataField("program")]
public byte InstrumentProgram { get; set; }
[DataField("bank")]
public byte InstrumentBank { get; set; }
[DataField("allowPercussion")]
public bool AllowPercussion { get; set; }
[DataField("allowProgramChange")]
public bool AllowProgramChange { get ; set; }
[DataField("respectMidiLimits")]
public bool RespectMidiLimits { get; set; }
[ViewVariables(VVAccess.ReadWrite)]
public bool DirtyRenderer { get; set; }
}
/// <summary>
/// This message is sent to the client to completely stop midi input and midi playback.
/// </summary>
[Serializable, NetSerializable]
public class InstrumentStopMidiEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public InstrumentStopMidiEvent(EntityUid uid)
{
Uid = uid;
}
}
/// <summary>
/// This message is sent to the client to start the synth.
/// </summary>
[Serializable, NetSerializable]
public class InstrumentStartMidiEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public InstrumentStartMidiEvent(EntityUid uid)
{
Uid = uid;
}
}
/// <summary>
/// This message carries a MidiEvent to be played on clients.
/// </summary>
[Serializable, NetSerializable]
public class InstrumentMidiEventEvent : EntityEventArgs
{
public EntityUid Uid { get; }
public MidiEvent[] MidiEvent { get; }
public InstrumentMidiEventEvent(EntityUid uid, MidiEvent[] midiEvent)
{
Uid = uid;
MidiEvent = midiEvent;
}
}
[Serializable, NetSerializable]
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 bool RespectMidiLimits { get; }
public InstrumentState(bool playing, byte instrumentProgram, byte instrumentBank, bool allowPercussion, bool allowProgramChange, bool respectMidiLimits, uint sequencerTick = 0)
{
Playing = playing;
InstrumentProgram = instrumentProgram;
InstrumentBank = instrumentBank;
AllowPercussion = allowPercussion;
AllowProgramChange = allowProgramChange;
RespectMidiLimits = respectMidiLimits;
}
}
[NetSerializable, Serializable]
public enum InstrumentUiKey
{
Key,
}