Skip to content

Commit

Permalink
[EXILED::API] Adding SpawnMice (#2765)
Browse files Browse the repository at this point in the history
* Mice Spawner (Infinite lil rats)

* Renamed

* Fix Build error

* Fixed overflow and Optimized

* Update Exiled.API/Features/Map.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

* Update Exiled.API/Features/Map.cs

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>

* More appropriate error

---------

Co-authored-by: Nao <60253860+NaoUnderscore@users.noreply.github.com>
  • Loading branch information
NotZer0Two and NaoUnderscore authored Aug 14, 2024
1 parent dd7673b commit 25b9a02
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Exiled.API/Features/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static class Map
internal static readonly List<AdminToy> ToysValue = new();

private static AmbientSoundPlayer ambientSoundPlayer;
private static SqueakSpawner squeakSpawner;

/// <summary>
/// Gets a value indicating whether decontamination has begun in the light containment zone.
Expand Down Expand Up @@ -99,6 +100,11 @@ public static int Seed
/// </summary>
public static AmbientSoundPlayer AmbientSoundPlayer => ambientSoundPlayer ??= ReferenceHub.HostHub.GetComponent<AmbientSoundPlayer>();

/// <summary>
/// Gets the <see cref="global::SqueakSpawner"/>.
/// </summary>
public static SqueakSpawner SqueakSpawner => squeakSpawner ??= Object.FindObjectOfType<SqueakSpawner>();

/// <summary>
/// Broadcasts a message to all <see cref="Player">players</see>.
/// </summary>
Expand Down Expand Up @@ -353,6 +359,19 @@ public static void PlayGunSound(Vector3 position, ItemType firearmType, byte max
msg.SendToAuthenticated();
}

/// <summary>
/// Spawns mice inside the <see cref="RoomType.EzShelter"/>.
/// </summary>
/// <param name="mice">The type of mice you want to spawn..</param>
public static void SpawnMice(byte mice = 1)
{
if (mice > SqueakSpawner.mice.Length)
throw new ArgumentOutOfRangeException($"Mouse type must be between 1 and {SqueakSpawner.mice.Length}.");

SqueakSpawner.NetworksyncSpawn = mice;
SqueakSpawner.SyncMouseSpawn(0, SqueakSpawner.NetworksyncSpawn);
}

/// <summary>
/// Clears the lazy loading game object cache.
/// </summary>
Expand Down

0 comments on commit 25b9a02

Please sign in to comment.