Add static "IsPowered" method (#8434)
* Add static "IsPowered" method * Use IsPowered in more places Co-authored-by: wrexbe <wrexbe@protonmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Server.DeviceNetwork.Components;
|
|||||||
using Content.Server.DeviceNetwork.Systems;
|
using Content.Server.DeviceNetwork.Systems;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Wires;
|
using Content.Server.Wires;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
@@ -201,7 +202,7 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent recv) && !recv.Powered)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_uiSystem.GetUiOrNull(component.Owner, SharedAirAlarmInterfaceKey.Key)?.Open(actor.PlayerSession);
|
_uiSystem.GetUiOrNull(component.Owner, SharedAirAlarmInterfaceKey.Key)?.Open(actor.PlayerSession);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Server.DeviceNetwork;
|
|||||||
using Content.Server.DeviceNetwork.Components;
|
using Content.Server.DeviceNetwork.Components;
|
||||||
using Content.Server.DeviceNetwork.Systems;
|
using Content.Server.DeviceNetwork.Systems;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Monitor;
|
using Content.Shared.Atmos.Monitor;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -229,8 +230,7 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
|
|
||||||
private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, ref TileFireEvent args)
|
private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, ref TileFireEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
|| !powerReceiverComponent.Powered)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if we're monitoring for atmos fire, then we make it similar to a smoke detector
|
// if we're monitoring for atmos fire, then we make it similar to a smoke detector
|
||||||
@@ -252,8 +252,7 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
|
|
||||||
private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, AtmosDeviceUpdateEvent args)
|
private void OnAtmosUpdate(EntityUid uid, AtmosMonitorComponent component, AtmosDeviceUpdateEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
|| !powerReceiverComponent.Powered)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// can't hurt
|
// can't hurt
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.AlertLevel;
|
using Content.Server.AlertLevel;
|
||||||
using Content.Server.Atmos.Monitor.Components;
|
using Content.Server.Atmos.Monitor.Components;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.AlertLevel;
|
using Content.Shared.AlertLevel;
|
||||||
using Content.Shared.Atmos.Monitor;
|
using Content.Shared.Atmos.Monitor;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
@@ -27,8 +28,7 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
|
|
||||||
if (EntityManager.TryGetComponent(args.User, out ActorComponent? actor)
|
if (EntityManager.TryGetComponent(args.User, out ActorComponent? actor)
|
||||||
&& EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
|
&& EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
|
||||||
&& EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? power)
|
&& this.IsPowered(uid, EntityManager))
|
||||||
&& power.Powered)
|
|
||||||
{
|
{
|
||||||
if (monitor.HighestAlarmInNetwork == AtmosMonitorAlarmType.Normal)
|
if (monitor.HighestAlarmInNetwork == AtmosMonitorAlarmType.Normal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Buckle.Components;
|
|||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Bed;
|
using Content.Shared.Bed;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Emag.Systems;
|
using Content.Shared.Emag.Systems;
|
||||||
using Content.Shared.MobState.Components;
|
using Content.Shared.MobState.Components;
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ namespace Content.Server.Bed
|
|||||||
if (!TryComp<SharedBodyComponent>(args.BuckledEntity, out var body))
|
if (!TryComp<SharedBodyComponent>(args.BuckledEntity, out var body))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var metabolicEvent = new ApplyMetabolicMultiplierEvent()
|
var metabolicEvent = new ApplyMetabolicMultiplierEvent()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.Botany.Components;
|
using Content.Server.Botany.Components;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
@@ -22,11 +23,10 @@ public sealed class SeedExtractorSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInteractUsing(EntityUid uid, SeedExtractorComponent component, InteractUsingEvent args)
|
private void OnInteractUsing(EntityUid uid, SeedExtractorComponent component, InteractUsingEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<ApcPowerReceiverComponent>(uid, out var powerReceiverComponent) || !powerReceiverComponent.Powered)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (TryComp(args.Used, out ProduceComponent? produce))
|
if (!TryComp(args.Used, out ProduceComponent? produce)) return;
|
||||||
{
|
|
||||||
if (!_botanySystem.TryGetSeed(produce, out var seed))
|
if (!_botanySystem.TryGetSeed(produce, out var seed))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -47,4 +47,3 @@ public sealed class SeedExtractorSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.MachineLinking.Events;
|
using Content.Server.MachineLinking.Events;
|
||||||
using Content.Server.MachineLinking.System;
|
using Content.Server.MachineLinking.System;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Recycling;
|
using Content.Server.Recycling;
|
||||||
using Content.Server.Recycling.Components;
|
using Content.Server.Recycling.Components;
|
||||||
using Content.Shared.Conveyor;
|
using Content.Shared.Conveyor;
|
||||||
@@ -34,17 +35,9 @@ namespace Content.Server.Conveyor
|
|||||||
|
|
||||||
private void UpdateAppearance(ConveyorComponent component)
|
private void UpdateAppearance(ConveyorComponent component)
|
||||||
{
|
{
|
||||||
if (EntityManager.TryGetComponent<AppearanceComponent?>(component.Owner, out var appearance))
|
if (!EntityManager.TryGetComponent<AppearanceComponent?>(component.Owner, out var appearance)) return;
|
||||||
{
|
var isPowered = this.IsPowered(component.Owner, EntityManager);
|
||||||
if (EntityManager.TryGetComponent<ApcPowerReceiverComponent?>(component.Owner, out var receiver) && receiver.Powered)
|
appearance.SetData(ConveyorVisuals.State, isPowered ? component.State : ConveyorState.Off);
|
||||||
{
|
|
||||||
appearance.SetData(ConveyorVisuals.State, component.State);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
appearance.SetData(ConveyorVisuals.State, ConveyorState.Off);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSignalReceived(EntityUid uid, ConveyorComponent component, SignalReceivedEvent args)
|
private void OnSignalReceived(EntityUid uid, ConveyorComponent component, SignalReceivedEvent args)
|
||||||
@@ -74,23 +67,9 @@ namespace Content.Server.Conveyor
|
|||||||
|
|
||||||
public bool CanRun(ConveyorComponent component)
|
public bool CanRun(ConveyorComponent component)
|
||||||
{
|
{
|
||||||
if (component.State == ConveyorState.Off)
|
return component.State != ConveyorState.Off &&
|
||||||
{
|
!EntityManager.HasComponent<SharedItemComponent>(component.Owner) &&
|
||||||
return false;
|
this.IsPowered(component.Owner, EntityManager);
|
||||||
}
|
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) &&
|
|
||||||
!receiver.Powered)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EntityManager.HasComponent<SharedItemComponent>(component.Owner))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using Content.Server.Hands.Components;
|
|||||||
using Content.Server.Nutrition.EntitySystems;
|
using Content.Server.Nutrition.EntitySystems;
|
||||||
using Content.Server.Paper;
|
using Content.Server.Paper;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -139,7 +140,7 @@ namespace Content.Server.Disease
|
|||||||
if (args.Handled || !args.CanReach)
|
if (args.Handled || !args.CanReach)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (HasComp<DiseaseMachineRunningComponent>(uid) || TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
|
if (HasComp<DiseaseMachineRunningComponent>(uid) || !this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!HasComp<HandsComponent>(args.User) || HasComp<ToolComponent>(args.Used)) // Don't want to accidentally breach wrenching or whatever
|
if (!HasComp<HandsComponent>(args.User) || HasComp<ToolComponent>(args.Used)) // Don't want to accidentally breach wrenching or whatever
|
||||||
@@ -171,7 +172,7 @@ namespace Content.Server.Disease
|
|||||||
if (args.Handled || !args.CanReach)
|
if (args.Handled || !args.CanReach)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (HasComp<DiseaseMachineRunningComponent>(uid) || TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
|
if (HasComp<DiseaseMachineRunningComponent>(uid) || !this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!HasComp<HandsComponent>(args.User) || HasComp<ToolComponent>(args.Used)) //This check ensures tools don't break without yaml ordering jank
|
if (!HasComp<HandsComponent>(args.User) || HasComp<ToolComponent>(args.Used)) //This check ensures tools don't break without yaml ordering jank
|
||||||
@@ -323,8 +324,8 @@ namespace Content.Server.Disease
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void OnDiagnoserFinished(EntityUid uid, DiseaseDiagnoserComponent component, DiseaseMachineFinishedEvent args)
|
private void OnDiagnoserFinished(EntityUid uid, DiseaseDiagnoserComponent component, DiseaseMachineFinishedEvent args)
|
||||||
{
|
{
|
||||||
var power = Comp<ApcPowerReceiverComponent>(uid);
|
var isPowered = this.IsPowered(uid, EntityManager);
|
||||||
UpdateAppearance(uid, power.Powered, false);
|
UpdateAppearance(uid, isPowered, false);
|
||||||
// spawn a piece of paper.
|
// spawn a piece of paper.
|
||||||
var printed = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
var printed = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
||||||
|
|
||||||
@@ -353,8 +354,7 @@ namespace Content.Server.Disease
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
private void OnVaccinatorFinished(EntityUid uid, DiseaseVaccineCreatorComponent component, DiseaseMachineFinishedEvent args)
|
private void OnVaccinatorFinished(EntityUid uid, DiseaseVaccineCreatorComponent component, DiseaseMachineFinishedEvent args)
|
||||||
{
|
{
|
||||||
var power = Comp<ApcPowerReceiverComponent>(uid);
|
UpdateAppearance(uid, this.IsPowered(uid, EntityManager), false);
|
||||||
UpdateAppearance(uid, power.Powered, false);
|
|
||||||
|
|
||||||
// spawn a vaccine
|
// spawn a vaccine
|
||||||
var vaxx = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
var vaxx = EntityManager.SpawnEntity(args.Machine.MachineOutput, Transform(uid).Coordinates);
|
||||||
|
|||||||
@@ -183,9 +183,7 @@ namespace Content.Server.Electrocution
|
|||||||
// Does it use APC power for its electrification check? Check if it's powered, and then
|
// Does it use APC power for its electrification check? Check if it's powered, and then
|
||||||
// attempt an electrocution if all the checks succeed.
|
// attempt an electrocution if all the checks succeed.
|
||||||
|
|
||||||
if (electrified.UsesApcPower &&
|
if (electrified.UsesApcPower && !this.IsPowered(uid, EntityManager))
|
||||||
(!TryComp(uid, out ApcPowerReceiverComponent? power)
|
|
||||||
|| !power.Powered))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Content.Server.Chemistry.EntitySystems;
|
|||||||
using Content.Server.Kitchen.Components;
|
using Content.Server.Kitchen.Components;
|
||||||
using Content.Server.Kitchen.Events;
|
using Content.Server.Kitchen.Events;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
@@ -134,16 +135,14 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
switch (message.Message)
|
switch (message.Message)
|
||||||
{
|
{
|
||||||
case SharedReagentGrinderComponent.ReagentGrinderGrindStartMessage msg:
|
case SharedReagentGrinderComponent.ReagentGrinderGrindStartMessage msg:
|
||||||
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) ||
|
if (!this.IsPowered(component.Owner, EntityManager)) break;
|
||||||
!receiver.Powered) break;
|
|
||||||
ClickSound(component);
|
ClickSound(component);
|
||||||
DoWork(component, attached,
|
DoWork(component, attached,
|
||||||
SharedReagentGrinderComponent.GrinderProgram.Grind);
|
SharedReagentGrinderComponent.GrinderProgram.Grind);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SharedReagentGrinderComponent.ReagentGrinderJuiceStartMessage msg:
|
case SharedReagentGrinderComponent.ReagentGrinderJuiceStartMessage msg:
|
||||||
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver2) ||
|
if (!this.IsPowered(component.Owner, EntityManager)) break;
|
||||||
!receiver2.Powered) break;
|
|
||||||
ClickSound(component);
|
ClickSound(component);
|
||||||
DoWork(component, attached,
|
DoWork(component, attached,
|
||||||
SharedReagentGrinderComponent.GrinderProgram.Juice);
|
SharedReagentGrinderComponent.GrinderProgram.Juice);
|
||||||
@@ -206,7 +205,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
(
|
(
|
||||||
comp.Busy,
|
comp.Busy,
|
||||||
comp.BeakerSlot.HasItem,
|
comp.BeakerSlot.HasItem,
|
||||||
EntityManager.TryGetComponent(comp.Owner, out ApcPowerReceiverComponent? receiver) && receiver.Powered,
|
this.IsPowered(comp.Owner, EntityManager),
|
||||||
canJuice,
|
canJuice,
|
||||||
canGrind,
|
canGrind,
|
||||||
comp.Chamber.ContainedEntities.Select(item => item).ToArray(),
|
comp.Chamber.ContainedEntities.Select(item => item).ToArray(),
|
||||||
@@ -224,7 +223,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
SharedReagentGrinderComponent.GrinderProgram program)
|
SharedReagentGrinderComponent.GrinderProgram program)
|
||||||
{
|
{
|
||||||
//Have power, are we busy, chamber has anything to grind, a beaker for the grounds to go?
|
//Have power, are we busy, chamber has anything to grind, a beaker for the grounds to go?
|
||||||
if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered ||
|
if (!this.IsPowered(component.Owner, EntityManager) ||
|
||||||
component.Busy || component.Chamber.ContainedEntities.Count <= 0 ||
|
component.Busy || component.Chamber.ContainedEntities.Count <= 0 ||
|
||||||
component.BeakerSlot.Item is not EntityUid beakerEntity ||
|
component.BeakerSlot.Item is not EntityUid beakerEntity ||
|
||||||
component.BeakerSolution == null)
|
component.BeakerSolution == null)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Content.Shared.Interaction;
|
|||||||
using Content.Server.Materials;
|
using Content.Server.Materials;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Stack;
|
using Content.Server.Stack;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -171,7 +172,7 @@ namespace Content.Server.Lathe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TryComp<ApcPowerReceiverComponent>(component.Owner, out var receiver) && !receiver.Powered)
|
if (!this.IsPowered(component.Owner, EntityManager))
|
||||||
{
|
{
|
||||||
FinishProducing(recipe, component, false);
|
FinishProducing(recipe, component, false);
|
||||||
return;
|
return;
|
||||||
@@ -247,7 +248,7 @@ namespace Content.Server.Lathe
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void UserInterfaceOnOnReceiveMessage(EntityUid uid, LatheComponent component, ServerBoundUserInterfaceMessage message)
|
private void UserInterfaceOnOnReceiveMessage(EntityUid uid, LatheComponent component, ServerBoundUserInterfaceMessage message)
|
||||||
{
|
{
|
||||||
if (TryComp<ApcPowerReceiverComponent>(uid, out var receiver) && !receiver.Powered)
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (message.Message)
|
switch (message.Message)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Content.Server.Medical.Components;
|
|||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Preferences.Managers;
|
using Content.Server.Preferences.Managers;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.CharacterAppearance.Components;
|
using Content.Shared.CharacterAppearance.Components;
|
||||||
@@ -57,7 +58,7 @@ namespace Content.Server.Medical
|
|||||||
|
|
||||||
private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
|
private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (!IsPowered(scannerComponent))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateUserInterface(uid, scannerComponent);
|
UpdateUserInterface(uid, scannerComponent);
|
||||||
@@ -164,10 +165,8 @@ namespace Content.Server.Medical
|
|||||||
|
|
||||||
private void UpdateUserInterface(EntityUid uid, MedicalScannerComponent scannerComponent)
|
private void UpdateUserInterface(EntityUid uid, MedicalScannerComponent scannerComponent)
|
||||||
{
|
{
|
||||||
if (!IsPowered(scannerComponent))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var newState = GetUserInterfaceState(uid, scannerComponent);
|
var newState = GetUserInterfaceState(uid, scannerComponent);
|
||||||
scannerComponent.UserInterface?.SetState(newState);
|
scannerComponent.UserInterface?.SetState(newState);
|
||||||
@@ -175,7 +174,7 @@ namespace Content.Server.Medical
|
|||||||
|
|
||||||
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
|
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
|
||||||
{
|
{
|
||||||
if (IsPowered(scannerComponent))
|
if (this.IsPowered(scannerComponent.Owner, EntityManager))
|
||||||
{
|
{
|
||||||
var body = scannerComponent.BodyContainer.ContainedEntity;
|
var body = scannerComponent.BodyContainer.ContainedEntity;
|
||||||
if (body == null)
|
if (body == null)
|
||||||
@@ -191,15 +190,6 @@ namespace Content.Server.Medical
|
|||||||
return MedicalScannerStatus.Off;
|
return MedicalScannerStatus.Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPowered(MedicalScannerComponent scannerComponent)
|
|
||||||
{
|
|
||||||
if (TryComp<ApcPowerReceiverComponent>(scannerComponent.Owner, out var receiver))
|
|
||||||
{
|
|
||||||
return receiver.Powered;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsOccupied(MedicalScannerComponent scannerComponent)
|
public bool IsOccupied(MedicalScannerComponent scannerComponent)
|
||||||
{
|
{
|
||||||
return scannerComponent.BodyContainer.ContainedEntity != null;
|
return scannerComponent.BodyContainer.ContainedEntity != null;
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
private void OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
|
private void OnActivate(EntityUid uid, ActivatableUIRequiresPowerComponent component, ActivatableUIOpenAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (args.Cancelled) return;
|
if (args.Cancelled) return;
|
||||||
if (EntityManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered)
|
if (this.IsPowered(uid, EntityManager)) return;
|
||||||
{
|
|
||||||
if (TryComp<WiresComponent>(uid, out var wires) && wires.IsPanelOpen)
|
if (TryComp<WiresComponent>(uid, out var wires) && wires.IsPanelOpen)
|
||||||
return;
|
return;
|
||||||
args.User.PopupMessageCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)));
|
args.User.PopupMessageCursor(Loc.GetString("base-computer-ui-component-not-powered", ("machine", uid)));
|
||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, PowerChangedEvent args)
|
private void OnPowerChanged(EntityUid uid, ActivatableUIRequiresPowerComponent component, PowerChangedEvent args)
|
||||||
{
|
{
|
||||||
|
|||||||
13
Content.Server/Power/EntitySystems/StaticPowerSystem.cs
Normal file
13
Content.Server/Power/EntitySystems/StaticPowerSystem.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Content.Server.Power.Components;
|
||||||
|
|
||||||
|
namespace Content.Server.Power.EntitySystems;
|
||||||
|
|
||||||
|
public static class StaticPowerSystem
|
||||||
|
{
|
||||||
|
// Using this makes the call shorter.
|
||||||
|
// ReSharper disable once UnusedParameter.Global
|
||||||
|
public static bool IsPowered(this EntitySystem system, EntityUid uid, IEntityManager entManager, ApcPowerReceiverComponent? receiver = null)
|
||||||
|
{
|
||||||
|
return entManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out receiver) && receiver.Powered;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using Content.Server.GameTicking;
|
|||||||
using Content.Server.Players;
|
using Content.Server.Players;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Recycling.Components;
|
using Content.Server.Recycling.Components;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
@@ -120,9 +121,8 @@ namespace Content.Server.Recycling
|
|||||||
|
|
||||||
private bool CanGib(RecyclerComponent component, EntityUid entity)
|
private bool CanGib(RecyclerComponent component, EntityUid entity)
|
||||||
{
|
{
|
||||||
// TODO: Power needs a helper for this jeez
|
|
||||||
return HasComp<SharedBodyComponent>(entity) && !component.Safe &&
|
return HasComp<SharedBodyComponent>(entity) && !component.Safe &&
|
||||||
TryComp<ApcPowerReceiverComponent>(component.Owner, out var receiver) && receiver.Powered;
|
this.IsPowered(component.Owner, EntityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Bloodstain(RecyclerComponent component)
|
public void Bloodstain(RecyclerComponent component)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace Content.Server.Remotes
|
|||||||
public sealed class DoorRemoteSystem : EntitySystem
|
public sealed class DoorRemoteSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||||
[Dependency] private readonly SharedDoorSystem _sharedDoorSystem = default!;
|
|
||||||
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||||
[Dependency] private readonly SharedAirlockSystem _sharedAirlockSystem = default!;
|
[Dependency] private readonly SharedAirlockSystem _sharedAirlockSystem = default!;
|
||||||
@@ -49,11 +48,13 @@ namespace Content.Server.Remotes
|
|||||||
|
|
||||||
private void OnAfterInteract(EntityUid uid, DoorRemoteComponent component, AfterInteractEvent args)
|
private void OnAfterInteract(EntityUid uid, DoorRemoteComponent component, AfterInteractEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled
|
if (!args.CanReach ||
|
||||||
|
args.Handled
|
||||||
|| args.Target == null
|
|| args.Target == null
|
||||||
|| !TryComp<DoorComponent>(args.Target, out var doorComponent) // If it isn't a door we don't use it
|
|| !TryComp<DoorComponent>(args.Target, out var doorComponent) // If it isn't a door we don't use it
|
||||||
|| !HasComp<AccessReaderComponent>(args.Target) // Remotes do not work on doors without access requirements
|
|| !HasComp<AccessReaderComponent>(args.Target) // Remotes do not work on doors without access requirements
|
||||||
|| !TryComp<AirlockComponent>(args.Target, out var airlockComponent) // Remotes only work on airlocks
|
|| !TryComp<AirlockComponent>(args.Target, out var airlockComponent) // Remotes only work on airlocks
|
||||||
|
// TODO: Why the fuck is this -1f
|
||||||
|| !_interactionSystem.InRangeUnobstructed(args.User, doorComponent.Owner, -1f, CollisionGroup.Opaque))
|
|| !_interactionSystem.InRangeUnobstructed(args.User, doorComponent.Owner, -1f, CollisionGroup.Opaque))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -63,7 +64,7 @@ namespace Content.Server.Remotes
|
|||||||
|
|
||||||
if (component.Mode == DoorRemoteComponent.OperatingMode.OpenClose)
|
if (component.Mode == DoorRemoteComponent.OperatingMode.OpenClose)
|
||||||
{
|
{
|
||||||
_sharedDoorSystem.TryToggleDoor(doorComponent.Owner, user: args.Used);
|
_doorSystem.TryToggleDoor(doorComponent.Owner, user: args.Used);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component.Mode == DoorRemoteComponent.OperatingMode.ToggleBolts
|
if (component.Mode == DoorRemoteComponent.OperatingMode.ToggleBolts
|
||||||
@@ -77,11 +78,11 @@ namespace Content.Server.Remotes
|
|||||||
{
|
{
|
||||||
if (doorComponent.State != DoorState.Open)
|
if (doorComponent.State != DoorState.Open)
|
||||||
{
|
{
|
||||||
_sharedDoorSystem.Deny(airlockComponent.Owner, user: args.User);
|
_doorSystem.Deny(airlockComponent.Owner, user: args.User);
|
||||||
}
|
}
|
||||||
else if (doorComponent.DenySound != null)
|
else if (doorComponent.DenySound != null)
|
||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Pvs(args.Target.Value), doorComponent.DenySound.GetSound(), args.Target.Value);
|
SoundSystem.Play(Filter.Pvs(args.Target.Value, entityManager: EntityManager), doorComponent.DenySound.GetSound(), args.Target.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Shuttles.Components;
|
using Content.Server.Shuttles.Components;
|
||||||
using Content.Shared.ActionBlocker;
|
using Content.Shared.ActionBlocker;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
@@ -51,7 +52,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
{
|
{
|
||||||
Text = Loc.GetString("shuttle-mode-toggle"),
|
Text = Loc.GetString("shuttle-mode-toggle"),
|
||||||
Act = () => ToggleShuttleMode(args.User, component, shuttle),
|
Act = () => ToggleShuttleMode(args.User, component, shuttle),
|
||||||
Disabled = !xform.Anchored || EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered,
|
Disabled = !xform.Anchored || !this.IsPowered(uid, EntityManager),
|
||||||
};
|
};
|
||||||
|
|
||||||
args.Verbs.Add(verb);
|
args.Verbs.Add(verb);
|
||||||
@@ -60,7 +61,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
private void ToggleShuttleMode(EntityUid user, ShuttleConsoleComponent consoleComponent, ShuttleComponent shuttleComponent, TransformComponent? consoleXform = null)
|
private void ToggleShuttleMode(EntityUid user, ShuttleConsoleComponent consoleComponent, ShuttleComponent shuttleComponent, TransformComponent? consoleXform = null)
|
||||||
{
|
{
|
||||||
// Re-validate
|
// Re-validate
|
||||||
if (EntityManager.TryGetComponent(consoleComponent.Owner, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) return;
|
if (!this.IsPowered(consoleComponent.Owner, EntityManager)) return;
|
||||||
|
|
||||||
if (!Resolve(consoleComponent.Owner, ref consoleXform)) return;
|
if (!Resolve(consoleComponent.Owner, ref consoleXform)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Linq;
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Content.Server.Audio;
|
using Content.Server.Audio;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Server.Shuttles.Components;
|
using Content.Server.Shuttles.Components;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
@@ -367,8 +368,7 @@ namespace Content.Server.Shuttles.EntitySystems
|
|||||||
|
|
||||||
var xform = Transform(uid);
|
var xform = Transform(uid);
|
||||||
|
|
||||||
if (!xform.Anchored ||
|
if (!xform.Anchored ||!this.IsPowered(uid, EntityManager))
|
||||||
EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? receiver) && !receiver.Powered)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Server.VendingMachines.Systems;
|
|
||||||
using Content.Server.Wires;
|
using Content.Server.Wires;
|
||||||
using Content.Shared.VendingMachines;
|
using Content.Shared.VendingMachines;
|
||||||
using Content.Shared.Wires;
|
using Content.Shared.Wires;
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
using Robust.Shared.Audio;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
using Content.Shared.VendingMachines;
|
|
||||||
using Robust.Server.GameObjects;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Robust.Shared.Random;
|
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.Emag.Systems;
|
using Content.Shared.Emag.Systems;
|
||||||
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
|
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
|
using Content.Shared.VendingMachines;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
|
||||||
|
|
||||||
namespace Content.Server.VendingMachines.Systems
|
namespace Content.Server.VendingMachines
|
||||||
{
|
{
|
||||||
public sealed class VendingMachineSystem : EntitySystem
|
public sealed class VendingMachineSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -49,7 +50,7 @@ namespace Content.Server.VendingMachines.Systems
|
|||||||
|
|
||||||
private void OnInventoryRequestMessage(EntityUid uid, VendingMachineComponent component, InventorySyncRequestMessage args)
|
private void OnInventoryRequestMessage(EntityUid uid, VendingMachineComponent component, InventorySyncRequestMessage args)
|
||||||
{
|
{
|
||||||
if (!IsPowered(uid, component))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var inventory = new List<VendingMachineInventoryEntry>(component.Inventory);
|
var inventory = new List<VendingMachineInventoryEntry>(component.Inventory);
|
||||||
@@ -62,7 +63,7 @@ namespace Content.Server.VendingMachines.Systems
|
|||||||
|
|
||||||
private void OnInventoryEjectMessage(EntityUid uid, VendingMachineComponent component, VendingMachineEjectMessage args)
|
private void OnInventoryEjectMessage(EntityUid uid, VendingMachineComponent component, VendingMachineEjectMessage args)
|
||||||
{
|
{
|
||||||
if (!IsPowered(uid, component))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (args.Session.AttachedEntity is not { Valid: true } entity || Deleted(entity))
|
if (args.Session.AttachedEntity is not { Valid: true } entity || Deleted(entity))
|
||||||
@@ -91,18 +92,6 @@ namespace Content.Server.VendingMachines.Systems
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPowered(EntityUid uid, VendingMachineComponent? vendComponent = null)
|
|
||||||
{
|
|
||||||
if (!Resolve(uid, ref vendComponent))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!TryComp<ApcPowerReceiverComponent>(vendComponent.Owner, out var receiver))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return receiver.Powered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeFromPrototype(EntityUid uid, VendingMachineComponent? vendComponent = null)
|
public void InitializeFromPrototype(EntityUid uid, VendingMachineComponent? vendComponent = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref vendComponent))
|
if (!Resolve(uid, ref vendComponent))
|
||||||
@@ -201,7 +190,7 @@ namespace Content.Server.VendingMachines.Systems
|
|||||||
if (!Resolve(uid, ref vendComponent))
|
if (!Resolve(uid, ref vendComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vendComponent.Ejecting || vendComponent.Broken || !IsPowered(uid, vendComponent))
|
if (vendComponent.Ejecting || vendComponent.Broken || !this.IsPowered(uid, EntityManager))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -276,7 +265,7 @@ namespace Content.Server.VendingMachines.Systems
|
|||||||
{
|
{
|
||||||
finalState = VendingMachineVisualState.Eject;
|
finalState = VendingMachineVisualState.Eject;
|
||||||
}
|
}
|
||||||
else if (!IsPowered(uid, vendComponent))
|
else if (!this.IsPowered(uid, EntityManager))
|
||||||
{
|
{
|
||||||
finalState = VendingMachineVisualState.Off;
|
finalState = VendingMachineVisualState.Off;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Wires;
|
using Content.Shared.Wires;
|
||||||
|
|
||||||
namespace Content.Server.Wires;
|
namespace Content.Server.Wires;
|
||||||
@@ -17,7 +18,7 @@ public abstract class BaseWireAction : IWireAction
|
|||||||
{
|
{
|
||||||
EntityManager = IoCManager.Resolve<IEntityManager>();
|
EntityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
WiresSystem = EntitySystem.Get<WiresSystem>();
|
WiresSystem = EntityManager.EntitySysManager.GetEntitySystem<WiresSystem>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool AddWire(Wire wire, int count) => count == 1;
|
public virtual bool AddWire(Wire wire, int count) => count == 1;
|
||||||
@@ -38,14 +39,8 @@ public abstract class BaseWireAction : IWireAction
|
|||||||
/// Utility function to check if this given entity is powered.
|
/// Utility function to check if this given entity is powered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>true if powered, false otherwise</returns>
|
/// <returns>true if powered, false otherwise</returns>
|
||||||
public bool IsPowered(EntityUid uid)
|
protected bool IsPowered(EntityUid uid)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent<ApcPowerReceiverComponent>(uid, out var power)
|
return WiresSystem.IsPowered(uid, EntityManager);
|
||||||
|| power.PowerDisabled) // there's some kind of race condition here?
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return power.Powered;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user