Remove instruments compref (#19560)

This commit is contained in:
metalgearsloth
2023-09-12 14:43:06 +10:00
committed by GitHub
parent f05f94fdc0
commit fd60d39bc7
7 changed files with 94 additions and 27 deletions

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Audio.Midi;
using Robust.Shared.Collections;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.GameStates;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -55,9 +56,26 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
SubscribeLocalEvent<InstrumentComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
SubscribeLocalEvent<InstrumentComponent, InstrumentBandRequestBuiMessage>(OnBoundUIRequestBands);
SubscribeLocalEvent<InstrumentComponent, ComponentGetState>(OnStrumentGetState);
_conHost.RegisterCommand("addtoband", AddToBandCommand);
}
private void OnStrumentGetState(EntityUid uid, InstrumentComponent component, ref ComponentGetState args)
{
args.State = new InstrumentComponentState()
{
Playing = component.Playing,
InstrumentProgram = component.InstrumentProgram,
InstrumentBank = component.InstrumentBank,
AllowPercussion = component.AllowPercussion,
AllowProgramChange = component.AllowProgramChange,
RespectMidiLimits = component.RespectMidiLimits,
Master = GetNetEntity(component.Master),
FilteredChannels = component.FilteredChannels
};
}
[AdminCommand(AdminFlags.Fun)]
private void AddToBandCommand(IConsoleShell shell, string _, string[] args)
{
@@ -441,4 +459,14 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (_bui.TryGetUi(uid, InstrumentUiKey.Key, out var bui))
_bui.ToggleUi(bui, session);
}
public override bool ResolveInstrument(EntityUid uid, ref SharedInstrumentComponent? component)
{
if (component is not null)
return true;
TryComp<InstrumentComponent>(uid, out var localComp);
component = localComp;
return component != null;
}
}