]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
mech tweaks (#15619)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Mon, 24 Apr 2023 21:00:36 +0000 (21:00 +0000)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2023 21:00:36 +0000 (17:00 -0400)
Content.Server/Mech/Systems/MechSystem.cs
Content.Shared/Mech/Components/MechComponent.cs
Resources/Prototypes/Entities/Objects/Specific/Mech/mech_construction.yml
Resources/Prototypes/Entities/Objects/Specific/Mech/mechs.yml

index 7e1422ba1060566ee6a641e4339fa6ce5608688b..60eee7f881c4d8d0129da15e0c58e588399d76b0 100644 (file)
@@ -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<MechComponent, InteractUsingEvent>(OnInteractUsing);
+        SubscribeLocalEvent<MechComponent, EntInsertedIntoContainerMessage>(OnInsertBattery);
         SubscribeLocalEvent<MechComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<MechComponent, GetVerbsEvent<AlternativeVerb>>(OnAlternativeVerb);
         SubscribeLocalEvent<MechComponent, MechOpenUiEvent>(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<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)
     {
         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);
     }
index b128e65019b2d11855a49fdb29709e662f9626c4..9c00d3d5524ccd58d3640718c44de8903191f762 100644 (file)
@@ -138,13 +138,6 @@ public sealed class MechComponent : Component
     [DataField("startingEquipment", customTypeSerializer: typeof(PrototypeIdListSerializer<EntityPrototype>))]
     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
     [DataField("mechCycleAction", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
     public string MechCycleAction = "MechCycleEquipment";
index 6b80066b4e861ee7f6d492cfc7b4e1e77a6b2688..16f273ff446bb36e2d0a256b40d5278dca41dc91 100644 (file)
       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
     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.
   - 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.
     - 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.
     - 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.
     - 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.
 
 - 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
index 80341063f5049a8b5f564ce823d3d954195cfcdd..d752a28f8643e969e7033b4a65a10d4ff7442ce3 100644 (file)
@@ -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
   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
   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