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
14 changes: 13 additions & 1 deletion EXILED/Exiled.API/Features/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ namespace Exiled.API.Features
using System.Linq;

using Enums;

using Exiled.API.Extensions;
using Exiled.API.Interfaces;

using MapGeneration;
using MapGeneration.Distributors;

using PlayerRoles.PlayableScps.Scp079.Cameras;

using UnityEngine;

using CameraType = Enums.CameraType;
Expand Down Expand Up @@ -260,6 +265,13 @@ public bool IsBeingUsed
set => Base.IsActive = value;
}

/// <summary>
/// Converts Scp079Camera to Camera.
/// </summary>
/// <param name="camera079">The Scp079Camera.</param>
/// <returns>EXILED Camera.</returns>
public static implicit operator Camera(Scp079Camera camera079) => Get(camera079);

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of <see cref="Camera"/> which contains all the <see cref="Camera"/> instances given a <see cref="IEnumerable{T}"/> of <see cref="Scp079Camera"/>.
/// </summary>
Expand All @@ -272,7 +284,7 @@ public bool IsBeingUsed
/// </summary>
/// <param name="camera079">The base <see cref="Scp079Camera"/>.</param>
/// <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;
public static Camera Get(Scp079Camera camera079) => camera079 == null ? null : Camera079ToCamera.TryGetValue(camera079, out Camera camera) ? camera : new(camera079);

/// <summary>
/// Gets a <see cref="Camera"/> given the specified <paramref name="cameraId"/>.
Expand Down
13 changes: 13 additions & 0 deletions EXILED/Exiled.API/Features/Doors/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ namespace Exiled.API.Features.Doors
using Exiled.API.Extensions;
using Exiled.API.Features.Core;
using Exiled.API.Interfaces;

using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;

using MEC;

using Mirror;

using PlayerRoles.PlayableScps.Scp079.Cameras;

using UnityEngine;

using BaseBreakableDoor = Interactables.Interobjects.BreakableDoor;
Expand Down Expand Up @@ -303,6 +309,13 @@ public Vector3 Scale
/// </summary>
internal List<Room> RoomsValue { get; } = new List<Room>();

/// <summary>
/// Converts DoorVariant to Door.
/// </summary>
/// <param name="doorVariant">The DoorVariant.</param>
/// <returns>EXILED Door.</returns>
public static implicit operator Door(DoorVariant doorVariant) => Get(doorVariant);

/// <summary>
/// Gets the door object associated with a specific <see cref="DoorVariant"/>, or creates a new one if there isn't one.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions EXILED/Exiled.API/Features/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ namespace Exiled.API.Features
using System.Linq;

using Enums;

using Exiled.API.Interfaces;

using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;

using MapGeneration.Distributors;

using UnityEngine;
Expand Down Expand Up @@ -219,6 +223,13 @@ public KeycardPermissions KeycardPermissions
set => Base._requiredPermission = (DoorPermissionFlags)value;
}

/// <summary>
/// Converts Scp079Generator to Generator.
/// </summary>
/// <param name="scp079Generator">The Scp079Generator.</param>
/// <returns>EXILED Generator.</returns>
public static implicit operator Generator(Scp079Generator scp079Generator) => Get(scp079Generator);

/// <summary>
/// Gets the <see cref="Generator"/> belonging to the <see cref="Scp079Generator"/>, if any.
/// </summary>
Expand Down
14 changes: 13 additions & 1 deletion EXILED/Exiled.API/Features/Hazards/Hazard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ namespace Exiled.API.Features.Hazards
using Exiled.API.Enums;
using Exiled.API.Features.Core;
using Exiled.API.Interfaces;

using global::Hazards;

using Interactables.Interobjects.DoorUtils;

using PlayerRoles.PlayableScps.Scp939;

using UnityEngine;

/// <summary>
Expand Down Expand Up @@ -113,12 +118,19 @@ public Vector3 Position
set => Base.SourcePosition = value;
}

/// <summary>
/// Converts EnvironmentalHazard to Hazard.
/// </summary>
/// <param name="environmentalHazard">The EnvironmentalHazard.</param>
/// <returns>EXILED Hazard.</returns>
public static implicit operator Hazard(EnvironmentalHazard environmentalHazard) => Get(environmentalHazard);

