mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> We like mechs here, yeah? --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Mocho, John Space - tweak: The H.O.N.K. has received an airtight cabin for honk operations in outer space. - add: Added the Ripley MK-II, a heavy, slow all-purpose mech, featuring a pressurized cabin for space operations. - add: Added the Clarke, A fast moving mech for space travel, with built in thrusters (not certain if they work properly though :trollface:) - add: Added the Gygax, a lightly armored and highly mobile mech with enough force to rip walls, or someone's head off. - add: Added the Durand, a slow but beefy combat suit that you dont want to fight in close quarters. - add: Added the Marauder, a specialized mech issued to ERT operatives. - add: Added the Seraph, a specialized combat suit issued to ??? operatives. - add: The syndicate has started issuing units under the codenames "Dark Gygax" and "Mauler" to syndicate agents at an introductory price. - add: The exosuit fabricator can now be emagged to reveal new recipes. - add: There are 4 new bounties cargo can fulfill for mechs. Feedback on the cost/reward is welcome! --------- Signed-off-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Co-authored-by: John Space <bigdumb421@gmail.com> Co-authored-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com> Co-authored-by: ScyronX <166930367+ScyronX@users.noreply.github.com> (cherry picked from commit e3003b67014565816e83556c826a8bba344aac94)
76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using Content.Server.Mech.Systems;
|
|
using Content.Server.Power.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared.Mech.Components;
|
|
using Content.Shared.Mech.EntitySystems;
|
|
using Content.Shared.Mech.Equipment.Components;
|
|
using Content.Shared.Throwing;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Mech.Equipment.EntitySystems;
|
|
public sealed class MechGunSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly MechSystem _mech = default!;
|
|
[Dependency] private readonly BatterySystem _battery = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<MechEquipmentComponent, HandleMechEquipmentBatteryEvent>(OnHandleMechEquipmentBattery);
|
|
SubscribeLocalEvent<HitscanBatteryAmmoProviderComponent, CheckMechWeaponBatteryEvent>(OnCheckBattery);
|
|
SubscribeLocalEvent<ProjectileBatteryAmmoProviderComponent, CheckMechWeaponBatteryEvent>(OnCheckBattery);
|
|
}
|
|
|
|
private void OnHandleMechEquipmentBattery(EntityUid uid, MechEquipmentComponent component, HandleMechEquipmentBatteryEvent args)
|
|
{
|
|
if (!component.EquipmentOwner.HasValue)
|
|
return;
|
|
|
|
if (!TryComp<MechComponent>(component.EquipmentOwner.Value, out var mech))
|
|
return;
|
|
|
|
if (TryComp<BatteryComponent>(uid, out var battery))
|
|
{
|
|
var ev = new CheckMechWeaponBatteryEvent(battery);
|
|
RaiseLocalEvent(uid, ref ev);
|
|
|
|
if (ev.Cancelled)
|
|
return;
|
|
|
|
ChargeGunBattery(uid, battery);
|
|
}
|
|
}
|
|
|
|
private void OnCheckBattery(EntityUid uid, BatteryAmmoProviderComponent component, CheckMechWeaponBatteryEvent args)
|
|
{
|
|
if (args.Battery.CurrentCharge > component.FireCost)
|
|
args.Cancelled = true;
|
|
}
|
|
|
|
private void ChargeGunBattery(EntityUid uid, BatteryComponent component)
|
|
{
|
|
if (!TryComp<MechEquipmentComponent>(uid, out var mechEquipment) || !mechEquipment.EquipmentOwner.HasValue)
|
|
return;
|
|
|
|
if (!TryComp<MechComponent>(mechEquipment.EquipmentOwner.Value, out var mech))
|
|
return;
|
|
|
|
var maxCharge = component.MaxCharge;
|
|
var currentCharge = component.CurrentCharge;
|
|
|
|
var chargeDelta = maxCharge - currentCharge;
|
|
|
|
// TODO: The battery charge of the mech would be spent directly when fired.
|
|
if (chargeDelta <= 0 || mech.Energy - chargeDelta < 0)
|
|
return;
|
|
|
|
if (!_mech.TryChangeEnergy(mechEquipment.EquipmentOwner.Value, -chargeDelta, mech))
|
|
return;
|
|
|
|
_battery.SetCharge(uid, component.MaxCharge, component);
|
|
}
|
|
}
|
|
|
|
[ByRefEvent]
|
|
public record struct CheckMechWeaponBatteryEvent(BatteryComponent Battery, bool Cancelled = false); |