using Content.Shared.Power;
using Content.Shared.Whitelist;
+using Content.Shared.Power;
+using Content.Shared.Whitelist;
+using Robust.Shared.GameObjects;
+using Robust.Shared.Serialization.Manager.Attributes;
+using Robust.Shared.ViewVariables;
namespace Content.Server.Power.Components
{
/// </summary>
[DataField("whitelist")]
public EntityWhitelist? Whitelist;
+
+ /// <summary>
+ /// Indicates whether the charger is portable and thus subject to EMP effects
+ /// and bypasses checks for transform, anchored, and ApcPowerReceiverComponent.
+ /// </summary>
+ [DataField]
+ public bool Portable = false;
}
}
using Content.Server.Power.Components;
+using Content.Server.Emp;
using Content.Server.PowerCell;
using Content.Shared.Examine;
using Content.Shared.Power;
using Content.Shared.PowerCell.Components;
+using Content.Shared.Emp;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using System.Diagnostics.CodeAnalysis;
SubscribeLocalEvent<ChargerComponent, ContainerIsInsertingAttemptEvent>(OnInsertAttempt);
SubscribeLocalEvent<ChargerComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
SubscribeLocalEvent<ChargerComponent, ExaminedEvent>(OnChargerExamine);
+
+ SubscribeLocalEvent<ChargerComponent, EmpPulseEvent>(OnEmpPulse);
}
private void OnStartup(EntityUid uid, ChargerComponent component, ComponentStartup args)
}
}
+ private void OnEmpPulse(EntityUid uid, ChargerComponent component, ref EmpPulseEvent args)
+ {
+ args.Affected = true;
+ args.Disabled = true;
+ }
+
private CellChargerStatus GetStatus(EntityUid uid, ChargerComponent component)
{
- if (!TryComp(uid, out TransformComponent? transformComponent))
- return CellChargerStatus.Off;
+ if (!component.Portable)
+ {
+ if (!TryComp(uid, out TransformComponent? transformComponent) || !transformComponent.Anchored)
+ return CellChargerStatus.Off;
+ }
- if (!transformComponent.Anchored)
+ if (!TryComp(uid, out ApcPowerReceiverComponent? apcPowerReceiverComponent))
return CellChargerStatus.Off;
- if (!TryComp(uid, out ApcPowerReceiverComponent? apcPowerReceiverComponent))
+ if (!component.Portable && !apcPowerReceiverComponent.Powered)
return CellChargerStatus.Off;
- if (!apcPowerReceiverComponent.Powered)
+ if (HasComp<EmpDisabledComponent>(uid))
return CellChargerStatus.Off;
if (!_container.TryGetContainer(uid, component.SlotId, out var container))
return CellChargerStatus.Charging;
}
-
+
private void TransferPower(EntityUid uid, EntityUid targetEntity, ChargerComponent component, float frameTime)
{
if (!TryComp(uid, out ApcPowerReceiverComponent? receiverComponent))
--- /dev/null
+- type: entity
+ parent: Clothing
+ id: PortableRecharger
+ name: portable recharger
+ description: High-tech recharger adapted for portability
+ components:
+ - type: Item
+ size: Huge
+ - type: Sprite
+ sprite: Objects/Power/portable_recharger.rsi
+ state: charging
+ - type: Clothing
+ equippedPrefix: charging
+ quickEquip: false
+ slots:
+ - back
+ - type: Charger
+ slotId: charger_slot
+ portable: true
+ - type: PowerChargerVisuals
+ - type: ApcPowerReceiver
+ needsPower: false
+ powerLoad: 0
+ - type: StaticPrice
+ price: 500
+ - type: Tag
+ tags: [] # ignore "WhitelistChameleon" tag
+ - type: ItemSlots
+ slots:
+ charger_slot:
+ ejectOnInteract: true
+ whitelist:
+ components:
+ - HitscanBatteryAmmoProvider
+ - ProjectileBatteryAmmoProvider
\ No newline at end of file