Skip to content

Commit

Permalink
meow
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyndomen committed Nov 18, 2024
1 parent 251189c commit b2c346c
Showing 1 changed file with 1 addition and 111 deletions.
112 changes: 1 addition & 111 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.AutoFire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Shared.Interaction; // Frontier
using Content.Shared.Examine; // Frontier
using Content.Shared.Power; // Frontier
using Content.Server.Popups; // Frontier

namespace Content.Server.Weapons.Ranged.Systems;

Expand Down Expand Up @@ -38,116 +39,6 @@ public override void Update(float frameTime)
// This code is licensed under AGPLv3. See AGPLv3.txt
private void OnGunExamine(EntityUid uid, AutoShootGunComponent component, ExaminedEvent args)
{
if (!HasComp<ApcPowerReceiverComponent>(uid))
return;

// Powered is already handled by other power components
var enabled = Loc.GetString(component.On ? "gun-comp-enabled" : "gun-comp-disabled");

args.PushMarkup(enabled);
}

private void OnActivateGun(EntityUid uid, AutoShootGunComponent component, ActivateInWorldEvent args)
{
if (args.Handled || !args.Complex)
return;

component.On ^= true;

if (!component.On)
{
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && component.OriginalLoad != 0)
apcPower.Load = 1;

DisableGun(uid, component);
args.Handled = true;
}
else if (CanEnable(uid, component))
{
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && component.OriginalLoad != apcPower.Load)
apcPower.Load = component.OriginalLoad;

EnableGun(uid, component);
args.Handled = true;
}
}

/// <summary>
/// Tries to disable the AutoShootGun.
/// </summary>
public void DisableGun(EntityUid uid, AutoShootGunComponent component)
{
if (component.CanFire)
component.CanFire = false;
}

public bool CanEnable(EntityUid uid, AutoShootGunComponent component)
{
var xform = Transform(uid);

// Must be anchored to fire.
if (!xform.Anchored)
return false;

// No power needed? Always works.
if (!HasComp<ApcPowerReceiverComponent>(uid))
return true;

// Not switched on? Won't work.
if (!component.On)
return false;

return this.IsPowered(uid, EntityManager);
}

public void EnableGun(EntityUid uid, AutoShootGunComponent component, TransformComponent? xform = null)
{
if (!component.CanFire)
component.CanFire = true;
}

private void OnAnchorChange(EntityUid uid, AutoShootGunComponent component, ref AnchorStateChangedEvent args)
{
if (args.Anchored && CanEnable(uid, component))
EnableGun(uid, component);
else
DisableGun(uid, component);
}

private void OnGunInit(EntityUid uid, AutoShootGunComponent component, ComponentInit args)
{
if (TryComp<ApcPowerReceiverComponent>(uid, out var apcPower) && component.OriginalLoad == 0)
component.OriginalLoad = apcPower.Load;

if (!component.On)
return;

if (CanEnable(uid, component))
EnableGun(uid, component);
}

private void OnGunShutdown(EntityUid uid, AutoShootGunComponent component, ComponentShutdown args)
{
DisableGun(uid, component);
}

private void OnPowerChange(EntityUid uid, AutoShootGunComponent component, ref PowerChangedEvent args)
{
if (args.Powered && CanEnable(uid, component))
EnableGun(uid, component);
else
DisableGun(uid, component);
}
// End of Frontier modified code

// New Frontiers - Shuttle Gun Power Draw - makes shuttle guns require power if they
// have an ApcPowerReceiverComponent
// This code is licensed under AGPLv3. See AGPLv3.txt
private void OnGunExamine(EntityUid uid, AutoShootGunComponent component, ExaminedEvent args)
{
if (!HasComp<ApcPowerReceiverComponent>(uid))
return;

// Powered is already handled by other power components
var enabled = Loc.GetString(component.On ? "gun-comp-enabled" : "gun-comp-disabled");

Expand Down Expand Up @@ -185,7 +76,6 @@ private void OnActivateGun(EntityUid uid, AutoShootGunComponent component, Activ
}
}


/// <summary>
/// Tries to disable the AutoShootGun.
/// </summary>
Expand Down

0 comments on commit b2c346c

Please sign in to comment.