Add power sinks (#8020)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -348,7 +348,8 @@ namespace Content.Client.Entry
|
|||||||
"HealthAnalyzer",
|
"HealthAnalyzer",
|
||||||
"Thirst",
|
"Thirst",
|
||||||
"CanEscapeInventory",
|
"CanEscapeInventory",
|
||||||
"Wires"
|
"PowerSink",
|
||||||
|
"Wires",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
Content.Server/PowerSink/PowerSinkComponent.cs
Normal file
8
Content.Server/PowerSink/PowerSinkComponent.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Content.Server.PowerSink
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Absorbs power up to its capacity when anchored then explodes.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed class PowerSinkComponent : Component {}
|
||||||
|
}
|
||||||
56
Content.Server/PowerSink/PowerSinkSystem.cs
Normal file
56
Content.Server/PowerSink/PowerSinkSystem.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using Content.Server.Explosion.EntitySystems;
|
||||||
|
using Content.Server.Power.Components;
|
||||||
|
using Content.Shared.Body.Events;
|
||||||
|
using Content.Shared.Examine;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
|
namespace Content.Server.PowerSink
|
||||||
|
{
|
||||||
|
public sealed class PowerSinkSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<PowerSinkComponent, ExaminedEvent>(OnExamine);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExamine(EntityUid uid, PowerSinkComponent component, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
if (!args.IsInDetailsRange || !TryComp<PowerConsumerComponent>(uid, out var consumer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var drainAmount = (int) consumer.NetworkLoad.ReceivingPower / 1000;
|
||||||
|
args.PushMarkup(
|
||||||
|
Loc.GetString(
|
||||||
|
"powersink-examine-drain-amount",
|
||||||
|
("amount", drainAmount),
|
||||||
|
("markupDrainColor", "orange"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
var toRemove = new RemQueue<(PowerSinkComponent Sink, BatteryComponent Battery)>();
|
||||||
|
|
||||||
|
// Realistically it's gonna be like <5 per station.
|
||||||
|
foreach (var (comp, networkLoad, battery, xform) in EntityManager.EntityQuery<PowerSinkComponent, PowerConsumerComponent, BatteryComponent, TransformComponent>())
|
||||||
|
{
|
||||||
|
if (!xform.Anchored) continue;
|
||||||
|
|
||||||
|
battery.CurrentCharge += networkLoad.NetworkLoad.ReceivingPower / 1000;
|
||||||
|
if (battery.CurrentCharge < battery.MaxCharge) continue;
|
||||||
|
|
||||||
|
toRemove.Add((comp, battery));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (comp, battery) in toRemove)
|
||||||
|
{
|
||||||
|
_explosionSystem.QueueExplosion(comp.Owner, "Default", 5 * (battery.MaxCharge / 2500000), 0.5f, 10, canCreateVacuum: false);
|
||||||
|
EntityManager.RemoveComponent(comp.Owner, comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Resources/Locale/en-US/powersink/powersink.ftl
Normal file
1
Resources/Locale/en-US/powersink/powersink.ftl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
powersink-examine-drain-amount = The power sink is draining [color={$markupDrainColor}]{$amount} kW[/color].
|
||||||
@@ -255,6 +255,12 @@
|
|||||||
itemId: ClothingBackpackDuffelSyndicateFilledMedical
|
itemId: ClothingBackpackDuffelSyndicateFilledMedical
|
||||||
price: 5
|
price: 5
|
||||||
|
|
||||||
|
- type : uplinkListing
|
||||||
|
id: UplinkPowerSink
|
||||||
|
category: Tools
|
||||||
|
itemId: PowerSink
|
||||||
|
price: 5
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
id: UplinkCarpDehydrated
|
id: UplinkCarpDehydrated
|
||||||
category: Tools
|
category: Tools
|
||||||
|
|||||||
46
Resources/Prototypes/Entities/Objects/Power/powersink.yml
Normal file
46
Resources/Prototypes/Entities/Objects/Power/powersink.yml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
- type: entity
|
||||||
|
id: PowerSink
|
||||||
|
parent: BaseMachine
|
||||||
|
name: power sink
|
||||||
|
description: Drains immense amounts of electricity from the grid.
|
||||||
|
components:
|
||||||
|
- type: Item
|
||||||
|
size: 150
|
||||||
|
- type: NodeContainer
|
||||||
|
examinable: true
|
||||||
|
nodes:
|
||||||
|
input:
|
||||||
|
!type:CableDeviceNode
|
||||||
|
nodeGroupID: HVPower
|
||||||
|
- type: Transform
|
||||||
|
anchored: true
|
||||||
|
- type: Physics
|
||||||
|
- type: Fixtures
|
||||||
|
fixtures:
|
||||||
|
- shape:
|
||||||
|
!type:PhysShapeAabb
|
||||||
|
bounds: "-0.40,-0.40,0.40,0.40"
|
||||||
|
mass: 15
|
||||||
|
mask:
|
||||||
|
- MachineMask
|
||||||
|
layer:
|
||||||
|
- MachineLayer
|
||||||
|
- type: Destructible
|
||||||
|
thresholds:
|
||||||
|
- trigger:
|
||||||
|
!type:DamageTrigger
|
||||||
|
damage: 25
|
||||||
|
behaviors:
|
||||||
|
- !type:DoActsBehavior
|
||||||
|
acts: [ "Destruction" ]
|
||||||
|
- type: PowerSink
|
||||||
|
- type: Battery
|
||||||
|
maxCharge: 7500000
|
||||||
|
- type: ExaminableBattery
|
||||||
|
- type: PowerConsumer
|
||||||
|
voltage: High
|
||||||
|
drawRate: 1000000
|
||||||
|
- type: Sprite
|
||||||
|
netsync: false
|
||||||
|
sprite: Objects/Power/powersink.rsi
|
||||||
|
state: powersink
|
||||||
14
Resources/Textures/Objects/Power/powersink.rsi/meta.json
Normal file
14
Resources/Textures/Objects/Power/powersink.rsi/meta.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"license": "CC-BY-NC-SA-3.0",
|
||||||
|
"copyright": "Taken from goonstation at commit https://github.com/goonstation/goonstation/commit/17c4392b75abd87a0f740e116c44dd4c7dfff6f7",
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "powersink"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
Resources/Textures/Objects/Power/powersink.rsi/powersink.png
Normal file
BIN
Resources/Textures/Objects/Power/powersink.rsi/powersink.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
Reference in New Issue
Block a user