Skip to content

Commit

Permalink
Update plasma cutters
Browse files Browse the repository at this point in the history
  • Loading branch information
MilenVolf committed Jan 12, 2025
1 parent 9926269 commit a1e7397
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Content.Server.AruMoon.Plasmacutter;
namespace Content.Server.Starshine.PlasmaCutter;

[RegisterComponent]
public sealed partial class BatteryRechargeComponent : Component
Expand All @@ -11,15 +11,15 @@ public sealed partial class BatteryRechargeComponent : Component
/// 1 plasma ore = 500 material units
/// </summary>
///
[DataField("multiplier"), ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float Multiplier = 1.0f;


/// <summary>
/// Max material storage limit
/// 7500 = 15 plasma ore
/// </summary>
[DataField("storageMaxCapacity"), ViewVariables(VVAccess.ReadWrite)]
[DataField]
public int StorageMaxCapacity = 7500;
}

53 changes: 26 additions & 27 deletions Content.Server/Starshine/PlasmaCutter/BatteryRechargeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
using Content.Server.Materials;
using Content.Shared.Materials;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Materials;

namespace Content.Server.AruMoon.Plasmacutter
namespace Content.Server.Starshine.PlasmaCutter
{

/// <summary>
/// This CODE FULL OF SHICODE!!!
/// <see cref="BatteryRechargeComponent"/>
/// Manages battery recharging with material usage and adjusts storage capacity dynamically.
/// </summary>
public sealed class BatteryRechargeSystem : EntitySystem
{
[Dependency] private readonly MaterialStorageSystem _materialStorage = default!;
[Dependency] private readonly BatterySystem _batterySystem = default!;



public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<MaterialStorageComponent, MaterialEntityInsertedEvent>(OnMaterialAmountChanged);
SubscribeLocalEvent<BatteryRechargeComponent, ChargeChangedEvent>(OnChargeChanged);
}

private void OnMaterialAmountChanged(EntityUid uid, MaterialStorageComponent component, MaterialEntityInsertedEvent args)
private void OnMaterialAmountChanged(EntityUid uid,
MaterialStorageComponent component,
MaterialEntityInsertedEvent args)
{
if (component.MaterialWhiteList != null)
foreach (var fuelType in component.MaterialWhiteList)
{
FuelAddCharge(uid, fuelType);
}
if (component.MaterialWhiteList == null)
return;

foreach (var fuelType in component.MaterialWhiteList)
{
FuelAddCharge(uid, fuelType);
}
}

private void OnChargeChanged(EntityUid uid, BatteryRechargeComponent component, ChargeChangedEvent args)
{
ChangeStorageLimit(uid, component.StorageMaxCapacity);
AdjustStorageCapacity(uid, component);
}

private void ChangeStorageLimit(
EntityUid uid,
int value,
private void AdjustStorageCapacity(EntityUid uid,
BatteryRechargeComponent component,
BatteryComponent? battery = null)
{
if (!Resolve(uid, ref battery))
return;
if (battery.CurrentCharge == battery.MaxCharge)
value = 0;
_materialStorage.TryChangeStorageLimit(uid, value);

// Calculate new storage limit based on current charge
var newCapacity = battery.CurrentCharge >= battery.MaxCharge
? 0
: (int)(component.StorageMaxCapacity * (1 - battery.CurrentCharge / battery.MaxCharge));

_materialStorage.TryChangeStorageLimit(uid, newCapacity);
}

private void FuelAddCharge(
EntityUid uid,
string fuelType,
BatteryRechargeComponent? recharge = null)
private void FuelAddCharge(EntityUid uid, string fuelType, BatteryRechargeComponent? recharge = null)
{
if (!Resolve(uid, ref recharge))
return;
Expand All @@ -68,5 +68,4 @@ private void FuelAddCharge(
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ ent-MiniatureEnergyCrossbow = энергетический мини арбале
.desc = энергетический арбалет синдиката, маленький, бесшумный и смертоносный.
ent-WeaponCutter = плазменный резак
.desc = Инструмент шахтеров, предназначенный для расчистки горных пород.
.suffix = Заряженный
ent-WeaponCutterEmpty = { ent-WeaponCutter }
.desc = { ent-WeaponCutter.desc }
.suffix = Пустой
ent-WeaponCutterAdv = улучшенный плазменный резак
.desc = Инструмент шахтеров, предназначенный для расчистки горных пород. Обладает усовершенствованной батареей и усиленной концентрирующей линзой.
.suffix = Заряженный
ent-WeaponCutterAdvEmpty = { ent-WeaponCutterAdv }
.desc = { ent-WeaponCutterAdv.desc }
.suffix = Пустой
ent-WeaponEmitterCannon = эмиттер-пушка
.desc = Самодельная пушка, созданная на основе стационарного эмиттера. Довольно мощная, однако скорость зарядки оставляет желать лучшего.
4 changes: 2 additions & 2 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@
- WeaponForceGun
- WeaponLaserSvalinn
- WeaponProtoKineticAccelerator
- WeaponCutter
- WeaponCutterEmpty
# Starshine-start
- WeaponCutterAdv
- WeaponCutterAdvEmpty
- WeaponTetherGun
- ClothingEyesVision
# Starshine-end
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Research/arsenal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- ShuttleGunKineticCircuitboard
# These are roundstart but not replenishable for salvage
## Starshine-start
- WeaponCutter
- WeaponCutterEmpty
# This is not roundstart since its a direct upgrade
## Starshine-end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@
- type: Appearance

- type: entity
name: Advanced Cutter
suffix: Empty
parent: WeaponCutter
id: WeaponCutterEmpty
components:
- type: MaterialStorage
storageLimit: 7500
- type: Battery
startingCharge: 0

- type: entity
name: advanced cutter
suffix: Charged
parent: WeaponCutter
id: WeaponCutterAdv
description: A self-defense weapon that exhausts organic targets, weakening them until they collapse.
Expand All @@ -76,6 +87,16 @@
fireCost: 75
- type: Appearance

- type: entity
suffix: Empty
parent: WeaponCutterAdv
id: WeaponCutterAdvEmpty
components:
- type: MaterialStorage
storageLimit: 7500
- type: Battery
startingCharge: 0

- type: entity
name: Emitter Cannon
id: WeaponEmitterCannon
Expand Down
10 changes: 4 additions & 6 deletions Resources/Prototypes/Starshine/Recipes/Lathes/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,22 @@
Plastic: 500

- type: latheRecipe
id: WeaponCutter
result: WeaponCutter
id: WeaponCutterEmpty
result: WeaponCutterEmpty
completetime: 10
materials:
Steel: 1000
Glass: 200
Silver: 100
Plasma: 400

- type: latheRecipe
id: WeaponCutterAdv
result: WeaponCutterAdv
id: WeaponCutterAdvEmpty
result: WeaponCutterAdvEmpty
completetime: 15
materials:
Steel: 1200
Glass: 300
Gold: 100
Plasma: 800

- type: latheRecipe
id: MagazinePistolSubMachineGunRubber
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Starshine/Research/arsenal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
tier: 2
cost: 10000
recipeUnlocks:
- WeaponCutterAdv
- WeaponCutterAdvEmpty
technologyPrerequisites:
- SalvageWeapons

Expand Down

0 comments on commit a1e7397

Please sign in to comment.