]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix weapon cooldown serialization while mapping (#15123)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Wed, 5 Apr 2023 23:37:50 +0000 (11:37 +1200)
committerGitHub <noreply@github.com>
Wed, 5 Apr 2023 23:37:50 +0000 (17:37 -0600)
Content.Server/Abilities/Mime/MimePowersComponent.cs
Content.Shared/Materials/MaterialStorageComponent.cs
Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Interactions.cs
Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs
Resources/Maps/Test/dev_map.yml

index 6e547d306e1eed731a13182b98903bd667f2d160..e38935742b1c0bbe6281d1bea146d041cbe9ea6e 100644 (file)
@@ -53,7 +53,7 @@ namespace Content.Server.Abilities.Mime
         /// <summary>
         /// How long it takes the mime to get their powers back
         /// </summary>
-        [DataField("vowCooldown", customTypeSerializer: typeof(TimeOffsetSerializer))]
+        [DataField("vowCooldown")]
         public TimeSpan VowCooldown = TimeSpan.FromMinutes(5);
     }
 }
index 0bc0c280c2bb33246798a2ba5a4196be7f6aa901..491c4d3cb73f282ecd17ed00f5f2e445501063d4 100644 (file)
@@ -55,7 +55,7 @@ public sealed class MaterialStorageComponent : Component
     /// <summary>
     /// How long the inserting animation will play
     /// </summary>
-    [DataField("insertionTime", customTypeSerializer: typeof(TimeOffsetSerializer))]
+    [DataField("insertionTime")]
     public TimeSpan InsertionTime = TimeSpan.FromSeconds(0.79f); // 0.01 off for animation timing
 }
 
index 2f9113cc503b410f810fe94f69fde112e43b8c8e..39721a6c3edab67e43389b4c3cfd02ddbd6f417c 100644 (file)
@@ -70,6 +70,16 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
         SubscribeAllEvent<HeavyAttackEvent>(OnHeavyAttack);
         SubscribeAllEvent<DisarmAttackEvent>(OnDisarmAttack);
         SubscribeAllEvent<StopAttackEvent>(OnStopAttack);
+
+#if DEBUG
+        SubscribeLocalEvent<MeleeWeaponComponent, MapInitEvent>(OnMapInit);
+    }
+
+    private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEvent args)
+    {
+        if (component.NextAttack > TimeSpan.Zero)
+            Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
+#endif
     }
 
     private void OnMeleeSelected(EntityUid uid, MeleeWeaponComponent component, HandSelectedEvent args)
@@ -80,6 +90,9 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
         if (!component.ResetOnHandSelected)
             return;
 
+        if (Paused(uid))
+            return;
+
         // If someone swaps to this weapon then reset its cd.
         var curTime = Timing.CurTime;
         var minimum = curTime + TimeSpan.FromSeconds(1 / component.AttackRate);
index 3bd3e9d7897b8bca6f8ea8d3fb5edf9a4d31c9ae..2b5b330fb50e06999be1b5fb60c17a0e9b8f2bea 100644 (file)
@@ -152,7 +152,8 @@ public abstract partial class SharedGunSystem
     {
         // Reset shotting for cycling
         if (Resolve(uid, ref gunComp, false) &&
-            gunComp is { FireRate: > 0f })
+            gunComp is { FireRate: > 0f } &&
+            !Paused(uid))
         {
             gunComp.NextFire = Timing.CurTime + TimeSpan.FromSeconds(1 / gunComp.FireRate);
         }
index 953881d7d6b7c6d1a5d93c49dbe411a4874d9352..ae873f6f60ed25af007e138962b55801e8398f34 100644 (file)
@@ -64,13 +64,17 @@ public abstract partial class SharedGunSystem
 
         DebugTools.Assert((component.AvailableModes  & fire) != 0x0);
         component.SelectedMode = fire;
-        var curTime = Timing.CurTime;
-        var cooldown = TimeSpan.FromSeconds(InteractNextFire);
 
-        if (component.NextFire < curTime)
-            component.NextFire = curTime + cooldown;
-        else
-            component.NextFire += cooldown;
+        if (!Paused(uid))
+        {
+            var curTime = Timing.CurTime;
+            var cooldown = TimeSpan.FromSeconds(InteractNextFire);
+
+            if (component.NextFire < curTime)
+                component.NextFire = curTime + cooldown;
+            else
+                component.NextFire += cooldown;
+        }
 
         Audio.PlayPredicted(component.SoundModeToggle, uid, user);
         Popup(Loc.GetString("gun-selected-mode", ("mode", GetLocSelector(fire))), uid, user);
