Skip to content
1 change: 0 additions & 1 deletion EXILED/Exiled.API/Features/Doors/ElevatorDoor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Exiled.API.Features.Doors

using Exiled.API.Enums;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;
using UnityEngine;

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -224,7 +223,7 @@ public static Item Get(ItemBase itemBase)
Scp018Projectile => new Scp018(throwable),
_ => new Throwable(throwable),
},
_ => new Item(itemBase),
_ => new(itemBase),
};
}

Expand Down
10 changes: 8 additions & 2 deletions EXILED/Exiled.API/Features/Items/Scp1344.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -40,6 +41,11 @@ internal Scp1344()
/// </summary>
public new Scp1344Item Base { get; }

/// <summary>
/// Gets a value indicating whether the item is worn.
/// </summary>
public bool IsWorn => Base.IsWorn;

/// <summary>
/// Gets a value indicating whether it can be started to use.
/// </summary>
Expand All @@ -55,9 +61,9 @@ public Scp1344Status Status
}

/// <summary>
/// Forcefully Deactivate SCP-1344.
/// Forcefully deactivate SCP-1344.
/// </summary>
/// <param name="dropItem">Drop or not the item.</param>
/// <param name="dropItem">Whether or not 1344 should be dropped.</param>
public void Deactivate(bool dropItem = false)
{
if (Status is not(Scp1344Status.Active or Scp1344Status.Stabbing or Scp1344Status.Dropping))
Expand Down
1 change: 0 additions & 1 deletion EXILED/Exiled.API/Features/Lift.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 6 additions & 2 deletions EXILED/Exiled.API/Features/Toys/Light.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Exiled.API.Features.Toys
{
using System;
using System.Linq;

using AdminToys;
Expand All @@ -32,6 +31,11 @@ internal Light(LightSourceToy lightSourceToy)
Base = lightSourceToy;
}

/// <summary>
/// Gets the prefab.
/// </summary>
public static LightSourceToy Prefab => PrefabHelper.GetPrefab<LightSourceToy>(PrefabType.LightSourceToy);

/// <summary>
/// Gets the base <see cref="LightSourceToy"/>.
/// </summary>
Expand Down Expand Up @@ -131,7 +135,7 @@ public static Light Create(Vector3? position = null, Vector3? rotation = null, V
/// <returns>The new <see cref="Light"/>.</returns>
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),
Expand Down
36 changes: 20 additions & 16 deletions EXILED/Exiled.API/Features/Toys/Primitive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class Primitive : AdminToy, IWrapper<PrimitiveObjectToy>
internal Primitive(PrimitiveObjectToy toyAdminToyBase)
: base(toyAdminToyBase, AdminToyType.PrimitiveObject) => Base = toyAdminToyBase;

/// <summary>
/// Gets the prefab.
/// </summary>
public static PrimitiveObjectToy Prefab => PrefabHelper.GetPrefab<PrimitiveObjectToy>(PrefabType.PrimitiveObjectToy);

/// <summary>
/// Gets the base <see cref="PrimitiveObjectToy"/>.
/// </summary>
Expand Down Expand Up @@ -115,17 +120,16 @@ public static Primitive Create(PrimitiveType primitiveType = PrimitiveType.Spher
/// <returns>The new <see cref="Primitive"/>.</returns>
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;
}

Expand All @@ -141,18 +145,18 @@ public static Primitive Create(Vector3? position /*= null*/, Vector3? rotation /
/// <returns>The new <see cref="Primitive"/>.</returns>
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;
}

Expand All @@ -169,19 +173,19 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph
/// <returns>The new <see cref="Primitive"/>.</returns>
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;
}

Expand All @@ -192,20 +196,20 @@ public static Primitive Create(PrimitiveType primitiveType /*= PrimitiveType.Sph
/// <returns>The new <see cref="Primitive"/>.</returns>
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;
}

Expand All @@ -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);
}
}
}
23 changes: 19 additions & 4 deletions EXILED/Exiled.API/Features/Toys/ShootingTargetToy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Gets the prefab for Sport Shooting Target.
/// </summary>
public static ShootingTarget SportShootingTargetPrefab => PrefabHelper.GetPrefab<ShootingTarget>(PrefabType.SportTarget);

/// <summary>
/// Gets the prefab for DBoy Shooting Target.
/// </summary>
public static ShootingTarget DboyShootingTargetPrefab => PrefabHelper.GetPrefab<ShootingTarget>(PrefabType.DBoyTarget);

/// <summary>
/// Gets the prefab for Binary Shooting Target.
/// </summary>
public static ShootingTarget BinaryShootingTargetPrefab => PrefabHelper.GetPrefab<ShootingTarget>(PrefabType.BinaryTarget);

/// <summary>
/// Gets the base-game <see cref="ShootingTarget"/> for this target.
/// </summary>
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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);
}

/// <summary>
Expand Down
30 changes: 29 additions & 1 deletion EXILED/Exiled.API/Features/Toys/Speaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace Exiled.API.Features.Toys
{
using AdminToys;

using Enums;
using Exiled.API.Interfaces;
using UnityEngine;

/// <summary>
/// A wrapper class for <see cref="SpeakerToy"/>.
Expand All @@ -24,6 +24,11 @@ public class Speaker : AdminToy, IWrapper<SpeakerToy>
internal Speaker(SpeakerToy speakerToy)
: base(speakerToy, AdminToyType.Speaker) => Base = speakerToy;

/// <summary>
/// Gets the prefab.
/// </summary>
public static SpeakerToy Prefab => PrefabHelper.GetPrefab<SpeakerToy>(PrefabType.SpeakerToy);

/// <summary>
/// Gets the base <see cref="SpeakerToy"/>.
/// </summary>
Expand Down Expand Up @@ -80,5 +85,28 @@ public float MinDistance
get => Base.NetworkMinDistance;
set => Base.NetworkMinDistance = value;
}

/// <summary>
/// Creates a new <see cref="Speaker"/>.
/// </summary>
/// <param name="position">The position of the <see cref="Speaker"/>.</param>
/// <param name="rotation">The rotation of the <see cref="Speaker"/>.</param>
/// <param name="scale">The scale of the <see cref="Speaker"/>.</param>
/// <param name="spawn">Whether the <see cref="Speaker"/> should be initially spawned.</param>
/// <returns>The new <see cref="Speaker"/>.</returns>
public static Speaker Create(Vector3? position, Vector3? rotation, Vector3? scale, bool spawn)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if you consider them as nullable maybe add a null default value?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can add default value yeah, i just copied the method from another toy

{
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;
}
}
}
Loading