Content update for NetEntities (#18935)
This commit is contained in:
@@ -61,13 +61,13 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
private void AddToBandCommand(IConsoleShell shell, string _, string[] args)
|
||||
{
|
||||
if (!EntityUid.TryParse(args[0], out var firstUid))
|
||||
if (!NetEntity.TryParse(args[0], out var firstUidNet) || !TryGetEntity(firstUidNet, out var firstUid))
|
||||
{
|
||||
shell.WriteError($"Cannot parse first Uid");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntityUid.TryParse(args[1], out var secondUid))
|
||||
if (!NetEntity.TryParse(args[1], out var secondUidNet) || !TryGetEntity(secondUidNet, out var secondUid))
|
||||
{
|
||||
shell.WriteError($"Cannot parse second Uid");
|
||||
return;
|
||||
@@ -79,15 +79,15 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var otherInstrument = Comp<InstrumentComponent>(secondUid);
|
||||
var otherInstrument = Comp<InstrumentComponent>(secondUid.Value);
|
||||
otherInstrument.Playing = true;
|
||||
otherInstrument.Master = firstUid;
|
||||
Dirty(secondUid, otherInstrument);
|
||||
Dirty(secondUid.Value, otherInstrument);
|
||||
}
|
||||
|
||||
private void OnMidiStart(InstrumentStartMidiEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var uid = msg.Uid;
|
||||
var uid = GetEntity(msg.Uid);
|
||||
|
||||
if (!TryComp(uid, out InstrumentComponent? instrument))
|
||||
return;
|
||||
@@ -101,7 +101,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
private void OnMidiStop(InstrumentStopMidiEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var uid = msg.Uid;
|
||||
var uid = GetEntity(msg.Uid);
|
||||
|
||||
if (!TryComp(uid, out InstrumentComponent? instrument))
|
||||
return;
|
||||
@@ -114,8 +114,8 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
private void OnMidiSetMaster(InstrumentSetMasterEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var uid = msg.Uid;
|
||||
var master = msg.Master;
|
||||
var uid = GetEntity(msg.Uid);
|
||||
var master = GetEntity(msg.Master);
|
||||
|
||||
if (!HasComp<ActiveInstrumentComponent>(uid))
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
private void OnMidiSetFilteredChannel(InstrumentSetFilteredChannelEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var uid = msg.Uid;
|
||||
var uid = GetEntity(msg.Uid);
|
||||
|
||||
if (!TryComp(uid, out InstrumentComponent? instrument))
|
||||
return;
|
||||
@@ -166,7 +166,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
if (msg.Value)
|
||||
{
|
||||
// Prevent stuck notes when turning off a channel... Shrimple.
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(uid, new []{RobustMidiEvent.AllNotesOff((byte)msg.Channel, 0)}));
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(msg.Uid, new []{RobustMidiEvent.AllNotesOff((byte)msg.Channel, 0)}));
|
||||
}
|
||||
|
||||
Dirty(uid, instrument);
|
||||
@@ -215,19 +215,19 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
_bandRequestQueue.Add(args);
|
||||
}
|
||||
|
||||
public (EntityUid, string)[] GetBands(EntityUid uid)
|
||||
public (NetEntity, string)[] GetBands(EntityUid uid)
|
||||
{
|
||||
var metadataQuery = EntityManager.GetEntityQuery<MetaDataComponent>();
|
||||
|
||||
if (Deleted(uid, metadataQuery))
|
||||
return Array.Empty<(EntityUid, string)>();
|
||||
return Array.Empty<(NetEntity, string)>();
|
||||
|
||||
var list = new ValueList<(EntityUid, string)>();
|
||||
var list = new ValueList<(NetEntity, string)>();
|
||||
var instrumentQuery = EntityManager.GetEntityQuery<InstrumentComponent>();
|
||||
|
||||
if (!TryComp(uid, out InstrumentComponent? originInstrument)
|
||||
|| originInstrument.InstrumentPlayer?.AttachedEntity is not {} originPlayer)
|
||||
return Array.Empty<(EntityUid, string)>();
|
||||
return Array.Empty<(NetEntity, string)>();
|
||||
|
||||
// It's probably faster to get all possible active instruments than all entities in range
|
||||
var activeEnumerator = EntityManager.EntityQueryEnumerator<ActiveInstrumentComponent>();
|
||||
@@ -254,7 +254,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|| !metadataQuery.TryGetComponent(entity, out var metadata))
|
||||
continue;
|
||||
|
||||
list.Add((entity, $"{playerMetadata.EntityName} - {metadata.EntityName}"));
|
||||
list.Add((GetNetEntity(entity), $"{playerMetadata.EntityName} - {metadata.EntityName}"));
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
@@ -267,10 +267,12 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
if (instrument.Playing)
|
||||
{
|
||||
// Reset puppet instruments too.
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(uid, new[]{RobustMidiEvent.SystemReset(0)}));
|
||||
var netUid = GetNetEntity(uid);
|
||||
|
||||
RaiseNetworkEvent(new InstrumentStopMidiEvent(uid));
|
||||
// Reset puppet instruments too.
|
||||
RaiseNetworkEvent(new InstrumentMidiEventEvent(netUid, new[]{RobustMidiEvent.SystemReset(0)}));
|
||||
|
||||
RaiseNetworkEvent(new InstrumentStopMidiEvent(netUid));
|
||||
}
|
||||
|
||||
instrument.Playing = false;
|
||||
@@ -284,7 +286,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
private void OnMidiEventRx(InstrumentMidiEventEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
var uid = msg.Uid;
|
||||
var uid = GetEntity(msg.Uid);
|
||||
|
||||
if (!TryComp(uid, out InstrumentComponent? instrument))
|
||||
return;
|
||||
@@ -292,8 +294,10 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
if (!instrument.Playing
|
||||
|| args.SenderSession != instrument.InstrumentPlayer
|
||||
|| instrument.InstrumentPlayer == null
|
||||
|| args.SenderSession.AttachedEntity is not {} attached)
|
||||
|| args.SenderSession.AttachedEntity is not { } attached)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var send = true;
|
||||
|
||||
@@ -361,8 +365,10 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
|
||||
|
||||
foreach (var request in _bandRequestQueue)
|
||||
{
|
||||
var nearby = GetBands(request.Entity);
|
||||
_bui.TrySendUiMessage(request.Entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby),
|
||||
var entity = GetEntity(request.Entity);
|
||||
|
||||
var nearby = GetBands(entity);
|
||||
_bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby),
|
||||
(IPlayerSession)request.Session);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user