mech tweaks (#15619)

This commit is contained in:
deltanedas
2023-04-24 21:00:36 +00:00
committed by GitHub
parent 808eee068f
commit dd4cf48c0a
4 changed files with 55 additions and 65 deletions

View File

@@ -16,6 +16,7 @@ using Content.Shared.Verbs;
using Content.Shared.Wires; using Content.Shared.Wires;
using Robust.Server.Containers; using Robust.Server.Containers;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Map; using Robust.Shared.Map;
namespace Content.Server.Mech.Systems; namespace Content.Server.Mech.Systems;
@@ -41,6 +42,7 @@ public sealed class MechSystem : SharedMechSystem
_sawmill = Logger.GetSawmill("mech"); _sawmill = Logger.GetSawmill("mech");
SubscribeLocalEvent<MechComponent, InteractUsingEvent>(OnInteractUsing); SubscribeLocalEvent<MechComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<MechComponent, EntInsertedIntoContainerMessage>(OnInsertBattery);
SubscribeLocalEvent<MechComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<MechComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<MechComponent, GetVerbsEvent<AlternativeVerb>>(OnAlternativeVerb); SubscribeLocalEvent<MechComponent, GetVerbsEvent<AlternativeVerb>>(OnAlternativeVerb);
SubscribeLocalEvent<MechComponent, MechOpenUiEvent>(OnOpenUi); SubscribeLocalEvent<MechComponent, MechOpenUiEvent>(OnOpenUi);
@@ -69,6 +71,7 @@ public sealed class MechSystem : SharedMechSystem
if (component.Broken || component.Integrity <= 0 || component.Energy <= 0) if (component.Broken || component.Integrity <= 0 || component.Energy <= 0)
args.Cancel(); args.Cancel();
} }
private void OnInteractUsing(EntityUid uid, MechComponent component, InteractUsingEvent args) private void OnInteractUsing(EntityUid uid, MechComponent component, InteractUsingEvent args)
{ {
if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open) if (TryComp<WiresPanelComponent>(uid, out var panel) && !panel.Open)
@@ -93,6 +96,18 @@ public sealed class MechSystem : SharedMechSystem
} }
} }
private void OnInsertBattery(EntityUid uid, MechComponent component, EntInsertedIntoContainerMessage args)
{
if (args.Container != component.BatterySlot || !TryComp<BatteryComponent>(args.Entity, out var battery))
return;
component.Energy = battery.CurrentCharge;
component.MaxEnergy = battery.MaxCharge;
Dirty(component);
_actionBlocker.UpdateCanMove(uid);
}
private void OnRemoveBattery(EntityUid uid, MechComponent component, RemoveBatteryEvent args) private void OnRemoveBattery(EntityUid uid, MechComponent component, RemoveBatteryEvent args)
{ {
if (args.Cancelled || args.Handled) if (args.Cancelled || args.Handled)
@@ -115,12 +130,6 @@ public sealed class MechSystem : SharedMechSystem
component.Integrity = component.MaxIntegrity; component.Integrity = component.MaxIntegrity;
component.Energy = component.MaxEnergy; component.Energy = component.MaxEnergy;
if (component.StartingBattery != null)
{
var battery = Spawn(component.StartingBattery, Transform(uid).Coordinates);
InsertBattery(uid, battery, component);
}
_actionBlocker.UpdateCanMove(uid); _actionBlocker.UpdateCanMove(uid);
Dirty(component); Dirty(component);
} }

View File

