Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cherry pick portable charger #2206

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Content.Server/Power/Components/ChargerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
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
{
Expand All @@ -26,5 +31,12 @@ public sealed partial class ChargerComponent : Component
/// </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;
}
}
25 changes: 19 additions & 6 deletions Content.Server/Power/EntitySystems/ChargerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
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;
Expand Down Expand Up @@ -30,6 +32,8 @@ public override void Initialize()
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)
Expand Down Expand Up @@ -190,18 +194,27 @@ private void UpdateStatus(EntityUid uid, ChargerComponent component)
}
}

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))
Expand All @@ -218,7 +231,7 @@ private CellChargerStatus GetStatus(EntityUid uid, ChargerComponent component)

return CellChargerStatus.Charging;
}

private void TransferPower(EntityUid uid, EntityUid targetEntity, ChargerComponent component, float frameTime)
{
if (!TryComp(uid, out ApcPowerReceiverComponent? receiverComponent))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
- 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: ContainerContainer
containers:
charger_slot: !type:ContainerSlot
- type: ItemSlots
slots:
charger_slot:
ejectOnInteract: true
whitelist:
components:
- HitscanBatteryAmmoProvider
- ProjectileBatteryAmmoProvider
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
- MagazineRifleUranium
- MagazineShotgunBeanbag
- MagazineShotgunIncendiary
#- PortableRecharger # DeltaV - removed for some reason
- PortableRecharger
- PowerCageHigh
- PowerCageMedium
- PowerCageSmall
Expand Down
21 changes: 10 additions & 11 deletions Resources/Prototypes/Recipes/Lathes/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,13 @@
Plastic: 100
Glass: 20

# DeltaV: removed, idk why
#- type: latheRecipe
# id: PortableRecharger
# result: PortableRecharger
# completetime: 15
# materials:
# Steel: 2000
# Uranium: 2000
# Plastic: 1000
# Plasma: 500
# Glass: 500
- type: latheRecipe
id: PortableRecharger
result: PortableRecharger
completetime: 15
materials:
Steel: 2000
Uranium: 2000
Plastic: 1000
Plasma: 500
Glass: 500
6 changes: 3 additions & 3 deletions Resources/Prototypes/Research/arsenal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
cost: 5000
recipeUnlocks:
- MagazineShotgunBeanbag
- BoxShellTranquilizer
- BoxBeanbag
- BoxShellTranquilizer
- BoxBeanbag
- WeaponDisabler
# DeltaV - rubber ammo which upstream removed
- MagazineRifleRubber
Expand Down Expand Up @@ -115,7 +115,6 @@
- WeaponDisablerSMG
- BorgModuleSecurityDeescalate # Delta-V : SecBorg Research
- BorgModuleSecurityEscalate # Delta-V : SecBorg Research


- type: technology
id: ExplosiveTechnology
Expand Down Expand Up @@ -211,6 +210,7 @@
cost: 15000
recipeUnlocks:
- WeaponAdvancedLaser
- PortableRecharger

- type: technology
id: ExperimentalBatteryAmmo
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Sprited by Lomovar",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "charging",
"delays": [
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
]
]
},
{
"name": "charging-equipped-BACKPACK",
"directions": 4,
"delays": [
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
],
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
],
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
],
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
]
]
},
{
"name": "charging-unlit",
"delays": [
[
0.3,
0.3,
0.3,
0.3,
0.3,
0.3
]
]
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}

Loading