Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions EXILED/Exiled.API/Features/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -274,6 +275,24 @@ public bool IsBeingUsed
/// <returns>A <see cref="Camera"/> or <see langword="null"/> if not found.</returns>
public static Camera Get(Scp079Camera camera079) => camera079 != null ? Camera079ToCamera.TryGetValue(camera079, out Camera camera) ? camera : new(camera079) : null;

/// <summary>
/// Gets the <see cref="Camera"/> belonging to the <see cref="GameObject"/>, if any.
/// </summary>
/// <param name="gameObject">The <see cref="GameObject"/> of the camera.</param>
/// <returns>A <see cref="Camera"/> or <see langword="null"/> if not found.</returns>
public static Camera Get(GameObject gameObject)
{
foreach (Camera camera in List)
{
if (camera.GameObject == gameObject)
{
return camera;
}
}

return null;
}

Comment thread
Saskyc marked this conversation as resolved.
/// <summary>
/// Gets a <see cref="Camera"/> given the specified <paramref name="cameraId"/>.
/// </summary>
Expand Down Expand Up @@ -318,6 +337,14 @@ public bool IsBeingUsed
/// <returns><see langword="true"/> if <see cref="Camera"/> is not <see langword="null"/>, or <see langword="false"/> if <see cref="Camera"/> is <see langword="null"/>.</returns>
public static bool TryGet(Scp079Camera camera, out Camera result) => (result = Get(camera)) != null;

/// <summary>
/// Gets the <see cref="Camera"/> belonging to the <see cref="Scp079Camera"/>, if any.
/// </summary>
/// <param name="gameObject">The <see cref="GameObject"/> of the camera.</param>
/// <param name="result">The instance of <see cref="Camera"/> which <see cref="Scp079Camera"/> base.</param>
/// <returns><see langword="true"/> if <see cref="Camera"/> is not <see langword="null"/>, or <see langword="false"/> if <see cref="Camera"/> is <see langword="null"/>.</returns>
public static bool TryGet(GameObject gameObject, out Camera result) => (result = Get(gameObject)) != null;

/// <summary>
/// Gets a <see cref="Camera"/> given the specified <paramref name="cameraId"/>.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions EXILED/Exiled.API/Features/PrefabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ public static T GetPrefab<T>(PrefabType prefabType)
/// <param name="prefabType">The <see cref="PrefabType"/>.</param>
/// <param name="position">The <see cref="Vector3"/> position where the <see cref="GameObject"/> will spawn.</param>
/// <param name="rotation">The <see cref="Quaternion"/> rotation of the <see cref="GameObject"/>.</param>
/// <param name="spawn">Whether the <see cref="PrefabType"/> should be initially spawned.</param>
/// <returns>Returns the <see cref="GameObject"/> instantied.</returns>
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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change. Either switch target branch to dev (for Exiled 10), or make this a separate method

{
if (!TryGetPrefab(prefabType, out GameObject gameObject))
return null;
Expand All @@ -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;
}
Expand Down
14 changes: 12 additions & 2 deletions EXILED/Exiled.API/Features/Toys/AdminToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,22 @@ public static AdminToy Get(AdminToyBase adminToyBase)
/// <summary>
/// Gets the <see cref="AdminToy"/> by <see cref="AdminToys.AdminToyBase"/>.
/// </summary>
/// <param name="adminToyBase">The <see cref="AdminToys.AdminToyBase"/> to convert into an admintoy.</param>
/// <param name="adminToyBase">The <see cref="AdminToys.AdminToyBase"/> to convert into an AdminToy.</param>
/// <typeparam name="T">The specified <see cref="AdminToy"/> type.</typeparam>
/// <returns>The admintoy wrapper for the given <see cref="AdminToys.AdminToyBase"/>.</returns>
/// <returns>The AdminToy wrapper for the given <see cref="AdminToys.AdminToyBase"/>.</returns>
public static T Get<T>(AdminToyBase adminToyBase)
where T : AdminToy => Get(adminToyBase) as T;

/// <summary>
/// Gets the <see cref="AdminToy"/> by <see cref="GameObject"/>.
/// </summary>
/// <param name="gameObject">The <see cref="GameObject"/> to convert into AdminToy.</param>
/// <typeparam name="T">The specified <see cref="AdminToy"/> type.</typeparam>
/// <returns>The AdminToy wrapper for the given <see cref="AdminToys.AdminToyBase"/>.</returns>
public static T Get<T>(GameObject gameObject)
where T : AdminToy
=> Get(gameObject.GetComponent<AdminToyBase>()) as T;

/// <summary>
/// Spawns the toy into the game. Use <see cref="UnSpawn"/> to remove it.
/// </summary>
Expand Down
Loading