From 4ee47f65e37119d3ec712d12329bd555a70133b3 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 08:00:07 +0200 Subject: [PATCH 1/7] Mice Spawner (Infinite lil rats) --- Exiled.API/Features/Map.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 791dc9a6ad..7c059017e5 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -353,6 +353,18 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max msg.SendToAuthenticated(); } + /// + /// Spawns a Mice inside the . + /// + /// Amount of mice you want to spawn + public static void PlaceMice(byte mice = 1) + { + SqueakSpawner squeakSpawner = UnityEngine.Object.FindObjectOfType(); + + squeakSpawner.NetworksyncSpawn = mice; + squeakSpawner.SyncMouseSpawn(0, squeakSpawner.NetworksyncSpawn); + } + /// /// Clears the lazy loading game object cache. /// From 3ffb7e39cef65fd02b39a0eab804417b45adf55c Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 08:01:27 +0200 Subject: [PATCH 2/7] Renamed --- Exiled.API/Features/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 7c059017e5..53b5e883b6 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -357,7 +357,7 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max /// Spawns a Mice inside the . /// /// Amount of mice you want to spawn - public static void PlaceMice(byte mice = 1) + public static void SpawnMice(byte mice = 1) { SqueakSpawner squeakSpawner = UnityEngine.Object.FindObjectOfType(); From 18c202d88a7407cd920c1a6e58a74089fa5cc358 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 08:17:50 +0200 Subject: [PATCH 3/7] Fix Build error --- Exiled.API/Features/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 53b5e883b6..ca809bfdeb 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -356,7 +356,7 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max /// /// Spawns a Mice inside the . /// - /// Amount of mice you want to spawn + /// Amount of mice you want to spawn. public static void SpawnMice(byte mice = 1) { SqueakSpawner squeakSpawner = UnityEngine.Object.FindObjectOfType(); From 68642aeffbc7d4fcdc9403d718d9b45f09b19560 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Sun, 11 Aug 2024 11:53:17 +0200 Subject: [PATCH 4/7] Fixed overflow and Optimized --- Exiled.API/Features/Map.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index ca809bfdeb..241a87456c 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -51,6 +51,7 @@ public static class Map internal static readonly List ToysValue = new(); private static AmbientSoundPlayer ambientSoundPlayer; + private static SqueakSpawner squeakSpawner; /// /// Gets a value indicating whether decontamination has begun in the light containment zone. @@ -99,6 +100,11 @@ public static int Seed /// public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer ??= ReferenceHub.HostHub.GetComponent(); + /// + /// Gets the . + /// + public static SqueakSpawner SqueakSpawner => squeakSpawner ??= Object.FindObjectOfType(); + /// /// Broadcasts a message to all players. /// @@ -356,13 +362,14 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max /// /// Spawns a Mice inside the . /// - /// Amount of mice you want to spawn. + /// The type of mice you want to spawn.. public static void SpawnMice(byte mice = 1) { - SqueakSpawner squeakSpawner = UnityEngine.Object.FindObjectOfType(); + if (mice > SqueakSpawner.mice.Length) + new OverflowException($"The mice type are from 1 to {SqueakSpawner.mice.Length}"); - squeakSpawner.NetworksyncSpawn = mice; - squeakSpawner.SyncMouseSpawn(0, squeakSpawner.NetworksyncSpawn); + SqueakSpawner.NetworksyncSpawn = mice; + SqueakSpawner.SyncMouseSpawn(0, SqueakSpawner.NetworksyncSpawn); } /// From b79634ad451e9c92a1b970a7d5ca897e65bffeed Mon Sep 17 00:00:00 2001 From: ZeroTwo <63092138+NotZer0Two@users.noreply.github.com> Date: Mon, 12 Aug 2024 08:04:52 +0200 Subject: [PATCH 5/7] Update Exiled.API/Features/Map.cs Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com> --- Exiled.API/Features/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index 241a87456c..efbb38ca9d 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -360,7 +360,7 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max } /// - /// Spawns a Mice inside the . + /// Spawns mice inside the . /// /// The type of mice you want to spawn.. public static void SpawnMice(byte mice = 1) From 5d5af81829251c54e086dec4aa525eea1920c11d Mon Sep 17 00:00:00 2001 From: ZeroTwo <63092138+NotZer0Two@users.noreply.github.com> Date: Mon, 12 Aug 2024 08:05:04 +0200 Subject: [PATCH 6/7] Update Exiled.API/Features/Map.cs Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com> --- Exiled.API/Features/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index efbb38ca9d..c56f91bdc4 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -366,7 +366,7 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max public static void SpawnMice(byte mice = 1) { if (mice > SqueakSpawner.mice.Length) - new OverflowException($"The mice type are from 1 to {SqueakSpawner.mice.Length}"); + throw new OverflowException($"Mouse type must be between 1 and {SqueakSpawner.mice.Length}."); SqueakSpawner.NetworksyncSpawn = mice; SqueakSpawner.SyncMouseSpawn(0, SqueakSpawner.NetworksyncSpawn); From f4e96763f8bdd672a43f82563f781ddc9bab8b78 Mon Sep 17 00:00:00 2001 From: NotZer0Two Date: Mon, 12 Aug 2024 11:43:25 +0200 Subject: [PATCH 7/7] More appropriate error --- Exiled.API/Features/Map.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exiled.API/Features/Map.cs b/Exiled.API/Features/Map.cs index c56f91bdc4..998b3ad13d 100644 --- a/Exiled.API/Features/Map.cs +++ b/Exiled.API/Features/Map.cs @@ -366,7 +366,7 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max public static void SpawnMice(byte mice = 1) { if (mice > SqueakSpawner.mice.Length) - throw new OverflowException($"Mouse type must be between 1 and {SqueakSpawner.mice.Length}."); + throw new ArgumentOutOfRangeException($"Mouse type must be between 1 and {SqueakSpawner.mice.Length}."); SqueakSpawner.NetworksyncSpawn = mice; SqueakSpawner.SyncMouseSpawn(0, SqueakSpawner.NetworksyncSpawn);