index 1b0a1221eee49722be9091fa383fed69b1d951c8..34ba12c7cd32450bd0c46997c152e3c901f92619 100644 (file)
@@ -88,6 +88,16 @@ public abstract partial class SharedGunSystem : EntitySystem
         SubscribeLocalEvent<GunComponent, ExaminedEvent>(OnExamine);
         SubscribeLocalEvent<GunComponent, CycleModeEvent>(OnCycleMode);
         SubscribeLocalEvent<GunComponent, ComponentInit>(OnGunInit);
+
+#if DEBUG
+        SubscribeLocalEvent<GunComponent, MapInitEvent>(OnMapInit);
+    }
+
+    private void OnMapInit(EntityUid uid, GunComponent component, MapInitEvent args)
+    {
+        if (component.NextFire > TimeSpan.Zero)
+            Logger.Warning($"Initializing a map that contains an entity that is on cooldown. Entity: {ToPrettyString(uid)}");
+#endif
     }
 
     private void OnGunInit(EntityUid uid, GunComponent component, ComponentInit args)
index a9549ba17b8b7c4eaa7781fae3e2617f4299c373..d7060e0f86959141fd54f6ac6fed7d019bb061df 100644 (file)
@@ -1055,8 +1055,6 @@ entities:
   - pos: -2.172831,4.5306726
     parent: 179
     type: Transform
-  - nextAttack: 384.7724706
-    type: MeleeWeapon
 - uid: 148
   type: Ointment
   components:
@@ -1687,8 +1685,6 @@ entities:
   - pos: -3.4579864,-1.9811735
     parent: 179
     type: Transform
-  - nextAttack: 582.1216812
-    type: MeleeWeapon
 - uid: 186
   type: PowerCellMedium
   components:
@@ -2617,16 +2613,12 @@ entities:
   - pos: -0.11783123,4.753312
     parent: 179
     type: Transform
-  - nextAttack: 244.2972008
-    type: MeleeWeapon
 - uid: 328
   type: MopItem
   components:
   - pos: 7.6382103,16.08618
     parent: 179
     type: Transform
-  - nextAttack: 3088.5283222
-    type: MeleeWeapon
   - solutions:
       absorbed:
         temperature: 293.15
@@ -2728,8 +2720,6 @@ entities:
   - pos: 0.6895334,4.7183027
     parent: 179
     type: Transform
-  - nextAttack: 247.8805212
-    type: MeleeWeapon
 - uid: 344
   type: ClothingHeadHatWelding
   components:
@@ -2838,8 +2828,6 @@ entities:
   - pos: -1.6207478,4.3951616
     parent: 179
     type: Transform
-  - nextAttack: 232.4472496
-    type: MeleeWeapon
 - uid: 360
   type: PowerCellMedium
   components:
@@ -2973,8 +2961,6 @@ entities:
   - pos: -3.277628,-2.15838
     parent: 179
     type: Transform
-  - nextAttack: 578.7883598
-    type: MeleeWeapon
 - uid: 382
   type: SheetSteel
   components:
@@ -3357,8 +3343,6 @@ entities:
   - pos: -1.235331,4.739151
     parent: 179
     type: Transform
-  - nextAttack: 385.5557994
-    type: MeleeWeapon
 - uid: 432
   type: ChemicalPayload
   components:
@@ -3377,8 +3361,6 @@ entities:
   - pos: -3.1734612,-2.6066077
     parent: 179
     type: Transform
-  - nextAttack: 577.9550312
-    type: MeleeWeapon
 - uid: 435
   type: ModularGrenade
   components:
@@ -5099,8 +5081,6 @@ entities:
   - pos: 1.1246341,7.500063
     parent: 179
     type: Transform
-  - nextAttack: 669.0197422
-    type: MeleeWeapon
 - uid: 673
   type: Poweredlight
   components:
@@ -7191,13 +7171,11 @@ entities:
     parent: 179
     type: Transform
 - uid: 956
-  type: EmergencyOxygenTank
+  type: EmergencyOxygenTankFilled
   components:
   - pos: -10.505015,6.711994
     parent: 179
     type: Transform
-  - nextAttack: 396.1132382
-    type: MeleeWeapon
 - uid: 957
   type: AlwaysPoweredLightLED
   components: