forked from Simple-Station/Einstein-Engines
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mechs real, Synth balance, Terragov Preset
- Loading branch information
Showing
19 changed files
with
864 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Content.Server/Mech/Equipment/EntitySystems/MechGunSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
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.Throwing; | ||
using Content.Shared.Weapons.Ranged.Systems; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.Mech.Equipment.EntitySystems; | ||
public sealed class MechGunSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly ThrowingSystem _throwing = default!; | ||
[Dependency] private readonly MechSystem _mech = default!; | ||
[Dependency] private readonly BatterySystem _battery = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<MechEquipmentComponent, GunShotEvent>(MechGunShot); | ||
} | ||
|
||
private void MechGunShot(EntityUid uid, MechEquipmentComponent component, ref GunShotEvent args) | ||
{ | ||
if (!component.EquipmentOwner.HasValue) | ||
return; | ||
|
||
if (!TryComp<MechComponent>(component.EquipmentOwner.Value, out var mech)) | ||
return; | ||
|
||
if (TryComp<BatteryComponent>(uid, out var battery)) | ||
{ | ||
ChargeGunBattery(uid, battery); | ||
return; | ||
} | ||
|
||
// In most guns the ammo itself isn't shot but turned into cassings | ||
// and a new projectile is spawned instead, meaning that args.Ammo | ||
// is most likely inside the equipment container (for some odd reason) | ||
|
||
// I'm not even sure why this is needed since GunSystem.Shoot() has a | ||
// container check before ejecting, but yet it still puts the spent ammo inside the mech | ||
foreach (var (ent, _) in args.Ammo) | ||
{ | ||
if (ent.HasValue && mech.EquipmentContainer.Contains(ent.Value)) | ||
{ | ||
mech.EquipmentContainer.Remove(ent.Value); | ||
_throwing.TryThrow(ent.Value, _random.NextVector2(), _random.Next(5)); | ||
} | ||
} | ||
} | ||
|
||
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; | ||
|
||
if (chargeDelta <= 0 || mech.Energy - chargeDelta < 0) | ||
return; | ||
|
||
if (!_mech.TryChangeEnergy(mechEquipment.EquipmentOwner.Value, -chargeDelta, mech)) | ||
return; | ||
|
||
_battery.SetCharge(uid, component.MaxCharge, component); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
- type: dataset | ||
id: names_terra_first | ||
values: | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Maj. | ||
- Lt. | ||
- Cpl. | ||
- Col. | ||
- Pvt. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. | ||
- Sgt. | ||
- Capt. | ||
- Pvt. | ||
- Lt. | ||
- Cpl. | ||
- Maj. | ||
- Col. |
Oops, something went wrong.