@@ -138,13 +138,6 @@ public sealed class MechComponent : Component
[DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))] [DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
public List<string> StartingEquipment = new(); public List<string> StartingEquipment = new();
/// <summary>
/// The battery the mech initially has when it spawns
/// Good for admemes and nukie mechs.
/// </summary>
[DataField("startingBattery", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? StartingBattery;
#region Action Prototypes #region Action Prototypes
[DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))] [DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
public string MechCycleAction = "MechCycleEquipment"; public string MechCycleAction = "MechCycleEquipment";

View File

@@ -21,6 +21,14 @@
restitution: 0.3 # fite me restitution: 0.3 # fite me
friction: 0.2 friction: 0.2
- type: Pullable - type: Pullable
# Ripley APLU
- type: entity
id: BaseRipleyPart
parent: BaseMechPart
abstract: true
components:
- type: Sprite - type: Sprite
drawdepth: Items drawdepth: Items
noRot: false noRot: false
@@ -28,27 +36,15 @@
sprite: Objects/Specific/Mech/ripley_construction.rsi sprite: Objects/Specific/Mech/ripley_construction.rsi
- type: entity - type: entity
id: BaseMechPartItem id: BaseRipleyPartItem
parent: BaseMechPart parent: BaseRipleyPart
abstract: true abstract: true
components: components:
- type: Item - type: Item
size: 50 size: 50
- type: entity - type: entity
id: BaseMechConstruct parent: BaseRipleyPart
parent: BaseMechPart
abstract: true
components:
- type: Appearance
- type: ContainerContainer
containers:
battery-container: !type:Container
- type: MechAssemblyVisuals
statePrefix: ripley
- type: entity
parent: BaseMechPart
id: RipleyHarness id: RipleyHarness
name: ripley harness name: ripley harness
description: The core of the Ripley APLU. description: The core of the Ripley APLU.
@@ -88,7 +84,7 @@
noRot: true noRot: true
- type: entity - type: entity
parent: BaseMechPartItem parent: BaseRipleyPartItem
id: RipleyLArm id: RipleyLArm
name: ripley left arm name: ripley left arm
description: The left arm of the Ripley APLU. It belongs on the chassis of the mech. description: The left arm of the Ripley APLU. It belongs on the chassis of the mech.
@@ -100,7 +96,7 @@
- RipleyLArm - RipleyLArm
- type: entity - type: entity
parent: BaseMechPartItem parent: BaseRipleyPartItem
id: RipleyLLeg id: RipleyLLeg
name: ripley left leg name: ripley left leg
description: The left leg of the Ripley APLU. It belongs on the chassis of the mech. description: The left leg of the Ripley APLU. It belongs on the chassis of the mech.
@@ -112,7 +108,7 @@
- RipleyLLeg - RipleyLLeg
- type: entity - type: entity
parent: BaseMechPartItem parent: BaseRipleyPartItem
id: RipleyRLeg id: RipleyRLeg
name: ripley right leg name: ripley right leg
description: The right leg of the Ripley APLU. It belongs on the chassis of the mech. description: The right leg of the Ripley APLU. It belongs on the chassis of the mech.
@@ -124,7 +120,7 @@
- RipleyRLeg - RipleyRLeg
- type: entity - type: entity
parent: BaseMechPartItem parent: BaseRipleyPartItem
id: RipleyRArm id: RipleyRArm
name: ripley right arm name: ripley right arm
description: The right arm of the Ripley APLU. It belongs on the chassis of the mech. description: The right arm of the Ripley APLU. It belongs on the chassis of the mech.
@@ -137,10 +133,16 @@
- type: entity - type: entity
id: RipleyChassis id: RipleyChassis
parent: BaseMechConstruct parent: BaseRipleyPart
name: ripley chassis name: ripley chassis
description: An in-progress construction of the Ripley APLU mech. description: An in-progress construction of the Ripley APLU mech.
components: components:
- type: Appearance
- type: ContainerContainer
containers:
battery-container: !type:Container
- type: MechAssemblyVisuals
statePrefix: ripley
- type: Sprite - type: Sprite
noRot: true noRot: true
state: ripley0 state: ripley0

View File

@@ -3,19 +3,8 @@
save: false save: false
abstract: true abstract: true
components: components:
- type: Sprite
netsync: false
drawdepth: Mobs
noRot: true
sprite: Objects/Specific/Mech/mecha.rsi
layers:
- map: [ "enum.MechVisualLayers.Base" ]
state: ripley
- type: MobMover - type: MobMover
- type: Mech - type: Mech
baseState: ripley
openState: ripley-open
brokenState: ripley-broken
- type: MechAir - type: MechAir
- type: DoAfter - type: DoAfter
- type: Repairable - type: Repairable
@@ -77,8 +66,16 @@
id: MechRipley id: MechRipley
parent: BaseMech parent: BaseMech
name: Ripley APLU name: Ripley APLU
description: Versatile and lightly armored, the Ripley is useful for almost any heavy work scenario. The "APLU" stands for Atonomous Power Loading Unit. description: Versatile and lightly armored, the Ripley is useful for almost any heavy work scenario. The "APLU" stands for Autonomous Power Loading Unit.
components: components:
- type: Sprite
netsync: false
drawdepth: Mobs
noRot: true
sprite: Objects/Specific/Mech/mecha.rsi
layers:
- map: [ "enum.MechVisualLayers.Base" ]
state: ripley
- type: FootstepModifier - type: FootstepModifier
footstepSoundCollection: footstepSoundCollection:
path: /Audio/Mecha/sound_mecha_powerloader_step.ogg path: /Audio/Mecha/sound_mecha_powerloader_step.ogg
@@ -102,18 +99,7 @@
parent: MechRipley parent: MechRipley
suffix: Battery suffix: Battery
components: components:
- type: Mech - type: ContainerFill
baseState: ripley containers:
openState: ripley-open mech-battery-slot:
brokenState: ripley-broken - PowerCellHigh
startingBattery: PowerCellHigh
mechToPilotDamageMultiplier: 0.75
- type: MeleeWeapon
hidden: true
attackRate: 1
damage:
types:
Blunt: 14
- type: MovementSpeedModifier
baseWalkSpeed: 2.25
baseSprintSpeed: 3.6