Add power debug verbs (#14212)
This commit is contained in:
@@ -57,6 +57,14 @@ namespace Content.Server.Administration.Managers
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
|
||||||
|
{
|
||||||
|
if (_playerManager.TryGetSessionByEntity(uid, out var session) && session is IPlayerSession playerSession)
|
||||||
|
return GetAdminData(playerSession, includeDeAdmin);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void DeAdmin(IPlayerSession session)
|
public void DeAdmin(IPlayerSession session)
|
||||||
{
|
{
|
||||||
if (!_admins.TryGetValue(session, out var reg))
|
if (!_admins.TryGetValue(session, out var reg))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
|
|
||||||
|
|
||||||
@@ -47,6 +47,26 @@ namespace Content.Server.Administration.Managers
|
|||||||
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
||||||
AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false);
|
AdminData? GetAdminData(IPlayerSession session, bool includeDeAdmin = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the admin data for a player, if they are an admin.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid">The entity being controlled by the player.</param>
|
||||||
|
/// <param name="includeDeAdmin">
|
||||||
|
/// Whether to return admin data for admins that are current de-adminned.
|
||||||
|
/// </param>
|
||||||
|
/// <returns><see langword="null" /> if the player is not an admin.</returns>
|
||||||
|
AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// See if a player has an admin flag.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if the player is and admin and has the specified flags.</returns>
|
||||||
|
bool HasAdminFlag(EntityUid player, AdminFlags flag)
|
||||||
|
{
|
||||||
|
var data = GetAdminData(player);
|
||||||
|
return data != null && data.HasFlag(flag);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// See if a player has an admin flag.
|
/// See if a player has an admin flag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Server.Cargo.Systems;
|
using Content.Server.Cargo.Systems;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace Content.Server.Power.EntitySystems
|
namespace Content.Server.Power.EntitySystems
|
||||||
@@ -13,12 +14,24 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ExaminableBatteryComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<ExaminableBatteryComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<PowerNetworkBatteryComponent, RejuvenateEvent>(OnNetBatteryRejuvenate);
|
||||||
|
SubscribeLocalEvent<BatteryComponent, RejuvenateEvent>(OnBatteryRejuvenate);
|
||||||
SubscribeLocalEvent<BatteryComponent, PriceCalculationEvent>(CalculateBatteryPrice);
|
SubscribeLocalEvent<BatteryComponent, PriceCalculationEvent>(CalculateBatteryPrice);
|
||||||
|
|
||||||
SubscribeLocalEvent<NetworkBatteryPreSync>(PreSync);
|
SubscribeLocalEvent<NetworkBatteryPreSync>(PreSync);
|
||||||
SubscribeLocalEvent<NetworkBatteryPostSync>(PostSync);
|
SubscribeLocalEvent<NetworkBatteryPostSync>(PostSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnNetBatteryRejuvenate(EntityUid uid, PowerNetworkBatteryComponent component, RejuvenateEvent args)
|
||||||
|
{
|
||||||
|
component.NetworkBattery.CurrentStorage = component.NetworkBattery.Capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBatteryRejuvenate(EntityUid uid, BatteryComponent component, RejuvenateEvent args)
|
||||||
|
{
|
||||||
|
component.CurrentCharge = component.MaxCharge;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, ExaminableBatteryComponent component, ExaminedEvent args)
|
private void OnExamine(EntityUid uid, ExaminableBatteryComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<BatteryComponent>(uid, out var batteryComponent))
|
if (!TryComp<BatteryComponent>(uid, out var batteryComponent))
|
||||||
|
|||||||
@@ -7,14 +7,18 @@ using Content.Shared.Verbs;
|
|||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
using Content.Server.Administration.Managers;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
|
||||||
namespace Content.Server.Power.EntitySystems
|
namespace Content.Server.Power.EntitySystems
|
||||||
{
|
{
|
||||||
public sealed class PowerReceiverSystem : EntitySystem
|
public sealed class PowerReceiverSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||||
[Dependency] private readonly AudioSystem _audio = default!;
|
[Dependency] private readonly AudioSystem _audio = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -27,9 +31,25 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
SubscribeLocalEvent<ApcPowerProviderComponent, ExtensionCableSystem.ReceiverConnectedEvent>(OnReceiverConnected);
|
SubscribeLocalEvent<ApcPowerProviderComponent, ExtensionCableSystem.ReceiverConnectedEvent>(OnReceiverConnected);
|
||||||
SubscribeLocalEvent<ApcPowerProviderComponent, ExtensionCableSystem.ReceiverDisconnectedEvent>(OnReceiverDisconnected);
|
SubscribeLocalEvent<ApcPowerProviderComponent, ExtensionCableSystem.ReceiverDisconnectedEvent>(OnReceiverDisconnected);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<ApcPowerReceiverComponent, GetVerbsEvent<Verb>>(OnGetVerbs);
|
||||||
SubscribeLocalEvent<PowerSwitchComponent, GetVerbsEvent<AlternativeVerb>>(AddSwitchPowerVerb);
|
SubscribeLocalEvent<PowerSwitchComponent, GetVerbsEvent<AlternativeVerb>>(AddSwitchPowerVerb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGetVerbs(EntityUid uid, ApcPowerReceiverComponent component, GetVerbsEvent<Verb> args)
|
||||||
|
{
|
||||||
|
if (!_adminManager.HasAdminFlag(args.User, AdminFlags.Admin))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// add debug verb to toggle power requirements
|
||||||
|
args.Verbs.Add(new()
|
||||||
|
{
|
||||||
|
Text = Loc.GetString("verb-debug-toggle-need-power"),
|
||||||
|
Category = VerbCategory.Debug,
|
||||||
|
IconTexture = "/Textures/Interface/VerbIcons/smite.svg.192dpi.png", // "smite" is a lightning bolt
|
||||||
|
Act = () => component.NeedsPower = !component.NeedsPower
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you.
|
///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you.
|
||||||
///</summary>
|
///</summary>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Robust.Shared.Containers;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Server.Kitchen.Components;
|
using Content.Server.Kitchen.Components;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
|
|
||||||
namespace Content.Server.PowerCell;
|
namespace Content.Server.PowerCell;
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<PowerCellComponent, ChargeChangedEvent>(OnChargeChanged);
|
SubscribeLocalEvent<PowerCellComponent, ChargeChangedEvent>(OnChargeChanged);
|
||||||
SubscribeLocalEvent<PowerCellComponent, SolutionChangedEvent>(OnSolutionChange);
|
SubscribeLocalEvent<PowerCellComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||||
|
SubscribeLocalEvent<PowerCellComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
|
|
||||||
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
SubscribeLocalEvent<PowerCellComponent, ExaminedEvent>(OnCellExamined);
|
||||||
|
|
||||||
@@ -37,6 +39,11 @@ public sealed class PowerCellSystem : SharedPowerCellSystem
|
|||||||
SubscribeLocalEvent<BatteryComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
SubscribeLocalEvent<BatteryComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRejuvenate(EntityUid uid, PowerCellComponent component, RejuvenateEvent args)
|
||||||
|
{
|
||||||
|
component.IsRigged = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnSlotMicrowaved(EntityUid uid, PowerCellSlotComponent component, BeingMicrowavedEvent args)
|
private void OnSlotMicrowaved(EntityUid uid, PowerCellSlotComponent component, BeingMicrowavedEvent args)
|
||||||
{
|
{
|
||||||
if (_itemSlotsSystem.TryGetSlot(uid, component.CellSlotId, out ItemSlot? slot))
|
if (_itemSlotsSystem.TryGetSlot(uid, component.CellSlotId, out ItemSlot? slot))
|
||||||
|
|||||||
@@ -1,18 +1,32 @@
|
|||||||
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.PowerCell.Components;
|
using Content.Shared.PowerCell.Components;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
namespace Content.Shared.PowerCell;
|
namespace Content.Shared.PowerCell;
|
||||||
|
|
||||||
public abstract class SharedPowerCellSystem : EntitySystem
|
public abstract class SharedPowerCellSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<PowerCellSlotComponent, RejuvenateEvent>(OnRejuventate);
|
||||||
SubscribeLocalEvent<PowerCellSlotComponent, EntInsertedIntoContainerMessage>(OnCellInserted);
|
SubscribeLocalEvent<PowerCellSlotComponent, EntInsertedIntoContainerMessage>(OnCellInserted);
|
||||||
SubscribeLocalEvent<PowerCellSlotComponent, EntRemovedFromContainerMessage>(OnCellRemoved);
|
SubscribeLocalEvent<PowerCellSlotComponent, EntRemovedFromContainerMessage>(OnCellRemoved);
|
||||||
SubscribeLocalEvent<PowerCellSlotComponent, ContainerIsInsertingAttemptEvent>(OnCellInsertAttempt);
|
SubscribeLocalEvent<PowerCellSlotComponent, ContainerIsInsertingAttemptEvent>(OnCellInsertAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRejuventate(EntityUid uid, PowerCellSlotComponent component, RejuvenateEvent args)
|
||||||
|
{
|
||||||
|
if (!_itemSlots.TryGetSlot(uid, component.CellSlotId, out ItemSlot? itemSlot) || !itemSlot.Item.HasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// charge entity batteries and remove booby traps.
|
||||||
|
RaiseLocalEvent(itemSlot.Item.Value, args);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args)
|
private void OnCellInsertAttempt(EntityUid uid, PowerCellSlotComponent component, ContainerIsInsertingAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (!component.Initialized)
|
if (!component.Initialized)
|
||||||
|
|||||||
2
Resources/Locale/en-US/power/verb.ftl
Normal file
2
Resources/Locale/en-US/power/verb.ftl
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# debug verb for allowing devices to work without requiring power.
|
||||||
|
verb-debug-toggle-need-power = Toggle Power
|
||||||
Reference in New Issue
Block a user