/// <summary>
/// Gets the <see cref="Hazard"/> by <see cref="EnvironmentalHazard"/>.
/// </summary>
/// <param name="environmentalHazard">The <see cref="EnvironmentalHazard"/> instance.</param>
/// <returns><see cref="Hazard"/> for <see cref="EnvironmentalHazard"/>.</returns>
public static Hazard Get(EnvironmentalHazard environmentalHazard) =>
public static Hazard Get(EnvironmentalHazard environmentalHazard) => environmentalHazard == null ? null :
EnvironmentalHazardToHazard.TryGetValue(environmentalHazard, out Hazard hazard) ? hazard
: environmentalHazard switch
{
Expand Down
4 changes: 4 additions & 0 deletions EXILED/Exiled.API/Features/Items/Firearm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Items
using System.Linq;

using CameraShaking;

using Enums;

using Exiled.API.Features.Items.FirearmModules;
Expand All @@ -20,7 +21,10 @@ namespace Exiled.API.Features.Items
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;
using Exiled.API.Structs;

using Extensions;

using InventorySystem.Items;
using InventorySystem.Items.Autosync;
using InventorySystem.Items.Firearms.Attachments;
using InventorySystem.Items.Firearms.Attachments.Components;
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ public ItemAddReason AddReason
/// </summary>
public ItemIdentifier Identifier => Base.ItemId;

/// <summary>
/// Converts ItemBase to Item.
/// </summary>
/// <param name="itemBase">The ItemBase.</param>
/// <returns>EXILED Item.</returns>
public static implicit operator Item(ItemBase itemBase) => Get(itemBase);

/// <summary>
/// Gets an existing <see cref="Item"/> or creates a new instance of one.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion EXILED/Exiled.API/Features/Lift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public float AnimationTime
/// </summary>
public Doors.ElevatorDoor CurrentDestination => Door.Get<Doors.ElevatorDoor>(Base.DestinationDoor);

/// <summary>
/// Converts ElevatorChamber to Lift.
/// </summary>
/// <param name="elevator">The ElevatorChamber.</param>
/// <returns>EXILED Lift.</returns>
public static implicit operator Lift(ElevatorChamber elevator) => Get(elevator);

/// <summary>
/// Gets a <see cref="IEnumerable{T}"/> of <see cref="Lift"/> which contains all the <see cref="Lift"/> instances from the specified <see cref="Status"/>.
/// </summary>
Expand All @@ -229,7 +236,7 @@ public float AnimationTime
/// </summary>
/// <param name="elevator">The <see cref="ElevatorChamber"/> instance.</param>
/// <returns>A <see cref="Lift"/> or <see langword="null"/> if not found.</returns>
public static Lift Get(ElevatorChamber elevator) => ElevatorChamberToLift.TryGetValue(elevator, out Lift lift) ? lift : new(elevator);
public static Lift Get(ElevatorChamber elevator) => elevator == null ? null : ElevatorChamberToLift.TryGetValue(elevator, out Lift lift) ? lift : new(elevator);

/// <summary>
/// Gets the <see cref="Lift"/> corresponding to the specified <see cref="ElevatorType"/>, if any.
Expand Down
12 changes: 12 additions & 0 deletions EXILED/Exiled.API/Features/Lockers/Chamber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ namespace Exiled.API.Features.Lockers
using Exiled.API.Extensions;
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;

using Interactables.Interobjects;

using InventorySystem.Items.Pickups;

using MapGeneration.Distributors;

using UnityEngine;

/// <summary>
Expand Down Expand Up @@ -189,6 +194,13 @@ public bool IsOpen
/// </summary>
public bool CanInteract => Base.CanInteract;

/// <summary>
/// Converts LockerChamber to Chamber.
/// </summary>
/// <param name="chamber">The LockerChamber.</param>
/// <returns>EXILED Chamber.</returns>
public static implicit operator Chamber(LockerChamber chamber) => Get(chamber);

/// <summary>
/// Adds an item to the current chamber.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Lockers/Locker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ public Vector3 RandomChamberPosition
}
}

/// <summary>
/// Converts BaseLocker to Locker.
/// </summary>
/// <param name="locker">The BaseLocker.</param>
/// <returns>EXILED Locker.</returns>
public static implicit operator Locker?(BaseLocker locker) => Get(locker);

/// <summary>
/// Gets the <see cref="Locker"/> belonging to the <see cref="BaseLocker"/>, if any.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Pickups/Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ public Quaternion Rotation
/// </summary>
public bool IsSpawned => NetworkServer.spawned.ContainsValue(Base.netIdentity);

/// <summary>
/// Converts ItemPickupBase to Pickup.
/// </summary>
/// <param name="pickupBase">The ItemPickupBase.</param>
/// <returns>EXILED Pickup.</returns>
public static implicit operator Pickup(ItemPickupBase pickupBase) => Get(pickupBase);

/// <summary>
/// Gets an existing <see cref="Pickup"/> or creates a new instance of one.
/// </summary>
Expand Down
15 changes: 11 additions & 4 deletions EXILED/Exiled.API/Features/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,17 +1229,24 @@ public bool IsSpawnProtected
protected HealthStat CustomHealthStat { get; set; }

/// <summary>
/// Converts LabApi player to EXILED player.
/// Converts ReferenceHub to Player.
/// </summary>
/// <param name="player">The LabApi player.</param>
/// <param name="hub">The ReferenceHub.</param>
/// <returns>EXILED player.</returns>
public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player);
public static implicit operator Player(ReferenceHub hub) => Get(hub);

/// <summary>
/// Converts LabApi player to EXILED player.
/// </summary>
/// <param name="player">The LabApi player.</param>
/// <returns>EXILED player.</returns>
public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player);

