* Initial commit * mechs has reflect * all mechs has powercagehigh * mechs can only powered by power cages * powercages on protolathes * magboots on mechs * fire cost upped x2 * battery on guns has 200 energy by basic, adds ion gun * mecha x-ray gun add * mecha vindictor here * added amlg 90 * added uvm31 * localization * burst fire on Ultra * fix vindictor no desc * mech has prying * add scale 1.08 * add scale 1.08 to combat mechs * Mechs has collision * buff chain sword * upd * some fixes * fix weapon charging * Fix UVM-31 "Drake" Sound and Proto particle * Fix Mech collision, mechs can't stop peoples any more(some thing issues creates if collision is on) * AMLG90 Has bigger damage * Stunner uses hos stun spread --------- Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
58 lines
No EOL
2.2 KiB
C#
58 lines
No EOL
2.2 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.Equipment.Components;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
|
|
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, GunShotEvent>(MechGunShot);
|
|
SubscribeLocalEvent<MechEquipmentComponent, OnEmptyGunShotEvent>(MechEmptyGunShot);
|
|
}
|
|
|
|
private void MechGunShot(EntityUid uid, MechEquipmentComponent component, ref GunShotEvent args)
|
|
{
|
|
if (!component.EquipmentOwner.HasValue
|
|
|| !HasComp<MechComponent>(component.EquipmentOwner.Value)
|
|
|| !TryComp<BatteryComponent>(uid, out var battery))
|
|
return;
|
|
|
|
ChargeGunBattery(uid, battery);
|
|
}
|
|
|
|
private void MechEmptyGunShot(EntityUid uid, MechEquipmentComponent component, ref OnEmptyGunShotEvent args)
|
|
{
|
|
if (!component.EquipmentOwner.HasValue
|
|
|| !HasComp<MechComponent>(component.EquipmentOwner.Value)
|
|
|| !TryComp<BatteryComponent>(uid, out var battery))
|
|
return;
|
|
|
|
ChargeGunBattery(uid, battery);
|
|
}
|
|
|
|
private void ChargeGunBattery(EntityUid uid, BatteryComponent component)
|
|
{
|
|
if (!TryComp<MechEquipmentComponent>(uid, out var mechEquipment)
|
|
|| mechEquipment.EquipmentOwner is null
|
|
|| !TryComp<MechComponent>(mechEquipment.EquipmentOwner.Value, out var mech))
|
|
return;
|
|
|
|
var chargeDelta = component.MaxCharge - component.CurrentCharge;
|
|
// TODO: The battery charge of the mech would be spent directly when fired.
|
|
if (chargeDelta <= 0
|
|
|| mech.Energy - chargeDelta < 0
|
|
|| !_mech.TryChangeEnergy(mechEquipment.EquipmentOwner.Value, -chargeDelta, mech))
|
|
return;
|
|
|
|
_battery.SetCharge(uid, component.MaxCharge, component);
|
|
}
|
|
} |