Converts the particle accelerator over to ECS + misc (#17075)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Wires;
|
||||
|
||||
public sealed class ParticleAcceleratorKeyboardWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
|
||||
{
|
||||
public override string Name { get; set; } = "wire-name-pa-keyboard";
|
||||
public override Color Color { get; set; } = Color.LimeGreen;
|
||||
public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Keyboard;
|
||||
|
||||
public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
|
||||
{
|
||||
return component.InterfaceDisabled ? StatusLightState.BlinkingFast : StatusLightState.On;
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.InterfaceDisabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.InterfaceDisabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.InterfaceDisabled = !controller.InterfaceDisabled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.ParticleAccelerator.EntitySystems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Wires;
|
||||
|
||||
public sealed class ParticleAcceleratorLimiterWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
|
||||
{
|
||||
public override string Name { get; set; } = "wire-name-pa-limiter";
|
||||
public override Color Color { get; set; } = Color.Teal;
|
||||
public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Limiter;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var result = base.GetStatusLightData(wire);
|
||||
|
||||
if (result.HasValue
|
||||
&& EntityManager.TryGetComponent<ParticleAcceleratorControlBoxComponent>(wire.Owner, out var controller)
|
||||
&& controller.MaxStrength >= ParticleAcceleratorPowerState.Level3)
|
||||
result = new(Color.Purple, result.Value.State, result.Value.Text);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
|
||||
{
|
||||
return StatusLightState.On;
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.MaxStrength = ParticleAcceleratorPowerState.Level3;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
|
||||
controller.MaxStrength = ParticleAcceleratorPowerState.Level2;
|
||||
if (controller.SelectedStrength <= controller.MaxStrength || controller.StrengthLocked)
|
||||
return true;
|
||||
|
||||
// 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);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Pulse(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
EntityManager.System<PopupSystem>().PopupEntity(
|
||||
Loc.GetString("particle-accelerator-control-box-component-wires-update-limiter-on-pulse"),
|
||||
user,
|
||||
PopupType.SmallCaution
|
||||
);
|
||||
}
|
||||
|
||||
public override void Update(Wire wire)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.ParticleAccelerator.EntitySystems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Wires;
|
||||
|
||||
public sealed class ParticleAcceleratorStrengthWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
|
||||
{
|
||||
public override string Name { get; set; } = "wire-name-pa-strength";
|
||||
public override Color Color { get; set; } = Color.Blue;
|
||||
public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Strength;
|
||||
|
||||
public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
|
||||
{
|
||||
return component.StrengthLocked ? StatusLightState.BlinkingSlow : StatusLightState.On;
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.StrengthLocked = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.StrengthLocked = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Content.Server.ParticleAccelerator.Components;
|
||||
using Content.Server.ParticleAccelerator.EntitySystems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Singularity.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
namespace Content.Server.ParticleAccelerator.Wires;
|
||||
|
||||
public sealed class ParticleAcceleratorPowerWireAction : ComponentWireAction<ParticleAcceleratorControlBoxComponent>
|
||||
{
|
||||
public override string Name { get; set; } = "wire-name-pa-power";
|
||||
public override Color Color { get; set; } = Color.Yellow;
|
||||
public override object StatusKey { get; } = ParticleAcceleratorWireStatus.Power;
|
||||
|
||||
public override StatusLightState? GetLightState(Wire wire, ParticleAcceleratorControlBoxComponent component)
|
||||
{
|
||||
if (!component.CanBeEnabled)
|
||||
return StatusLightState.Off;
|
||||
return component.Enabled ? StatusLightState.On : StatusLightState.BlinkingSlow;
|
||||
}
|
||||
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire, ParticleAcceleratorControlBoxComponent controller)
|
||||
{
|
||||
controller.CanBeEnabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
else if (controller.Assembled)
|
||||
paSystem.SwitchOn(wire.Owner, userSession, controller);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user