/// <summary>
/// Converts EXILED player to LabApi player.
/// </summary>
/// <param name="player">The EXILED player.</param>
/// <returns>LabApi player.</returns>
public static implicit operator LabApi.Features.Wrappers.Player(Player player) => LabApi.Features.Wrappers.Player.Get(player?.ReferenceHub);

/// <summary>
Expand Down Expand Up @@ -1435,7 +1442,7 @@ public static Player Get(string args)
/// </summary>
/// <param name="apiPlayer">The <see cref="LabApi.Features.Wrappers.Player"/> class.</param>
/// <returns>A <see cref="Player"/> or <see langword="null"/> if not found.</returns>
public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer.ReferenceHub);
public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer?.ReferenceHub);

/// <summary>
/// Try-get a player given a <see cref="CommandSystem.ICommandSender"/>.
Expand Down
7 changes: 7 additions & 0 deletions EXILED/Exiled.API/Features/Ragdoll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,13 @@ public Vector3 RagdollScale
/// </summary>
internal static HashSet<BasicRagdoll> IgnoredRagdolls { get; set; } = new();

/// <summary>
/// Converts BasicRagdoll to Ragdoll.
/// </summary>
/// <param name="basicRagdoll">The BasicRagdoll.</param>
/// <returns>EXILED Ragdoll.</returns>
public static implicit operator Ragdoll(BasicRagdoll basicRagdoll) => Get(basicRagdoll);

/// <summary>
/// Gets the last ragdoll of the player.
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions EXILED/Exiled.API/Features/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@ namespace Exiled.API.Features
using System.Linq;

using Enums;

using Exiled.API.Extensions;
using Exiled.API.Features.Doors;
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;

using MapGeneration;
using MapGeneration.Holidays;
using MapGeneration.Rooms;

using MEC;

using Mirror;

using PlayerRoles.PlayableScps.Scp079;
using PlayerRoles.Ragdolls;

using RelativePositioning;

using UnityEngine;

using Utils.NonAllocLINQ;

/// <summary>
Expand Down Expand Up @@ -227,6 +236,13 @@ public bool AreLightsOff
/// </summary>
internal List<Room> NearestRoomsValue { get; } = new();

/// <summary>
/// Converts RoomIdentifier to Room.
/// </summary>
/// <param name="roomIdentifier">The RoomIdentifier.</param>
/// <returns>EXILED Room.</returns>
public static implicit operator Room(RoomIdentifier roomIdentifier) => Get(roomIdentifier);

/// <summary>
/// Gets a <see cref="Room"/> given the specified <see cref="RoomType"/>.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Scp559.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Vector3 Position
/// </summary>
/// <param name="cake">Game instance.</param>
/// <returns><see cref="Scp559"/>.</returns>
public static Scp559 Get(Scp559Cake cake) => CakeToWrapper.TryGetValue(cake, out Scp559 scp559) ? scp559 : new Scp559(cake);
public static Scp559 Get(Scp559Cake cake) => cake == null ? null : CakeToWrapper.TryGetValue(cake, out Scp559 scp559) ? scp559 : new Scp559(cake);

/// <summary>
/// Gets the <see cref="IEnumerable{T}"/> of SCP-559 which matches the predicate.
Expand Down
15 changes: 14 additions & 1 deletion EXILED/Exiled.API/Features/TeslaGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ namespace Exiled.API.Features
using System.Linq;

using Exiled.API.Interfaces;

using Hazards;

using InventorySystem.Items.Firearms.Attachments;

using MEC;

using PlayerRoles;

using UnityEngine;

using BaseTeslaGate = global::TeslaGate;
Expand Down Expand Up @@ -195,12 +201,19 @@ public bool UseInstantBurst
/// </summary>
public IEnumerable<Player> PlayersInTriggerRange => Player.List.Where(IsPlayerInTriggerRange);

/// <summary>
/// Converts BaseTeslaGate to TeslaGate.
/// </summary>
/// <param name="baseTeslaGate">The BaseTeslaGate.</param>
/// <returns>EXILED TeslaGate.</returns>
public static implicit operator TeslaGate(BaseTeslaGate baseTeslaGate) => Get(baseTeslaGate);

/// <summary>
/// Gets the <see cref="TeslaGate"/> belonging to the <see cref="BaseTeslaGate"/>.
/// </summary>
/// <param name="baseTeslaGate">The <see cref="BaseTeslaGate"/> instance.</param>
/// <returns>The corresponding <see cref="TeslaGate"/> instance.</returns>
public static TeslaGate Get(BaseTeslaGate baseTeslaGate) => BaseTeslaGateToTeslaGate.TryGetValue(baseTeslaGate, out TeslaGate teslagate) ?
public static TeslaGate Get(BaseTeslaGate baseTeslaGate) => baseTeslaGate == null ? null : BaseTeslaGateToTeslaGate.TryGetValue(baseTeslaGate, out TeslaGate teslagate) ?
teslagate :
new(baseTeslaGate, Room.FindParentRoom(baseTeslaGate.gameObject));

Expand Down
Loading
Loading