diff --git a/EXILED/Exiled.API/Features/Camera.cs b/EXILED/Exiled.API/Features/Camera.cs index fa17a77540..3f67057e7b 100644 --- a/EXILED/Exiled.API/Features/Camera.cs +++ b/EXILED/Exiled.API/Features/Camera.cs @@ -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; @@ -260,6 +265,13 @@ public bool IsBeingUsed set => Base.IsActive = value; } + /// + /// Converts Scp079Camera to Camera. + /// + /// The Scp079Camera. + /// EXILED Camera. + public static implicit operator Camera(Scp079Camera camera079) => Get(camera079); + /// /// Gets a of which contains all the instances given a of . /// @@ -272,7 +284,7 @@ public bool IsBeingUsed /// /// The base . /// A or if not found. - 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); /// /// Gets a given the specified . diff --git a/EXILED/Exiled.API/Features/Doors/Door.cs b/EXILED/Exiled.API/Features/Doors/Door.cs index a8163f207c..ecfe2c2ce7 100644 --- a/EXILED/Exiled.API/Features/Doors/Door.cs +++ b/EXILED/Exiled.API/Features/Doors/Door.cs @@ -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; @@ -303,6 +309,13 @@ public Vector3 Scale /// internal List RoomsValue { get; } = new List(); + /// + /// Converts DoorVariant to Door. + /// + /// The DoorVariant. + /// EXILED Door. + public static implicit operator Door(DoorVariant doorVariant) => Get(doorVariant); + /// /// Gets the door object associated with a specific , or creates a new one if there isn't one. /// diff --git a/EXILED/Exiled.API/Features/Generator.cs b/EXILED/Exiled.API/Features/Generator.cs index b19369208d..e7893b8f7f 100644 --- a/EXILED/Exiled.API/Features/Generator.cs +++ b/EXILED/Exiled.API/Features/Generator.cs @@ -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; @@ -219,6 +223,13 @@ public KeycardPermissions KeycardPermissions set => Base._requiredPermission = (DoorPermissionFlags)value; } + /// + /// Converts Scp079Generator to Generator. + /// + /// The Scp079Generator. + /// EXILED Generator. + public static implicit operator Generator(Scp079Generator scp079Generator) => Get(scp079Generator); + /// /// Gets the belonging to the , if any. /// diff --git a/EXILED/Exiled.API/Features/Hazards/Hazard.cs b/EXILED/Exiled.API/Features/Hazards/Hazard.cs index 22d620092a..dd9205e31a 100644 --- a/EXILED/Exiled.API/Features/Hazards/Hazard.cs +++ b/EXILED/Exiled.API/Features/Hazards/Hazard.cs @@ -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; /// @@ -113,12 +118,19 @@ public Vector3 Position set => Base.SourcePosition = value; } + /// + /// Converts EnvironmentalHazard to Hazard. + /// + /// The EnvironmentalHazard. + /// EXILED Hazard. + public static implicit operator Hazard(EnvironmentalHazard environmentalHazard) => Get(environmentalHazard); + /// /// Gets the by . /// /// The instance. /// for . - public static Hazard Get(EnvironmentalHazard environmentalHazard) => + public static Hazard Get(EnvironmentalHazard environmentalHazard) => environmentalHazard == null ? null : EnvironmentalHazardToHazard.TryGetValue(environmentalHazard, out Hazard hazard) ? hazard : environmentalHazard switch { diff --git a/EXILED/Exiled.API/Features/Items/Firearm.cs b/EXILED/Exiled.API/Features/Items/Firearm.cs index 56215591af..5996da1508 100644 --- a/EXILED/Exiled.API/Features/Items/Firearm.cs +++ b/EXILED/Exiled.API/Features/Items/Firearm.cs @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Items using System.Linq; using CameraShaking; + using Enums; using Exiled.API.Features.Items.FirearmModules; @@ -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; diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 89bb189c42..a7b2372a68 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -204,6 +204,13 @@ public ItemAddReason AddReason /// public ItemIdentifier Identifier => Base.ItemId; + /// + /// Converts ItemBase to Item. + /// + /// The ItemBase. + /// EXILED Item. + public static implicit operator Item(ItemBase itemBase) => Get(itemBase); + /// /// Gets an existing or creates a new instance of one. /// diff --git a/EXILED/Exiled.API/Features/Lift.cs b/EXILED/Exiled.API/Features/Lift.cs index d191cd6764..40ab56306b 100644 --- a/EXILED/Exiled.API/Features/Lift.cs +++ b/EXILED/Exiled.API/Features/Lift.cs @@ -217,6 +217,13 @@ public float AnimationTime /// public Doors.ElevatorDoor CurrentDestination => Door.Get(Base.DestinationDoor); + /// + /// Converts ElevatorChamber to Lift. + /// + /// The ElevatorChamber. + /// EXILED Lift. + public static implicit operator Lift(ElevatorChamber elevator) => Get(elevator); + /// /// Gets a of which contains all the instances from the specified . /// @@ -229,7 +236,7 @@ public float AnimationTime /// /// The instance. /// A or if not found. - 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); /// /// Gets the corresponding to the specified , if any. diff --git a/EXILED/Exiled.API/Features/Lockers/Chamber.cs b/EXILED/Exiled.API/Features/Lockers/Chamber.cs index 610fcaa90f..5b7c0f878a 100644 --- a/EXILED/Exiled.API/Features/Lockers/Chamber.cs +++ b/EXILED/Exiled.API/Features/Lockers/Chamber.cs @@ -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; /// @@ -189,6 +194,13 @@ public bool IsOpen /// public bool CanInteract => Base.CanInteract; + /// + /// Converts LockerChamber to Chamber. + /// + /// The LockerChamber. + /// EXILED Chamber. + public static implicit operator Chamber(LockerChamber chamber) => Get(chamber); + /// /// Adds an item to the current chamber. /// diff --git a/EXILED/Exiled.API/Features/Lockers/Locker.cs b/EXILED/Exiled.API/Features/Lockers/Locker.cs index 734f849fb2..c547396200 100644 --- a/EXILED/Exiled.API/Features/Lockers/Locker.cs +++ b/EXILED/Exiled.API/Features/Lockers/Locker.cs @@ -123,6 +123,13 @@ public Vector3 RandomChamberPosition } } + /// + /// Converts BaseLocker to Locker. + /// + /// The BaseLocker. + /// EXILED Locker. + public static implicit operator Locker?(BaseLocker locker) => Get(locker); + /// /// Gets the belonging to the , if any. /// diff --git a/EXILED/Exiled.API/Features/Pickups/Pickup.cs b/EXILED/Exiled.API/Features/Pickups/Pickup.cs index 5dcceb6135..38bd965a9a 100644 --- a/EXILED/Exiled.API/Features/Pickups/Pickup.cs +++ b/EXILED/Exiled.API/Features/Pickups/Pickup.cs @@ -293,6 +293,13 @@ public Quaternion Rotation /// public bool IsSpawned => NetworkServer.spawned.ContainsValue(Base.netIdentity); + /// + /// Converts ItemPickupBase to Pickup. + /// + /// The ItemPickupBase. + /// EXILED Pickup. + public static implicit operator Pickup(ItemPickupBase pickupBase) => Get(pickupBase); + /// /// Gets an existing or creates a new instance of one. /// diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index d91e703c01..0f07bd638d 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1229,17 +1229,24 @@ public bool IsSpawnProtected protected HealthStat CustomHealthStat { get; set; } /// - /// Converts LabApi player to EXILED player. + /// Converts ReferenceHub to Player. /// - /// The LabApi player. + /// The ReferenceHub. /// EXILED player. - public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player); + public static implicit operator Player(ReferenceHub hub) => Get(hub); /// /// Converts LabApi player to EXILED player. /// /// The LabApi player. /// EXILED player. + public static implicit operator Player(LabApi.Features.Wrappers.Player player) => Get(player); + + /// + /// Converts EXILED player to LabApi player. + /// + /// The EXILED player. + /// LabApi player. public static implicit operator LabApi.Features.Wrappers.Player(Player player) => LabApi.Features.Wrappers.Player.Get(player?.ReferenceHub); /// @@ -1435,7 +1442,7 @@ public static Player Get(string args) /// /// The class. /// A or if not found. - public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer.ReferenceHub); + public static Player Get(LabApi.Features.Wrappers.Player apiPlayer) => Get(apiPlayer?.ReferenceHub); /// /// Try-get a player given a . diff --git a/EXILED/Exiled.API/Features/Ragdoll.cs b/EXILED/Exiled.API/Features/Ragdoll.cs index 19321ee35d..fc3abe7fd1 100644 --- a/EXILED/Exiled.API/Features/Ragdoll.cs +++ b/EXILED/Exiled.API/Features/Ragdoll.cs @@ -299,6 +299,13 @@ public Vector3 RagdollScale /// internal static HashSet IgnoredRagdolls { get; set; } = new(); + /// + /// Converts BasicRagdoll to Ragdoll. + /// + /// The BasicRagdoll. + /// EXILED Ragdoll. + public static implicit operator Ragdoll(BasicRagdoll basicRagdoll) => Get(basicRagdoll); + /// /// Gets the last ragdoll of the player. /// diff --git a/EXILED/Exiled.API/Features/Room.cs b/EXILED/Exiled.API/Features/Room.cs index 846a76509c..1eb1b7f518 100644 --- a/EXILED/Exiled.API/Features/Room.cs +++ b/EXILED/Exiled.API/Features/Room.cs @@ -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; /// @@ -227,6 +236,13 @@ public bool AreLightsOff /// internal List NearestRoomsValue { get; } = new(); + /// + /// Converts RoomIdentifier to Room. + /// + /// The RoomIdentifier. + /// EXILED Room. + public static implicit operator Room(RoomIdentifier roomIdentifier) => Get(roomIdentifier); + /// /// Gets a given the specified . /// diff --git a/EXILED/Exiled.API/Features/Scp559.cs b/EXILED/Exiled.API/Features/Scp559.cs index 246a030d7f..87b4b4b943 100644 --- a/EXILED/Exiled.API/Features/Scp559.cs +++ b/EXILED/Exiled.API/Features/Scp559.cs @@ -131,7 +131,7 @@ public Vector3 Position /// /// Game instance. /// . - 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); /// /// Gets the of SCP-559 which matches the predicate. diff --git a/EXILED/Exiled.API/Features/TeslaGate.cs b/EXILED/Exiled.API/Features/TeslaGate.cs index ddc04ac791..fe3341d5b2 100644 --- a/EXILED/Exiled.API/Features/TeslaGate.cs +++ b/EXILED/Exiled.API/Features/TeslaGate.cs @@ -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; @@ -195,12 +201,19 @@ public bool UseInstantBurst /// public IEnumerable PlayersInTriggerRange => Player.List.Where(IsPlayerInTriggerRange); + /// + /// Converts BaseTeslaGate to TeslaGate. + /// + /// The BaseTeslaGate. + /// EXILED TeslaGate. + public static implicit operator TeslaGate(BaseTeslaGate baseTeslaGate) => Get(baseTeslaGate); + /// /// Gets the belonging to the . /// /// The instance. /// The corresponding instance. - 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)); diff --git a/EXILED/Exiled.API/Features/Toys/AdminToy.cs b/EXILED/Exiled.API/Features/Toys/AdminToy.cs index c93cee110e..b47561c1fb 100644 --- a/EXILED/Exiled.API/Features/Toys/AdminToy.cs +++ b/EXILED/Exiled.API/Features/Toys/AdminToy.cs @@ -12,8 +12,13 @@ namespace Exiled.API.Features.Toys using AdminToys; using Enums; + using Exiled.API.Interfaces; + using Footprinting; + + using InventorySystem.Items.Pickups; + using Mirror; using UnityEngine; @@ -145,6 +150,13 @@ public bool IsStatic set => AdminToyBase.NetworkIsStatic = value; } + /// + /// Converts AdminToyBase to AdminToy. + /// + /// The AdminToyBase. + /// EXILED AdminToy. + public static implicit operator AdminToy(AdminToyBase adminToyBase) => Get(adminToyBase); + /// /// Gets the belonging to the . /// diff --git a/EXILED/Exiled.API/Features/Toys/Waypoint.cs b/EXILED/Exiled.API/Features/Toys/Waypoint.cs index 0de33936a7..88c3ab0936 100644 --- a/EXILED/Exiled.API/Features/Toys/Waypoint.cs +++ b/EXILED/Exiled.API/Features/Toys/Waypoint.cs @@ -109,7 +109,7 @@ public static Waypoint Create(Transform parent = null, Vector3? position = null, Waypoint toy = new(Object.Instantiate(Prefab, parent)) { Priority = priority, - BoundsSize = scale ?? Vector3.one * 255.9961f, + BoundsSize = scale ?? Vector3.one * WaypointToy.MaxBounds, VisualizeBounds = visualizeBounds, }; diff --git a/EXILED/Exiled.API/Features/Window.cs b/EXILED/Exiled.API/Features/Window.cs index 2d327ff0c4..09bf0b1c86 100644 --- a/EXILED/Exiled.API/Features/Window.cs +++ b/EXILED/Exiled.API/Features/Window.cs @@ -12,10 +12,15 @@ namespace Exiled.API.Features using System.Linq; using DamageHandlers; + using Enums; + using Exiled.API.Extensions; using Exiled.API.Features.Doors; using Exiled.API.Interfaces; + + using MapGeneration; + using UnityEngine; /// @@ -148,12 +153,19 @@ public Player LastAttacker set => Base.LastAttacker = value.Footprint; } + /// + /// Converts BreakableWindow to Window. + /// + /// The BreakableWindow. + /// EXILED Window. + public static implicit operator Window(BreakableWindow breakableWindow) => Get(breakableWindow); + /// /// Gets the window object associated with a specific , or creates a new one if there isn't one. /// /// The base-game . /// A wrapper object. - public static Window Get(BreakableWindow breakableWindow) => BreakableWindowToWindow.TryGetValue(breakableWindow, out Window window) + public static Window Get(BreakableWindow breakableWindow) => breakableWindow == null ? null : BreakableWindowToWindow.TryGetValue(breakableWindow, out Window window) ? window : new(breakableWindow, breakableWindow.GetComponentInParent()); diff --git a/EXILED/Exiled.API/Features/Workstation.cs b/EXILED/Exiled.API/Features/Workstation.cs index 7e7978a7ff..809564d11d 100644 --- a/EXILED/Exiled.API/Features/Workstation.cs +++ b/EXILED/Exiled.API/Features/Workstation.cs @@ -119,12 +119,19 @@ public Player KnownUser set => Base.KnownUser = value.ReferenceHub; } + /// + /// Converts WorkstationController to Workstation. + /// + /// The WorkstationController. + /// EXILED Workstation. + public static implicit operator Workstation(WorkstationController workstationController) => Get(workstationController); + /// /// Gets a given a instance. /// /// The instance. /// The instance. - public static Workstation Get(WorkstationController workstationController) => WorkstationControllerToWorkstation.TryGetValue(workstationController, out Workstation workstation) ? workstation : new(workstationController); + public static Workstation Get(WorkstationController workstationController) => workstationController == null ? null : WorkstationControllerToWorkstation.TryGetValue(workstationController, out Workstation workstation) ? workstation : new(workstationController); /// /// Gets all instances that match the specified predicate.