From dd4cf48c0a65e3b2a32e86d82fc975c9115b3bec Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Mon, 24 Apr 2023 21:00:36 +0000 Subject: [PATCH] mech tweaks (#15619) --- Content.Server/Mech/Systems/MechSystem.cs | 21 +++++--- .../Mech/Components/MechComponent.cs | 7 --- .../Specific/Mech/mech_construction.yml | 52 ++++++++++--------- .../Entities/Objects/Specific/Mech/mechs.yml | 40 +++++--------- 4 files changed, 55 insertions(+), 65 deletions(-) diff --git a/Content.Server/Mech/Systems/MechSystem.cs b/Content.Server/Mech/Systems/MechSystem.cs index 7e1422ba10..60eee7f881 100644 --- a/Content.Server/Mech/Systems/MechSystem.cs +++ b/Content.Server/Mech/Systems/MechSystem.cs @@ -16,6 +16,7 @@ using Content.Shared.Verbs; using Content.Shared.Wires; using Robust.Server.Containers; using Robust.Server.GameObjects; +using Robust.Shared.Containers; using Robust.Shared.Map; namespace Content.Server.Mech.Systems; @@ -41,6 +42,7 @@ public sealed class MechSystem : SharedMechSystem _sawmill = Logger.GetSawmill("mech"); SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnInsertBattery); SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent>(OnAlternativeVerb); SubscribeLocalEvent(OnOpenUi); @@ -69,6 +71,7 @@ public sealed class MechSystem : SharedMechSystem if (component.Broken || component.Integrity <= 0 || component.Energy <= 0) args.Cancel(); } + private void OnInteractUsing(EntityUid uid, MechComponent component, InteractUsingEvent args) { if (TryComp(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(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) { if (args.Cancelled || args.Handled) @@ -115,12 +130,6 @@ public sealed class MechSystem : SharedMechSystem component.Integrity = component.MaxIntegrity; component.Energy = component.MaxEnergy; - if (component.StartingBattery != null) - { - var battery = Spawn(component.StartingBattery, Transform(uid).Coordinates); - InsertBattery(uid, battery, component); - } - _actionBlocker.UpdateCanMove(uid); Dirty(component); } diff --git a/Content.Shared/Mech/Components/MechComponent.cs b/Content.Shared/Mech/Components/MechComponent.cs index b128e65019..9c00d3d552 100644 --- a/Content.Shared/Mech/Components/MechComponent.cs +++ b/Content.Shared/Mech/Components/MechComponent.cs @@ -138,13 +138,6 @@ public sealed class MechComponent : Component [DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer))] public List StartingEquipment = new(); - /// - /// The battery the mech initially has when it spawns - /// Good for admemes and nukie mechs. - /// - [DataField("startingBattery", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? StartingBattery; - #region Action Prototypes [DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer))] public string MechCycleAction = "MechCycleEquipment"; diff --git a/Resources/Prototypes/Entities/Objects/Specific/Mech/mech_construction.yml b/Resources/Prototypes/Entities/Objects/Specific/Mech/mech_construction.yml index 6b80066b4e..16f273ff44 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Mech/mech_construction.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Mech/mech_construction.yml @@ -21,6 +21,14 @@ restitution: 0.3 # fite me friction: 0.2 - type: Pullable + +# Ripley APLU + +- type: entity + id: BaseRipleyPart + parent: BaseMechPart + abstract: true + components: - type: Sprite drawdepth: Items noRot: false @@ -28,27 +36,15 @@ sprite: Objects/Specific/Mech/ripley_construction.rsi - type: entity - id: BaseMechPartItem - parent: BaseMechPart + id: BaseRipleyPartItem + parent: BaseRipleyPart abstract: true components: - type: Item size: 50 - type: entity - id: BaseMechConstruct - parent: BaseMechPart - abstract: true - components: - - type: Appearance - - type: ContainerContainer - containers: - battery-container: !type:Container - - type: MechAssemblyVisuals - statePrefix: ripley - -- type: entity - parent: BaseMechPart + parent: BaseRipleyPart id: RipleyHarness name: ripley harness description: The core of the Ripley APLU. @@ -57,19 +53,19 @@ - type: ItemMapper mapLayers: ripley_l_arm+o: - whitelist: + whitelist: tags: - RipleyLArm ripley_r_arm+o: - whitelist: + whitelist: tags: - RipleyRArm ripley_l_leg+o: - whitelist: + whitelist: tags: - RipleyLLeg ripley_r_leg+o: - whitelist: + whitelist: tags: - RipleyRLeg sprite: Objects/Specific/Mech/ripley_construction.rsi @@ -88,7 +84,7 @@ noRot: true - type: entity - parent: BaseMechPartItem + parent: BaseRipleyPartItem id: RipleyLArm name: ripley left arm description: The left arm of the Ripley APLU. It belongs on the chassis of the mech. @@ -100,7 +96,7 @@ - RipleyLArm - type: entity - parent: BaseMechPartItem + parent: BaseRipleyPartItem id: RipleyLLeg name: ripley left leg description: The left leg of the Ripley APLU. It belongs on the chassis of the mech. @@ -112,7 +108,7 @@ - RipleyLLeg - type: entity - parent: BaseMechPartItem + parent: BaseRipleyPartItem id: RipleyRLeg name: ripley right leg description: The right leg of the Ripley APLU. It belongs on the chassis of the mech. @@ -124,7 +120,7 @@ - RipleyRLeg - type: entity - parent: BaseMechPartItem + parent: BaseRipleyPartItem id: RipleyRArm name: ripley right arm description: The right arm of the Ripley APLU. It belongs on the chassis of the mech. @@ -137,14 +133,20 @@ - type: entity id: RipleyChassis - parent: BaseMechConstruct + parent: BaseRipleyPart name: ripley chassis description: An in-progress construction of the Ripley APLU mech. components: + - type: Appearance + - type: ContainerContainer + containers: + battery-container: !type:Container + - type: MechAssemblyVisuals + statePrefix: ripley - type: Sprite noRot: true state: ripley0 - type: Construction graph: Ripley node: start - defaultTarget: ripley \ No newline at end of file + defaultTarget: ripley diff --git a/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml b/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml index 80341063f5..d752a28f86 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml @@ -3,19 +3,8 @@ save: false abstract: true 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: Mech - baseState: ripley - openState: ripley-open - brokenState: ripley-broken - type: MechAir - type: DoAfter - type: Repairable @@ -77,8 +66,16 @@ id: MechRipley parent: BaseMech 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: + - type: Sprite + netsync: false + drawdepth: Mobs + noRot: true + sprite: Objects/Specific/Mech/mecha.rsi + layers: + - map: [ "enum.MechVisualLayers.Base" ] + state: ripley - type: FootstepModifier footstepSoundCollection: path: /Audio/Mecha/sound_mecha_powerloader_step.ogg @@ -102,18 +99,7 @@ parent: MechRipley suffix: Battery components: - - type: Mech - baseState: ripley - openState: ripley-open - brokenState: ripley-broken - startingBattery: PowerCellHigh - mechToPilotDamageMultiplier: 0.75 - - type: MeleeWeapon - hidden: true - attackRate: 1 - damage: - types: - Blunt: 14 - - type: MovementSpeedModifier - baseWalkSpeed: 2.25 - baseSprintSpeed: 3.6 \ No newline at end of file + - type: ContainerFill + containers: + mech-battery-slot: + - PowerCellHigh