mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-24 09:08:04 +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
62 lines
2.3 KiB
C#
62 lines
2.3 KiB
C#
using Content.Shared._White.DollyMixture;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Shared._White.Guns.ModularTurret;
|
|
|
|
public abstract class SharedModularTurretSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedDollyMixtureSystem _dolly = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<ModularTurretComponent, ContainerIsInsertingAttemptEvent>(OnInsertAttempt);
|
|
SubscribeLocalEvent<ModularTurretComponent, EntInsertedIntoContainerMessage>(OnInserted);
|
|
SubscribeLocalEvent<ModularTurretComponent, EntRemovedFromContainerMessage>(OnRemoved);
|
|
SubscribeLocalEvent<ModularTurretWeaponComponent, ShotAttemptedEvent>(OnModularTurretWeaponShotAttempt);
|
|
}
|
|
|
|
private void OnModularTurretWeaponShotAttempt(EntityUid turretUid, ModularTurretWeaponComponent comp, ref ShotAttemptedEvent args)
|
|
{
|
|
if (comp.OnlyUsableByTurret && !HasComp<ModularTurretComponent>(args.User))
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnInsertAttempt(EntityUid uid, ModularTurretComponent comp, ContainerIsInsertingAttemptEvent args)
|
|
{
|
|
if (args.Container.ID != comp.Slot)
|
|
return;
|
|
|
|
if (!TryComp<ModularTurretWeaponComponent>(args.EntityUid, out var modweapon))
|
|
{
|
|
args.Cancel();
|
|
return;
|
|
}
|
|
|
|
if (comp.MountClass is string turretClass &&
|
|
!modweapon.WeaponClass.Contains(turretClass))
|
|
args.Cancel();
|
|
}
|
|
|
|
protected virtual void OnInserted(EntityUid uid, ModularTurretComponent comp, EntInsertedIntoContainerMessage args)
|
|
{
|
|
if (args.Container.ID == comp.Slot && TryComp<ModularTurretWeaponComponent>(args.Entity, out var weapon))
|
|
{
|
|
weapon.CurrentTurretHolder = uid;
|
|
if (weapon.DollyMixRSIPath is string path)
|
|
_dolly.Apply3D(uid, path);
|
|
}
|
|
}
|
|
|
|
protected virtual void OnRemoved(EntityUid uid, ModularTurretComponent comp, EntRemovedFromContainerMessage args)
|
|
{
|
|
if (args.Container.ID == comp.Slot && TryComp<ModularTurretWeaponComponent>(args.Entity, out var weapon))
|
|
{
|
|
weapon.CurrentTurretHolder = null;
|
|
if (weapon.DollyMixRSIPath is not null)
|
|
_dolly.Remove3D(uid);
|
|
}
|
|
}
|
|
|
|
}
|