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

@@ -37,14 +37,12 @@ public sealed class BlockGameArcadeSystem : EntitySystem
}
}
private void UpdatePlayerStatus(EntityUid uid, ICommonSession session, PlayerBoundUserInterface? bui = null, BlockGameArcadeComponent? blockGame = null)
private void UpdatePlayerStatus(EntityUid uid, EntityUid actor, BlockGameArcadeComponent? blockGame = null)
{
if (!Resolve(uid, ref blockGame))
return;
if (bui == null && !_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out bui))
return;
_uiSystem.TrySendUiMessage(bui, new BlockGameMessages.BlockGameUserStatusMessage(blockGame.Player == session), session);
_uiSystem.ServerSendUiMessage(uid, BlockGameUiKey.Key, new BlockGameMessages.BlockGameUserStatusMessage(blockGame.Player == actor), actor);
}
private void OnComponentInit(EntityUid uid, BlockGameArcadeComponent component, ComponentInit args)
@@ -54,33 +52,21 @@ public sealed class BlockGameArcadeSystem : EntitySystem
private void OnAfterUIOpen(EntityUid uid, BlockGameArcadeComponent component, AfterActivatableUIOpenEvent args)
{
if (!TryComp<ActorComponent>(args.User, out var actor))
return;
if (!_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out var bui))
return;
var session = actor.PlayerSession;
if (!bui.SubscribedSessions.Contains(session))
return;
if (component.Player == null)
component.Player = session;
component.Player = args.Actor;
else
component.Spectators.Add(session);
component.Spectators.Add(args.Actor);
UpdatePlayerStatus(uid, session, bui, component);
component.Game?.UpdateNewPlayerUI(session);
UpdatePlayerStatus(uid, args.Actor, component);
component.Game?.UpdateNewPlayerUI(args.Actor);
}
private void OnAfterUiClose(EntityUid uid, BlockGameArcadeComponent component, BoundUIClosedEvent args)
{
if (args.Session is not { } session)
return;
if (component.Player != session)
if (component.Player != args.Actor)
{
component.Spectators.Remove(session);
UpdatePlayerStatus(uid, session, blockGame: component);
component.Spectators.Remove(args.Actor);
UpdatePlayerStatus(uid, args.Actor, blockGame: component);
return;
}
@@ -88,11 +74,11 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (component.Spectators.Count > 0)
{
component.Player = component.Spectators[0];
component.Spectators.Remove(component.Player);
UpdatePlayerStatus(uid, component.Player, blockGame: component);
component.Spectators.Remove(component.Player.Value);
UpdatePlayerStatus(uid, component.Player.Value, blockGame: component);
}
UpdatePlayerStatus(uid, temp, blockGame: component);
UpdatePlayerStatus(uid, temp.Value, blockGame: component);
}
private void OnBlockPowerChanged(EntityUid uid, BlockGameArcadeComponent component, ref PowerChangedEvent args)
@@ -100,8 +86,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
if (args.Powered)
return;
if (_uiSystem.TryGetUi(uid, BlockGameUiKey.Key, out var bui))
_uiSystem.CloseAll(bui);
_uiSystem.CloseUi(uid, BlockGameUiKey.Key);
component.Player = null;
component.Spectators.Clear();
}
@@ -112,7 +97,7 @@ public sealed class BlockGameArcadeSystem : EntitySystem
return;
if (!BlockGameUiKey.Key.Equals(msg.UiKey))
return;
if (msg.Session != component.Player)
if (msg.Actor != component.Player)
return;
if (msg.PlayerAction == BlockGamePlayerAction.NewGame)