mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-20 15:08:46 +03:00
* the definition of insanity * the definition of insanity * the definition of insanity * we have hullrot at home * maybe the real hullrot was the friends we made along the way * john hullrot * i am going to hullroooooot * it's hullrotver * we're so hullback * we're rotting the hull with this one * hullmerge * the hullrot is leaking * never gonna rot you up * hullfresh * john starsector * god i wish we had grid collision damage * you can tell I am very tired because I stopped forcing a hullrot joke into every commit message * hr * this is a surprise sprite that will help us later * motherfucker * i have nothing good to say * still nothing * brb * random letter random letter random letter dash random number random number random number * ass * blast * ffs * fcuk * RE: ffs * RE: RE: ffs * гнида жестяная * continue * i hate tests * i love tests * slide to the right * i hate tests again * what the fuck * ты шиз? * ?? * bbgun
54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
using Content.Server.Power.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using Content.Shared._White.Guns.ModularTurret;
|
|
using Content.Shared.Containers.ItemSlots;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
|
|
namespace Content.Server._White.Guns.ModularTurret;
|
|
|
|
public sealed class ModularTurretSystem : SharedModularTurretSystem
|
|
{
|
|
[Dependency] private readonly BatterySystem _battery = default!;
|
|
[Dependency] private readonly ItemSlotsSystem _slot = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ModularTurretComponent, ShotAttemptedEvent>(OnModularTurretShotAttempt);
|
|
SubscribeLocalEvent<ModularTurretWeaponComponent, GunShotEvent>(OnModularTurretWeaponShot);
|
|
}
|
|
|
|
|
|
private void OnModularTurretShotAttempt(EntityUid turretUid, ModularTurretComponent comp, ref ShotAttemptedEvent args)
|
|
{
|
|
RechargeWeapon(turretUid, args.Used);
|
|
}
|
|
|
|
private void OnModularTurretWeaponShot(EntityUid gunUid, ModularTurretWeaponComponent comp, ref GunShotEvent args)
|
|
{
|
|
if(comp.CurrentTurretHolder is EntityUid turretUid)
|
|
RechargeWeapon(turretUid, gunUid);
|
|
}
|
|
|
|
|
|
private void RechargeWeapon(EntityUid turretUid, EntityUid gunUid)
|
|
{
|
|
if (!HasComp<ModularTurretWeaponComponent>(gunUid))
|
|
return;
|
|
|
|
//var turretComp = Comp<ModularTurretComponent>(turretUid);
|
|
if (!TryComp<BatteryComponent>(gunUid, out var gunBattery) || // || !turretComp.CanChargeWeapon
|
|
!TryComp<BatteryComponent>(turretUid, out var turretBattery))
|
|
return;
|
|
|
|
float missing = gunBattery.MaxCharge - gunBattery.CurrentCharge;
|
|
|
|
float recharged = -_battery.UseCharge(turretUid, missing, turretBattery);
|
|
|
|
_battery.SetCharge(gunUid, gunBattery.CurrentCharge + recharged, gunBattery);
|
|
}
|
|
}
|
|
|