Instruments have a property for enabling/disabling MIDI limits.
- Added unlimited super synth that doesn't respect MIDI limits! Adminbuse it to your heart's content and blast your epic MIDIs, fellow badmins.
This commit is contained in:
@@ -52,6 +52,8 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
|
||||
private bool _allowProgramChange;
|
||||
|
||||
private bool _respectMidiLimits;
|
||||
|
||||
/// <summary>
|
||||
/// A queue of MidiEvents to be sent to the server.
|
||||
/// </summary>
|
||||
@@ -239,6 +241,7 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
serializer.DataField(ref _instrumentBank, "bank", (byte) 0);
|
||||
serializer.DataField(ref _allowPercussion, "allowPercussion", false);
|
||||
serializer.DataField(ref _allowProgramChange, "allowProgramChange", false);
|
||||
serializer.DataField(ref _respectMidiLimits, "respectMidiLimits", true);
|
||||
}
|
||||
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null)
|
||||
@@ -429,7 +432,9 @@ namespace Content.Client.GameObjects.Components.Instruments
|
||||
|
||||
if (_midiEventBuffer.Count == 0) return;
|
||||
|
||||
var max = Math.Min(_instrumentSystem.MaxMidiEventsPerBatch, _instrumentSystem.MaxMidiEventsPerSecond - _sentWithinASec);
|
||||
var max = _respectMidiLimits ?
|
||||
Math.Min(_instrumentSystem.MaxMidiEventsPerBatch, _instrumentSystem.MaxMidiEventsPerSecond - _sentWithinASec)
|
||||
: _midiEventBuffer.Count;
|
||||
|
||||
if (max <= 0)
|
||||
{
|
||||
|
||||
@@ -78,8 +78,8 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
private byte _instrumentBank;
|
||||
private bool _allowPercussion;
|
||||
private bool _allowProgramChange;
|
||||
private bool _respectMidiLimits;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public override byte InstrumentProgram { get => _instrumentProgram;
|
||||
set
|
||||
{
|
||||
@@ -88,7 +88,6 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public override byte InstrumentBank { get => _instrumentBank;
|
||||
set
|
||||
{
|
||||
@@ -97,7 +96,6 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public override bool AllowPercussion { get => _allowPercussion;
|
||||
set
|
||||
{
|
||||
@@ -106,7 +104,6 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
}
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public override bool AllowProgramChange { get => _allowProgramChange;
|
||||
set
|
||||
{
|
||||
@@ -115,6 +112,14 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RespectMidiLimits { get => _respectMidiLimits;
|
||||
set
|
||||
{
|
||||
_respectMidiLimits = value;
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the instrument is an item which can be held or not.
|
||||
/// </summary>
|
||||
@@ -181,11 +186,12 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
serializer.DataField(ref _instrumentBank, "bank", (byte) 0);
|
||||
serializer.DataField(ref _allowPercussion, "allowPercussion", false);
|
||||
serializer.DataField(ref _allowProgramChange, "allowProgramChange", false);
|
||||
serializer.DataField(ref _respectMidiLimits, "respectMidiLimits", true);
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new InstrumentState(Playing, InstrumentProgram, InstrumentBank, AllowPercussion, AllowProgramChange, _lastSequencerTick);
|
||||
return new InstrumentState(Playing, InstrumentProgram, InstrumentBank, AllowPercussion, AllowProgramChange, RespectMidiLimits, _lastSequencerTick);
|
||||
}
|
||||
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel channel, ICommonSession? session = null)
|
||||
@@ -217,6 +223,8 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
|
||||
_laggedBatches++;
|
||||
|
||||
if (_respectMidiLimits)
|
||||
{
|
||||
if (_laggedBatches == (int) (maxMidiLaggedBatches * (1 / 3d) + 1))
|
||||
{
|
||||
Owner.PopupMessage(InstrumentPlayer.AttachedEntity,
|
||||
@@ -226,6 +234,7 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
Owner.PopupMessage(InstrumentPlayer.AttachedEntity,
|
||||
Loc.GetString("Your fingers are seriously cramping up!"));
|
||||
}
|
||||
}
|
||||
|
||||
if (_laggedBatches > maxMidiLaggedBatches)
|
||||
{
|
||||
@@ -250,7 +259,7 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
send = false;
|
||||
}
|
||||
|
||||
if (send)
|
||||
if (send || !_respectMidiLimits)
|
||||
{
|
||||
SendNetworkMessage(midiEventMsg);
|
||||
}
|
||||
@@ -367,7 +376,7 @@ namespace Content.Server.GameObjects.Components.Instruments
|
||||
|
||||
if ((_batchesDropped >= maxMidiBatchDropped
|
||||
|| _laggedBatches >= maxMidiLaggedBatches)
|
||||
&& InstrumentPlayer != null)
|
||||
&& InstrumentPlayer != null && _respectMidiLimits)
|
||||
{
|
||||
var mob = InstrumentPlayer.AttachedEntity;
|
||||
|
||||
|
||||
@@ -11,11 +11,21 @@ namespace Content.Shared.GameObjects.Components.Instruments
|
||||
public override string Name => "Instrument";
|
||||
public override uint? NetID => ContentNetIDs.INSTRUMENTS;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual byte InstrumentProgram { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual byte InstrumentBank { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual bool AllowPercussion { get; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual bool AllowProgramChange { get ; set; }
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual bool RespectMidiLimits { get; set; }
|
||||
|
||||
public virtual void Update(float delta)
|
||||
{
|
||||
}
|
||||
@@ -61,14 +71,16 @@ namespace Content.Shared.GameObjects.Components.Instruments
|
||||
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, uint sequencerTick = 0) : base(ContentNetIDs.INSTRUMENTS)
|
||||
public InstrumentState(bool playing, byte instrumentProgram, byte instrumentBank, bool allowPercussion, bool allowProgramChange, bool respectMidiLimits, uint sequencerTick = 0) : base(ContentNetIDs.INSTRUMENTS)
|
||||
{
|
||||
Playing = playing;
|
||||
InstrumentProgram = instrumentProgram;
|
||||
InstrumentBank = instrumentBank;
|
||||
AllowPercussion = allowPercussion;
|
||||
AllowProgramChange = allowProgramChange;
|
||||
RespectMidiLimits = respectMidiLimits;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -223,3 +223,15 @@
|
||||
- type: Item
|
||||
size: 24
|
||||
sprite: Objects/Fun/Instruments/h_synthesizer.rsi
|
||||
|
||||
- type: entity
|
||||
name: super synthesizer
|
||||
suffix: no MIDI limits
|
||||
description: Blasting the ghetto with Touhou MIDIs since 2020.
|
||||
id: SuperSynthesizerUnlimitedInstrument
|
||||
parent: SuperSynthesizerInstrument
|
||||
components:
|
||||
- type: Instrument
|
||||
allowPercussion: true
|
||||
allowProgramChange: true
|
||||
respectMidiLimits: false
|
||||
|
||||
Reference in New Issue
Block a user