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:
@@ -41,6 +41,7 @@ namespace Content.Server.PDA
|
||||
SubscribeLocalEvent<PdaComponent, LightToggleEvent>(OnLightToggle);
|
||||
|
||||
// UI Events:
|
||||
SubscribeLocalEvent<PdaComponent, BoundUIOpenedEvent>(OnPdaOpen);
|
||||
SubscribeLocalEvent<PdaComponent, PdaRequestUpdateInterfaceMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaToggleFlashlightMessage>(OnUiMessage);
|
||||
SubscribeLocalEvent<PdaComponent, PdaShowRingtoneMessage>(OnUiMessage);
|
||||
@@ -145,7 +146,7 @@ namespace Content.Server.PDA
|
||||
if (!Resolve(uid, ref pda, false))
|
||||
return;
|
||||
|
||||
if (!_ui.TryGetUi(uid, PdaUiKey.Key, out var ui))
|
||||
if (!_ui.HasUi(uid, PdaUiKey.Key))
|
||||
return;
|
||||
|
||||
var address = GetDeviceNetAddress(uid);
|
||||
@@ -182,7 +183,15 @@ namespace Content.Server.PDA
|
||||
hasInstrument,
|
||||
address);
|
||||
|
||||
_ui.SetUiState(ui, state);
|
||||
_ui.SetUiState(uid, PdaUiKey.Key, state);
|
||||
}
|
||||
|
||||
private void OnPdaOpen(Entity<PdaComponent> ent, ref BoundUIOpenedEvent args)
|
||||
{
|
||||
if (!PdaUiKey.Key.Equals(args.UiKey))
|
||||
return;
|
||||
|
||||
UpdatePdaUi(ent.Owner, ent.Comp);
|
||||
}
|
||||
|
||||
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaRequestUpdateInterfaceMessage msg)
|
||||
@@ -208,7 +217,7 @@ namespace Content.Server.PDA
|
||||
return;
|
||||
|
||||
if (HasComp<RingerComponent>(uid))
|
||||
_ringer.ToggleRingerUI(uid, msg.Session);
|
||||
_ringer.ToggleRingerUI(uid, msg.Actor);
|
||||
}
|
||||
|
||||
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowMusicMessage msg)
|
||||
@@ -217,7 +226,7 @@ namespace Content.Server.PDA
|
||||
return;
|
||||
|
||||
if (TryComp<InstrumentComponent>(uid, out var instrument))
|
||||
_instrument.ToggleInstrumentUi(uid, msg.Session, instrument);
|
||||
_instrument.ToggleInstrumentUi(uid, msg.Actor, instrument);
|
||||
}
|
||||
|
||||
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaShowUplinkMessage msg)
|
||||
@@ -227,7 +236,7 @@ namespace Content.Server.PDA
|
||||
|
||||
// check if its locked again to prevent malicious clients opening locked uplinks
|
||||
if (TryComp<StoreComponent>(uid, out var store) && IsUnlocked(uid))
|
||||
_store.ToggleUi(msg.Session.AttachedEntity!.Value, uid, store);
|
||||
_store.ToggleUi(msg.Actor, uid, store);
|
||||
}
|
||||
|
||||
private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaLockUplinkMessage msg)
|
||||
|
||||
@@ -81,7 +81,10 @@ namespace Content.Server.PDA.Ringer
|
||||
|
||||
private void OnSetRingtone(EntityUid uid, RingerComponent ringer, RingerSetRingtoneMessage args)
|
||||
{
|
||||
ref var lastSetAt = ref CollectionsMarshal.GetValueRefOrAddDefault(_lastSetRingtoneAt, args.Session.UserId, out var exists);
|
||||
if (!TryComp(args.Actor, out ActorComponent? actorComp))
|
||||
return;
|
||||
|
||||
ref var lastSetAt = ref CollectionsMarshal.GetValueRefOrAddDefault(_lastSetRingtoneAt, actorComp.PlayerSession.UserId, out var exists);
|
||||
|
||||
// Delay on the client is 0.333, 0.25 is still enough and gives some leeway in case of small time differences
|
||||
if (exists && lastSetAt > _gameTiming.CurTime - TimeSpan.FromMilliseconds(250))
|
||||
@@ -111,7 +114,7 @@ namespace Content.Server.PDA.Ringer
|
||||
|
||||
// can't keep store open after locking it
|
||||
if (!uplink.Unlocked)
|
||||
_ui.TryCloseAll(uid, StoreUiKey.Key);
|
||||
_ui.CloseUi(uid, StoreUiKey.Key);
|
||||
|
||||
// no saving the code to prevent meta click set on sus guys pda -> wewlad
|
||||
args.Handled = true;
|
||||
@@ -130,7 +133,7 @@ namespace Content.Server.PDA.Ringer
|
||||
return;
|
||||
|
||||
uplink.Unlocked = false;
|
||||
_ui.TryCloseAll(uid, StoreUiKey.Key);
|
||||
_ui.CloseUi(uid, StoreUiKey.Key);
|
||||
}
|
||||
|
||||
public void RandomizeRingtone(EntityUid uid, RingerComponent ringer, MapInitEvent args)
|
||||
@@ -181,14 +184,12 @@ namespace Content.Server.PDA.Ringer
|
||||
|
||||
private void UpdateRingerUserInterface(EntityUid uid, RingerComponent ringer, bool isPlaying)
|
||||
{
|
||||
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
|
||||
_ui.SetUiState(bui, new RingerUpdateState(isPlaying, ringer.Ringtone));
|
||||
_ui.SetUiState(uid, RingerUiKey.Key, new RingerUpdateState(isPlaying, ringer.Ringtone));
|
||||
}
|
||||
|
||||
public bool ToggleRingerUI(EntityUid uid, ICommonSession session)
|
||||
public bool ToggleRingerUI(EntityUid uid, EntityUid actor)
|
||||
{
|
||||
if (_ui.TryGetUi(uid, RingerUiKey.Key, out var bui))
|
||||
_ui.ToggleUi(bui, session);
|
||||
_ui.TryToggleUi(uid, RingerUiKey.Key, actor);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user