Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
8 changes: 8 additions & 0 deletions EXILED/Exiled.API/Features/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ public static Camera Get(Scp079Camera camera079)
/// <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
19 changes: 16 additions & 3 deletions EXILED/Exiled.API/Features/PrefabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ 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)
// TOOD: Only keep this method for Exiled 10
public static GameObject Spawn(PrefabType prefabType, Vector3 position /*= default*/, Quaternion? rotation /*= null*/, bool spawn /*= true*/)
Comment thread
louis1706 marked this conversation as resolved.
Outdated
{
if (!TryGetPrefab(prefabType, out GameObject gameObject))
return null;
Expand All @@ -112,7 +114,7 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default
if (newGameObject.TryGetComponent(out StructurePositionSync positionSync))
{
positionSync.Network_position = position;
positionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(rotation.Value.eulerAngles.y / 5.625F);
positionSync.Network_rotationY = (sbyte)Mathf.RoundToInt(rotation.Value.eulerAngles.y / StructurePositionSync.ConversionRate);
}

#pragma warning disable CS0618 // Type or member is obsolete
Expand All @@ -128,11 +130,22 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default
}
#pragma warning restore CS0618 // Type or member is obsolete

NetworkServer.Spawn(newGameObject);
if (spawn)
NetworkServer.Spawn(newGameObject);

return newGameObject;
}

/// <summary>
/// Spawns the <see cref="GameObject"/> of the specified <see cref="PrefabType"/>.
/// </summary>
/// <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>
/// <returns>Returns the <see cref="GameObject"/> instantied.</returns>
public static GameObject Spawn(PrefabType prefabType, Vector3 position = default, Quaternion? rotation = null)
=> Spawn(prefabType, position, rotation, true);

/// <summary>
/// Spawns the <see cref="GameObject"/> of the specified <see cref="PrefabType"/>.
/// </summary>
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