diff --git a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs index dd597645c3..797378312a 100644 --- a/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs +++ b/EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs @@ -12,7 +12,6 @@ namespace Exiled.API.Features.Doors using Exiled.API.Enums; using Interactables.Interobjects; - using Interactables.Interobjects.DoorUtils; using UnityEngine; /// diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index 8b88942a12..28acb94329 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -13,7 +13,6 @@ namespace Exiled.API.Features.Items using Exiled.API.Features.Core; using Exiled.API.Features.Pickups; using Exiled.API.Interfaces; - using InventorySystem; using InventorySystem.Items; using InventorySystem.Items.Armor; @@ -224,7 +223,7 @@ public static Item Get(ItemBase itemBase) Scp018Projectile => new Scp018(throwable), _ => new Throwable(throwable), }, - _ => new Item(itemBase), + _ => new(itemBase), }; } diff --git a/EXILED/Exiled.API/Features/Items/Scp1344.cs b/EXILED/Exiled.API/Features/Items/Scp1344.cs index 805ff2d745..460aeb8c06 100644 --- a/EXILED/Exiled.API/Features/Items/Scp1344.cs +++ b/EXILED/Exiled.API/Features/Items/Scp1344.cs @@ -8,6 +8,7 @@ namespace Exiled.API.Features.Items { using Exiled.API.Interfaces; + using InventorySystem.Items.Usables; using InventorySystem.Items.Usables.Scp1344; using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers; @@ -40,6 +41,11 @@ internal Scp1344() /// public new Scp1344Item Base { get; } + /// + /// Gets a value indicating whether the item is worn. + /// + public bool IsWorn => Base.IsWorn; + /// /// Gets a value indicating whether it can be started to use. /// @@ -55,9 +61,9 @@ public Scp1344Status Status } /// - /// Forcefully Deactivate SCP-1344. + /// Forcefully deactivate SCP-1344. /// - /// Drop or not the item. + /// Whether or not 1344 should be dropped. public void Deactivate(bool dropItem = false) { if (Status is not(Scp1344Status.Active or Scp1344Status.Stabbing or Scp1344Status.Dropping)) diff --git a/EXILED/Exiled.API/Features/Lift.cs b/EXILED/Exiled.API/Features/Lift.cs index 53160f9a6e..c38e146a32 100644 --- a/EXILED/Exiled.API/Features/Lift.cs +++ b/EXILED/Exiled.API/Features/Lift.cs @@ -21,7 +21,6 @@ namespace Exiled.API.Features using UnityEngine; using static Interactables.Interobjects.ElevatorChamber; - using static Interactables.Interobjects.ElevatorManager; using Elevator = Interactables.Interobjects.ElevatorDoor; diff --git a/EXILED/Exiled.API/Features/Toys/Light.cs b/EXILED/Exiled.API/Features/Toys/Light.cs index 8e2a7642e1..a831f4b6d3 100644 --- a/EXILED/Exiled.API/Features/Toys/Light.cs +++ b/EXILED/Exiled.API/Features/Toys/Light.cs @@ -7,7 +7,6 @@ namespace Exiled.API.Features.Toys { - using System; using System.Linq; using AdminToys; @@ -32,6 +31,11 @@ internal Light(LightSourceToy lightSourceToy) Base = lightSourceToy; } + /// + /// Gets the prefab. + /// + public static LightSourceToy Prefab => PrefabHelper.GetPrefab(PrefabType.LightSourceToy); + /// /// Gets the base . /// @@ -131,7 +135,7 @@ public static Light Create(Vector3? position = null, Vector3? rotation = null, V /// The new . public static Light Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Light light = new(UnityEngine.Object.Instantiate(ToysHelper.LightBaseObject)) + Light light = new(UnityEngine.Object.Instantiate(Prefab)) { Position = position ?? Vector3.zero, Rotation = Quaternion.Euler(rotation ?? Vector3.zero), diff --git a/EXILED/Exiled.API/Features/Toys/Primitive.cs b/EXILED/Exiled.API/Features/Toys/Primitive.cs index b90588d8fe..1b7202fa76 100644 --- a/EXILED/Exiled.API/Features/Toys/Primitive.cs +++ b/EXILED/Exiled.API/Features/Toys/Primitive.cs @@ -31,6 +31,11 @@ public class Primitive : AdminToy, IWrapper internal Primitive(PrimitiveObjectToy toyAdminToyBase) : base(toyAdminToyBase, AdminToyType.PrimitiveObject) => Base = toyAdminToyBase; + /// + /// Gets the prefab. + /// + public static PrimitiveObjectToy Prefab => PrefabHelper.GetPrefab(PrefabType.PrimitiveObjectToy); + /// /// Gets the base . /// @@ -115,17 +120,16 @@ public static Primitive Create(PrimitiveType primitiveType = PrimitiveType.Spher /// The new . public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; + primitive.Color = color ?? Color.gray; if (spawn) primitive.Spawn(); - primitive.Color = color ?? Color.gray; - return primitive; } @@ -141,18 +145,18 @@ public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation / /// The new . public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sphere*/, Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; - if (spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveType; primitive.Color = color ?? Color.gray; + if (spawn) + primitive.Spawn(); + return primitive; } @@ -169,19 +173,19 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph /// The new . public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sphere*/, PrimitiveFlags flags, Vector3? position /*= null*/, Vector3? rotation /*= null*/, Vector3? scale /*= null*/, bool spawn /*= true*/, Color? color /*= null*/) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = position ?? Vector3.zero; primitive.Rotation = Quaternion.Euler(rotation ?? Vector3.zero); primitive.Scale = scale ?? Vector3.one; primitive.Flags = flags; - if (spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveType; primitive.Color = color ?? Color.gray; + if (spawn) + primitive.Spawn(); + return primitive; } @@ -192,20 +196,20 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph /// The new . public static Primitive Create(PrimitiveSettings primitiveSettings) { - Primitive primitive = new(Object.Instantiate(ToysHelper.PrimitiveBaseObject)); + Primitive primitive = new(Object.Instantiate(Prefab)); primitive.Position = primitiveSettings.Position; primitive.Rotation = Quaternion.Euler(primitiveSettings.Rotation); primitive.Scale = primitiveSettings.Scale; primitive.Flags = primitiveSettings.Flags; - if (primitiveSettings.Spawn) - primitive.Spawn(); - primitive.Base.NetworkPrimitiveType = primitiveSettings.PrimitiveType; primitive.Color = primitiveSettings.Color; primitive.IsStatic = primitiveSettings.IsStatic; + if (primitiveSettings.Spawn) + primitive.Spawn(); + return primitive; } @@ -217,7 +221,7 @@ public static Primitive Create(PrimitiveSettings primitiveSettings) public static Primitive Get(PrimitiveObjectToy primitiveObjectToy) { AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == primitiveObjectToy); - return adminToy is not null ? adminToy as Primitive : new Primitive(primitiveObjectToy); + return adminToy is not null ? adminToy as Primitive : new(primitiveObjectToy); } } } diff --git a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs index 70bcf6f12c..6723944a4d 100644 --- a/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs +++ b/EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs @@ -46,6 +46,21 @@ internal ShootingTargetToy(ShootingTarget target) Type = TypeLookup.TryGetValue(Base.gameObject.name.Substring(0, Base.gameObject.name.Length - 7), out ShootingTargetType type) ? type : ShootingTargetType.Unknown; } + /// + /// Gets the prefab for Sport Shooting Target. + /// + public static ShootingTarget SportShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.SportTarget); + + /// + /// Gets the prefab for DBoy Shooting Target. + /// + public static ShootingTarget DboyShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.DBoyTarget); + + /// + /// Gets the prefab for Binary Shooting Target. + /// + public static ShootingTarget BinaryShootingTargetPrefab => PrefabHelper.GetPrefab(PrefabType.BinaryTarget); + /// /// Gets the base-game for this target. /// @@ -165,19 +180,19 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio { case ShootingTargetType.ClassD: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.DboyShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(DboyShootingTargetPrefab)); break; } case ShootingTargetType.Binary: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.BinaryShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(BinaryShootingTargetPrefab)); break; } default: { - shootingTargetToy = new ShootingTargetToy(Object.Instantiate(ToysHelper.SportShootingTargetObject)); + shootingTargetToy = new(Object.Instantiate(SportShootingTargetPrefab)); break; } } @@ -200,7 +215,7 @@ public static ShootingTargetToy Create(ShootingTargetType type, Vector3? positio public static ShootingTargetToy Get(ShootingTarget shootingTarget) { AdminToy adminToy = Map.Toys.FirstOrDefault(x => x.AdminToyBase == shootingTarget); - return adminToy is not null ? adminToy as ShootingTargetToy : new ShootingTargetToy(shootingTarget); + return adminToy is not null ? adminToy as ShootingTargetToy : new(shootingTarget); } /// diff --git a/EXILED/Exiled.API/Features/Toys/Speaker.cs b/EXILED/Exiled.API/Features/Toys/Speaker.cs index dc03c3ff9d..c51b8bcb79 100644 --- a/EXILED/Exiled.API/Features/Toys/Speaker.cs +++ b/EXILED/Exiled.API/Features/Toys/Speaker.cs @@ -8,9 +8,9 @@ namespace Exiled.API.Features.Toys { using AdminToys; - using Enums; using Exiled.API.Interfaces; + using UnityEngine; /// /// A wrapper class for . @@ -24,6 +24,11 @@ public class Speaker : AdminToy, IWrapper internal Speaker(SpeakerToy speakerToy) : base(speakerToy, AdminToyType.Speaker) => Base = speakerToy; + /// + /// Gets the prefab. + /// + public static SpeakerToy Prefab => PrefabHelper.GetPrefab(PrefabType.SpeakerToy); + /// /// Gets the base . /// @@ -80,5 +85,28 @@ public float MinDistance get => Base.NetworkMinDistance; set => Base.NetworkMinDistance = value; } + + /// + /// Creates a new . + /// + /// The position of the . + /// The rotation of the . + /// The scale of the . + /// Whether the should be initially spawned. + /// The new . + public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scale, bool spawn) + { + Speaker speaker = new(UnityEngine.Object.Instantiate(Prefab)) + { + Position = position ?? Vector3.zero, + Rotation = Quaternion.Euler(rotation ?? Vector3.zero), + Scale = scale ?? Vector3.one, + }; + + if (spawn) + speaker.Spawn(); + + return speaker; + } } } diff --git a/EXILED/Exiled.API/Features/Toys/ToysHelper.cs b/EXILED/Exiled.API/Features/Toys/ToysHelper.cs deleted file mode 100644 index 5ebcfc42fb..0000000000 --- a/EXILED/Exiled.API/Features/Toys/ToysHelper.cs +++ /dev/null @@ -1,142 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) ExMod Team. All rights reserved. -// Licensed under the CC BY-SA 3.0 license. -// -// ----------------------------------------------------------------------- - -namespace Exiled.API.Features.Toys -{ - using AdminToys; - - using Mirror; - - using UnityEngine; - - /// - /// A helper class for interacting with toys. - /// - public static class ToysHelper - { - private static PrimitiveObjectToy primitiveBaseObject; - private static LightSourceToy lightBaseObject; - private static ShootingTarget sportShootingTargetObject; - private static ShootingTarget dboyShootingTargetObject; - private static ShootingTarget binaryShootingTargetObject; - - /// - /// Gets the base to instantiate when creating a new primitive. - /// - public static PrimitiveObjectToy PrimitiveBaseObject - { - get - { - if (primitiveBaseObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if (gameObject.TryGetComponent(out PrimitiveObjectToy component)) - { - primitiveBaseObject = component; - break; - } - } - } - - return primitiveBaseObject; - } - } - - /// - /// Gets the base to instantiate when creating a new light. - /// - public static LightSourceToy LightBaseObject - { - get - { - if (lightBaseObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if (gameObject.TryGetComponent(out LightSourceToy component)) - { - lightBaseObject = component; - break; - } - } - } - - return lightBaseObject; - } - } - - /// - /// Gets the base to instantiate when creating a new sport shooting target. - /// - public static ShootingTarget SportShootingTargetObject - { - get - { - if (sportShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "sportTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - sportShootingTargetObject = shootingTarget; - break; - } - } - } - - return sportShootingTargetObject; - } - } - - /// - /// Gets the base to instantiate when creating a new dboy shooting target. - /// - public static ShootingTarget DboyShootingTargetObject - { - get - { - if (dboyShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "dboyTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - dboyShootingTargetObject = shootingTarget; - break; - } - } - } - - return dboyShootingTargetObject; - } - } - - /// - /// Gets the base to instantiate when creating a new binary shooting target. - /// - public static ShootingTarget BinaryShootingTargetObject - { - get - { - if (binaryShootingTargetObject is null) - { - foreach (GameObject gameObject in NetworkClient.prefabs.Values) - { - if ((gameObject.name == "binaryTargetPrefab") && gameObject.TryGetComponent(out ShootingTarget shootingTarget)) - { - binaryShootingTargetObject = shootingTarget; - break; - } - } - } - - return binaryShootingTargetObject; - } - } - } -} \ No newline at end of file diff --git a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs index 8014a45e9d..1320ad76a0 100644 --- a/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs +++ b/EXILED/Exiled.Events/Handlers/Internal/MapGenerated.cs @@ -7,6 +7,9 @@ namespace Exiled.Events.Handlers.Internal { + using System.Collections.Generic; + using System.Linq; + using API.Features; using Exiled.API.Features.Lockers;