diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index fa17a7754..7c4958fdd 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -15,6 +15,7 @@ namespace Exiled.API.Features using Exiled.API.Extensions; using Exiled.API.Interfaces; using MapGeneration; + using PlayerRoles.PlayableScps.Scp079; using PlayerRoles.PlayableScps.Scp079.Cameras; using UnityEngine; @@ -274,6 +275,24 @@ public bool IsBeingUsed /// A or if not found. public static Camera Get(Scp079Camera camera079) => camera079 != null ? Camera079ToCamera.TryGetValue(camera079, out Camera camera) ? camera : new(camera079) : null; + /// + /// Gets the belonging to the , if any. + /// + /// The of the camera. + /// A or if not found. + public static Camera Get(GameObject gameObject) + { + foreach (Camera camera in List) + { + if (camera.GameObject == gameObject) + { + return camera; + } + } + + return null; + } + /// /// Gets a given the specified . /// @@ -318,6 +337,14 @@ public bool IsBeingUsed /// if is not , or if is . public static bool TryGet(Scp079Camera camera, out Camera result) => (result = Get(camera)) != null; + /// + /// Gets the belonging to the , if any. + /// + /// The of the camera. + /// The instance of which base. + /// if is not , or if is . + public static bool TryGet(GameObject gameObject, out Camera result) => (result = Get(gameObject)) != null; + /// /// Gets a given the specified . /// diff --git a/EXILED/Exiled.API/Features/PrefabHelper.cs b/EXILED/Exiled.API/Features/PrefabHelper.cs index 179991e63..0b1b66a8d 100644 --- a/EXILED/Exiled.API/Features/PrefabHelper.cs +++ b/EXILED/Exiled.API/Features/PrefabHelper.cs @@ -96,8 +96,9 @@ public static T GetPrefab(PrefabType prefabType) /// The . /// The position where the will spawn. /// The rotation of the . + /// Whether the should be initially spawned. /// Returns the instantied. - public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null) + public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null, bool spawn = true) { if (!TryGetPrefab(prefabType, out GameObject gameObject)) return null; @@ -112,7 +113,8 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default positionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(rotation.Value.eulerAngles.y / 5.625F); } - NetworkServer.Spawn(newGameObject); + if (spawn) + NetworkServer.Spawn(newGameObject); return newGameObject; } diff --git a/EXILED/Exiled.API/Features/Toys/AdminToy.cs b/EXILED/Exiled.API/Features/Toys/AdminToy.cs index c93cee110..99fa27e4e 100644 --- a/EXILED/Exiled.API/Features/Toys/AdminToy.cs +++ b/EXILED/Exiled.API/Features/Toys/AdminToy.cs @@ -176,12 +176,22 @@ public static AdminToy Get(AdminToyBase adminToyBase) /// /// Gets the by . /// - /// The to convert into an admintoy. + /// The to convert into an AdminToy. /// The specified type. - /// The admintoy wrapper for the given . + /// The AdminToy wrapper for the given . public static T Get(AdminToyBase adminToyBase) where T : AdminToy => Get(adminToyBase) as T; + /// + /// Gets the by . + /// + /// The to convert into AdminToy. + /// The specified type. + /// The AdminToy wrapper for the given . + public static T Get(GameObject gameObject) + where T : AdminToy + => Get(gameObject.GetComponent()) as T; + /// /// Spawns the toy into the game. Use to remove it. ///