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

@@ -67,7 +67,7 @@ public sealed partial class ParticleAcceleratorSystem
FireEmitter(comp.StarboardEmitter!.Value, strength);
}
public void SwitchOn(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
public void SwitchOn(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
@@ -77,7 +77,7 @@ public sealed partial class ParticleAcceleratorSystem
if (comp.Enabled || !comp.CanBeEnabled)
return;
if (user?.AttachedEntity is { } player)
if (user is { } player)
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} on");
comp.Enabled = true;
@@ -90,14 +90,14 @@ public sealed partial class ParticleAcceleratorSystem
UpdateUI(uid, comp);
}
public void SwitchOff(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
public void SwitchOff(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
if (!comp.Enabled)
return;
if (user?.AttachedEntity is { } player)
if (user is { } player)
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} off");
comp.Enabled = false;
@@ -138,7 +138,7 @@ public sealed partial class ParticleAcceleratorSystem
UpdateUI(uid, comp);
}
public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
public void SetStrength(EntityUid uid, ParticleAcceleratorPowerState strength, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? comp = null)
{
if (!Resolve(uid, ref comp))
return;
@@ -154,7 +154,7 @@ public sealed partial class ParticleAcceleratorSystem
if (strength == comp.SelectedStrength)
return;
if (user?.AttachedEntity is { } player)
if (user is { } player)
{
var impact = strength switch
{
@@ -235,7 +235,8 @@ public sealed partial class ParticleAcceleratorSystem
{
if (!Resolve(uid, ref comp))
return;
if (!_uiSystem.TryGetUi(uid, ParticleAcceleratorControlBoxUiKey.Key, out var bui))
if (!_uiSystem.HasUi(uid, ParticleAcceleratorControlBoxUiKey.Key))
return;
var draw = 0f;
@@ -247,7 +248,7 @@ public sealed partial class ParticleAcceleratorSystem
receive = powerConsumer.ReceivedPower;
}
_uiSystem.SetUiState(bui, new ParticleAcceleratorUIState(
_uiSystem.SetUiState(uid, ParticleAcceleratorControlBoxUiKey.Key, new ParticleAcceleratorUIState(
comp.Assembled,
comp.Enabled,
comp.SelectedStrength,
@@ -346,7 +347,7 @@ public sealed partial class ParticleAcceleratorSystem
UpdateAppearance(uid, comp);
if (!args.Powered)
_uiSystem.TryCloseAll(uid, ParticleAcceleratorControlBoxUiKey.Key);
_uiSystem.CloseUi(uid, ParticleAcceleratorControlBoxUiKey.Key);
}
private void OnUISetEnableMessage(EntityUid uid, ParticleAcceleratorControlBoxComponent comp, ParticleAcceleratorSetEnableMessage msg)
@@ -361,10 +362,10 @@ public sealed partial class ParticleAcceleratorSystem
if (msg.Enabled)
{
if (comp.Assembled)
SwitchOn(uid, msg.Session, comp);
SwitchOn(uid, msg.Actor, comp);
}
else
SwitchOff(uid, msg.Session, comp);
SwitchOff(uid, msg.Actor, comp);
UpdateUI(uid, comp);
}
@@ -378,7 +379,7 @@ public sealed partial class ParticleAcceleratorSystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return;
SetStrength(uid, msg.State, msg.Session, comp);
SetStrength(uid, msg.State, msg.Actor, comp);
UpdateUI(uid, comp);
}
@@ -392,7 +393,7 @@ public sealed partial class ParticleAcceleratorSystem
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && !apcPower.Powered)
return;
RescanParts(uid, msg.Session, comp);
RescanParts(uid, msg.Actor, comp);
UpdateUI(uid, comp);
}

View File

@@ -18,7 +18,7 @@ public sealed partial class ParticleAcceleratorSystem
SubscribeLocalEvent<ParticleAcceleratorPartComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
}
public void RescanParts(EntityUid uid, ICommonSession? user = null, ParticleAcceleratorControlBoxComponent? controller = null)
public void RescanParts(EntityUid uid, EntityUid? user = null, ParticleAcceleratorControlBoxComponent? controller = null)
{
if (!Resolve(uid, ref controller))
return;

View File

@@ -48,8 +48,7 @@ public sealed partial class ParticleAcceleratorLimiterWireAction : ComponentWire
// Yes, it's a feature that mending this wire WON'T WORK if the strength wire is also cut.
// Since that blocks SetStrength().
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
paSystem.SetStrength(wire.Owner, controller.MaxStrength, userSession, controller);
paSystem.SetStrength(wire.Owner, controller.MaxStrength, user, controller);
return true;
}

View File

@@ -33,7 +33,6 @@ public sealed partial class ParticleAcceleratorStrengthWireAction : ComponentWir
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
paSystem.SetStrength(wire.Owner, (ParticleAcceleratorPowerState) ((int) controller.SelectedStrength + 1), userSession, controller);
paSystem.SetStrength(wire.Owner, (ParticleAcceleratorPowerState) ((int) controller.SelectedStrength + 1), user, controller);
}
}

View File

@@ -23,10 +23,9 @@ public sealed partial class ParticleAcceleratorPowerWireAction : ComponentWireAc
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
controller.CanBeEnabled = false;
paSystem.SwitchOff(wire.Owner, userSession, controller);
paSystem.SwitchOff(wire.Owner, user, controller);
return true;
}
@@ -39,11 +38,10 @@ public sealed partial class ParticleAcceleratorPowerWireAction : ComponentWireAc
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
{
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
var userSession = EntityManager.TryGetComponent<ActorComponent>(user, out var actor) ? actor.PlayerSession : null;
if (controller.Enabled)
paSystem.SwitchOff(wire.Owner, userSession, controller);
paSystem.SwitchOff(wire.Owner, user, controller);
else if (controller.Assembled)
paSystem.SwitchOn(wire.Owner, userSession, controller);
paSystem.SwitchOn(wire.Owner, user, controller);
}
}