Content update for UI prediction (#27214)

* Content update for UI refactor

* Big update

* Sharing

* Remaining content updates

* First big update

* Prototype updates

* AUGH

* Fix UI comp ref

* Cleanup

- Fix predicted message, fix item slots, fix interaction range check.

* Fix regressions

* Make this predictive

idk why it wasn't.

* Fix slime merge

* Merge conflict

* Fix merge
This commit is contained in:
metalgearsloth
2024-04-26 18:16:24 +10:00
committed by GitHub
parent 32b81de8c5
commit 5896e68752
279 changed files with 1308 additions and 1582 deletions

View File

@@ -111,7 +111,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument))
return;
if (args.SenderSession != instrument.InstrumentPlayer)
if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return;
instrument.Playing = true;
@@ -125,7 +125,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument))
return;
if (args.SenderSession != instrument.InstrumentPlayer)
if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return;
Clean(uid, instrument);
@@ -142,7 +142,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument))
return;
if (args.SenderSession != instrument.InstrumentPlayer)
if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return;
if (master != null)
@@ -174,7 +174,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
if (!TryComp(uid, out InstrumentComponent? instrument))
return;
if (args.SenderSession != instrument.InstrumentPlayer)
if (args.SenderSession.AttachedEntity != instrument.InstrumentPlayer)
return;
if (msg.Channel == RobustMidiEvent.PercussionChannel && !instrument.AllowPercussion)
@@ -194,8 +194,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
private void OnBoundUIClosed(EntityUid uid, InstrumentComponent component, BoundUIClosedEvent args)
{
if (HasComp<ActiveInstrumentComponent>(uid)
&& _bui.TryGetUi(uid, args.UiKey, out var bui)
&& bui.SubscribedSessions.Count == 0)
&& !_bui.IsUiOpen(uid, args.UiKey))
{
RemComp<ActiveInstrumentComponent>(uid);
}
@@ -232,7 +231,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
var instrumentQuery = EntityManager.GetEntityQuery<InstrumentComponent>();
if (!TryComp(uid, out InstrumentComponent? originInstrument)
|| originInstrument.InstrumentPlayer?.AttachedEntity is not {} originPlayer)
|| originInstrument.InstrumentPlayer is not {} originPlayer)
return Array.Empty<(NetEntity, string)>();
// It's probably faster to get all possible active instruments than all entities in range
@@ -247,7 +246,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
continue;
// We want to use the instrument player's name.
if (instrument.InstrumentPlayer?.AttachedEntity is not {} playerUid)
if (instrument.InstrumentPlayer is not {} playerUid)
continue;
// Maybe a bit expensive but oh well GetBands is queued and has a timer anyway.
@@ -298,7 +297,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
return;
if (!instrument.Playing
|| args.SenderSession != instrument.InstrumentPlayer
|| args.SenderSession.AttachedEntity != instrument.InstrumentPlayer
|| instrument.InstrumentPlayer == null
|| args.SenderSession.AttachedEntity is not { } attached)
{
@@ -374,8 +373,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
var entity = GetEntity(request.Entity);
var nearby = GetBands(entity);
_bui.TrySendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby),
request.Session);
_bui.ServerSendUiMessage(entity, request.UiKey, new InstrumentBandResponseBuiMessage(nearby), request.Actor);
}
_bandRequestQueue.Clear();
@@ -413,7 +411,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
(instrument.BatchesDropped >= MaxMidiBatchesDropped
|| instrument.LaggedBatches >= MaxMidiLaggedBatches))
{
if (instrument.InstrumentPlayer?.AttachedEntity is {Valid: true} mob)
if (instrument.InstrumentPlayer is {Valid: true} mob)
{
_stuns.TryParalyze(mob, TimeSpan.FromSeconds(1), true);
@@ -423,7 +421,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
// Just in case
Clean(uid);
_bui.TryCloseAll(uid, InstrumentUiKey.Key);
_bui.CloseUi(uid, InstrumentUiKey.Key);
}
instrument.Timer += frameTime;
@@ -437,13 +435,12 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
}
}
public void ToggleInstrumentUi(EntityUid uid, ICommonSession session, InstrumentComponent? component = null)
public void ToggleInstrumentUi(EntityUid uid, EntityUid actor, InstrumentComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
if (_bui.TryGetUi(uid, InstrumentUiKey.Key, out var bui))
_bui.ToggleUi(bui, session);
_bui.TryToggleUi(uid, InstrumentUiKey.Key, actor);
}
public override bool ResolveInstrument(EntityUid uid, ref SharedInstrumentComponent? component)