Files
crystall-punk-14/Content.Shared/Instruments/SharedInstrumentComponent.cs

111 lines
3.1 KiB
C#
Raw Normal View History

using System;
2021-11-28 01:47:36 +01:00
using Robust.Shared.Analyzers;
using Robust.Shared.Audio.Midi;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
2021-11-28 01:47:36 +01:00
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
2021-11-28 01:47:36 +01:00
namespace Content.Shared.Instruments;
[NetworkedComponent, Friend(typeof(SharedInstrumentSystem))]
public abstract class SharedInstrumentComponent : Component
{
2021-11-28 01:47:36 +01:00
[ViewVariables]
public bool Playing { get; set; }
2021-11-28 01:47:36 +01:00
[ViewVariables]
public uint LastSequencerTick { get; set; }
[DataField("program"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public byte InstrumentProgram { get; set; }
[DataField("bank"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public byte InstrumentBank { get; set; }
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public bool AllowPercussion { get; set; }
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite)]
2021-11-28 01:47:36 +01:00
public bool AllowProgramChange { get ; set; }
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite)]
public bool RespectMidiLimits { get; set; } = true;
2021-11-28 01:47:36 +01:00
[ViewVariables(VVAccess.ReadWrite)]
public bool DirtyRenderer { get; set; }
}
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 EntityUid Uid { get; }
2020-05-20 15:15:17 +02:00
2021-11-28 01:47:36 +01:00
public InstrumentStopMidiEvent(EntityUid uid)
{
2021-11-28 01:47:36 +01:00
Uid = uid;
}
}
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 EntityUid Uid { get; }
public InstrumentStartMidiEvent(EntityUid uid)
{
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 EntityUid Uid { get; }
public MidiEvent[] MidiEvent { get; }
2021-11-28 01:47:36 +01:00
public InstrumentMidiEventEvent(EntityUid uid, MidiEvent[] 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
[Serializable, NetSerializable]
public sealed class InstrumentState : ComponentState
2021-11-28 01:47:36 +01:00
{
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)
{
2021-11-28 01:47:36 +01:00
Playing = playing;
InstrumentProgram = instrumentProgram;
InstrumentBank = instrumentBank;
AllowPercussion = allowPercussion;
AllowProgramChange = allowProgramChange;
RespectMidiLimits = respectMidiLimits;
}
}
2021-11-28 01:47:36 +01:00
[NetSerializable, Serializable]
public enum InstrumentUiKey
{
Key,
}