PA ui cleanup + bugfixes (#28750)
* ui and visual aspect + radio * finish jank ui shit and finish radio * remove radio * send it --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class ParticleAcceleratorEmitterComponent : Component
|
||||
{
|
||||
[DataField("emittedPrototype")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string EmittedPrototype = "ParticlesProjectile";
|
||||
[DataField]
|
||||
public EntProtoId EmittedPrototype = "ParticlesProjectile";
|
||||
|
||||
[DataField("emitterType")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
|
||||
@@ -101,6 +101,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} has turned {ToPrettyString(uid)} off");
|
||||
|
||||
comp.Enabled = false;
|
||||
SetStrength(uid, ParticleAcceleratorPowerState.Standby, user, comp);
|
||||
UpdatePowerDraw(uid, comp);
|
||||
PowerOff(uid, comp);
|
||||
UpdateUI(uid, comp);
|
||||
@@ -174,12 +175,14 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
var pos = Transform(uid);
|
||||
if (_timing.CurTime > comp.EffectCooldown)
|
||||
{
|
||||
_chat.SendAdminAlert(player, Loc.GetString("particle-accelerator-admin-power-strength-warning",
|
||||
_chat.SendAdminAlert(player,
|
||||
Loc.GetString("particle-accelerator-admin-power-strength-warning",
|
||||
("machine", ToPrettyString(uid)),
|
||||
("powerState", strength),
|
||||
("powerState", GetPANumericalLevel(strength)),
|
||||
("coordinates", pos.Coordinates)));
|
||||
_audio.PlayGlobal("/Audio/Misc/adminlarm.ogg",
|
||||
Filter.Empty().AddPlayers(_adminManager.ActiveAdmins), false,
|
||||
Filter.Empty().AddPlayers(_adminManager.ActiveAdmins),
|
||||
false,
|
||||
AudioParams.Default.WithVolume(-8f));
|
||||
comp.EffectCooldown = _timing.CurTime + comp.CooldownDuration;
|
||||
}
|
||||
@@ -230,7 +233,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
powerConsumer.DrawRate = powerDraw;
|
||||
}
|
||||
|
||||
private void UpdateUI(EntityUid uid, ParticleAcceleratorControlBoxComponent? comp = null)
|
||||
public void UpdateUI(EntityUid uid, ParticleAcceleratorControlBoxComponent? comp = null)
|
||||
{
|
||||
if (!Resolve(uid, ref comp))
|
||||
return;
|
||||
@@ -247,7 +250,9 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
receive = powerConsumer.ReceivedPower;
|
||||
}
|
||||
|
||||
_uiSystem.SetUiState(uid, ParticleAcceleratorControlBoxUiKey.Key, new ParticleAcceleratorUIState(
|
||||
_uiSystem.SetUiState(uid,
|
||||
ParticleAcceleratorControlBoxUiKey.Key,
|
||||
new ParticleAcceleratorUIState(
|
||||
comp.Assembled,
|
||||
comp.Enabled,
|
||||
comp.SelectedStrength,
|
||||
@@ -396,4 +401,16 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
|
||||
UpdateUI(uid, comp);
|
||||
}
|
||||
|
||||
public static int GetPANumericalLevel(ParticleAcceleratorPowerState state)
|
||||
{
|
||||
return state switch
|
||||
{
|
||||
ParticleAcceleratorPowerState.Level0 => 1,
|
||||
ParticleAcceleratorPowerState.Level1 => 2,
|
||||
ParticleAcceleratorPowerState.Level2 => 3,
|
||||
ParticleAcceleratorPowerState.Level3 => 4,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.EntitySystems;
|
||||
|
||||
@@ -26,8 +24,6 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
if (controller.CurrentlyRescanning)
|
||||
return;
|
||||
|
||||
SwitchOff(uid, user, controller);
|
||||
|
||||
var partQuery = GetEntityQuery<ParticleAcceleratorPartComponent>();
|
||||
foreach (var part in AllParts(uid, controller))
|
||||
{
|
||||
@@ -45,19 +41,25 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
|
||||
var xformQuery = GetEntityQuery<TransformComponent>();
|
||||
if (!xformQuery.TryGetComponent(uid, out var xform) || !xform.Anchored)
|
||||
{
|
||||
SwitchOff(uid, user, controller);
|
||||
return;
|
||||
}
|
||||
|
||||
var gridUid = xform.GridUid;
|
||||
if (gridUid == null || gridUid != xform.ParentUid || !TryComp<MapGridComponent>(gridUid, out var grid))
|
||||
{
|
||||
SwitchOff(uid, user, controller);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find fuel chamber first by scanning cardinals.
|
||||
var fuelQuery = GetEntityQuery<ParticleAcceleratorFuelChamberComponent>();
|
||||
foreach (var adjacent in _mapSystem.GetCardinalNeighborCells(gridUid.Value, grid, xform.Coordinates))
|
||||
{
|
||||
if (fuelQuery.HasComponent(adjacent)
|
||||
&& partQuery.TryGetComponent(adjacent, out var partState)
|
||||
&& partState.Master == null)
|
||||
&& partQuery.TryGetComponent(adjacent, out var partState)
|
||||
&& partState.Master == null)
|
||||
{
|
||||
controller.FuelChamber = adjacent;
|
||||
break;
|
||||
@@ -66,7 +68,7 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
|
||||
if (controller.FuelChamber == null)
|
||||
{
|
||||
UpdateUI(uid, controller);
|
||||
SwitchOff(uid, user, controller);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,19 +95,19 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
var positionForeEmitter = positionFuelChamber + offsetVect * 2;
|
||||
var positionStarboardEmitter = positionFuelChamber + offsetVect * 2 - orthoOffsetVect;
|
||||
|
||||
ScanPart<ParticleAcceleratorEndCapComponent>(gridUid!.Value, positionEndCap, rotation, out controller.EndCap, out var _, grid);
|
||||
ScanPart<ParticleAcceleratorPowerBoxComponent>(gridUid!.Value, positionPowerBox, rotation, out controller.PowerBox, out var _, grid);
|
||||
ScanPart<ParticleAcceleratorEndCapComponent>(gridUid.Value, positionEndCap, rotation, out controller.EndCap, out _, grid);
|
||||
ScanPart<ParticleAcceleratorPowerBoxComponent>(gridUid.Value, positionPowerBox, rotation, out controller.PowerBox, out _, grid);
|
||||
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid!.Value, positionPortEmitter, rotation, out controller.PortEmitter, out var portEmitter, grid)
|
||||
|| portEmitter!.Type != ParticleAcceleratorEmitterType.Port)
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid.Value, positionPortEmitter, rotation, out controller.PortEmitter, out var portEmitter, grid)
|
||||
|| portEmitter.Type != ParticleAcceleratorEmitterType.Port)
|
||||
controller.PortEmitter = null;
|
||||
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid!.Value, positionForeEmitter, rotation, out controller.ForeEmitter, out var foreEmitter, grid)
|
||||
|| foreEmitter!.Type != ParticleAcceleratorEmitterType.Fore)
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid.Value, positionForeEmitter, rotation, out controller.ForeEmitter, out var foreEmitter, grid)
|
||||
|| foreEmitter.Type != ParticleAcceleratorEmitterType.Fore)
|
||||
controller.ForeEmitter = null;
|
||||
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid!.Value, positionStarboardEmitter, rotation, out controller.StarboardEmitter, out var starboardEmitter, grid)
|
||||
|| starboardEmitter!.Type != ParticleAcceleratorEmitterType.Starboard)
|
||||
if (!ScanPart<ParticleAcceleratorEmitterComponent>(gridUid.Value, positionStarboardEmitter, rotation, out controller.StarboardEmitter, out var starboardEmitter, grid)
|
||||
|| starboardEmitter.Type != ParticleAcceleratorEmitterType.Starboard)
|
||||
controller.StarboardEmitter = null;
|
||||
|
||||
controller.Assembled =
|
||||
@@ -157,19 +159,19 @@ public sealed partial class ParticleAcceleratorSystem
|
||||
|
||||
private void OnComponentShutdown(EntityUid uid, ParticleAcceleratorPartComponent comp, ComponentShutdown args)
|
||||
{
|
||||
if (EntityManager.EntityExists(comp.Master))
|
||||
if (Exists(comp.Master))
|
||||
RescanParts(comp.Master!.Value);
|
||||
}
|
||||
|
||||
private void BodyTypeChanged(EntityUid uid, ParticleAcceleratorPartComponent comp, ref PhysicsBodyTypeChangedEvent args)
|
||||
{
|
||||
if (EntityManager.EntityExists(comp.Master))
|
||||
if (Exists(comp.Master))
|
||||
RescanParts(comp.Master!.Value);
|
||||
}
|
||||
|
||||
private void OnMoveEvent(EntityUid uid, ParticleAcceleratorPartComponent comp, ref MoveEvent args)
|
||||
{
|
||||
if (EntityManager.EntityExists(comp.Master))
|
||||
if (Exists(comp.Master))
|
||||
RescanParts(comp.Master!.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.ParticleAccelerator.EntitySystems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
@@ -19,12 +20,16 @@ public sealed partial class ParticleAcceleratorKeyboardWireAction : ComponentWir
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.InterfaceDisabled = true;
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.InterfaceDisabled = false;
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Server.Wires;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Wires;
|
||||
|
||||
@@ -35,6 +34,8 @@ public sealed partial class ParticleAcceleratorLimiterWireAction : ComponentWire
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.MaxStrength = ParticleAcceleratorPowerState.Level3;
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,12 +50,14 @@ public sealed partial class ParticleAcceleratorLimiterWireAction : ComponentWire
|
||||
// Since that blocks SetStrength().
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.SetStrength(wire.Owner, controller.MaxStrength, user, controller);
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
EntityManager.System<PopupSystem>().PopupEntity(
|
||||
EntityManager.System<PopupSystem>()
|
||||
.PopupEntity(
|
||||
Loc.GetString("particle-accelerator-control-box-component-wires-update-limiter-on-pulse"),
|
||||
user,
|
||||
PopupType.SmallCaution
|
||||
|
||||
@@ -21,12 +21,16 @@ public sealed partial class ParticleAcceleratorStrengthWireAction : ComponentWir
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.StrengthLocked = true;
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.StrengthLocked = false;
|
||||
var paSystem = EntityManager.System<ParticleAcceleratorSystem>();
|
||||
paSystem.UpdateUI(wire.Owner, controller);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user