Skip to content
4 changes: 0 additions & 4 deletions EXILED/Exiled.API/Features/Doors/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ namespace Exiled.API.Features.Doors
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features.Core;
using Exiled.API.Features.Hazards;
using Exiled.API.Interfaces;
using global::Hazards;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;
using MEC;
using Mirror;
using UnityEngine;

using static Interactables.Interobjects.ElevatorManager;

using BaseBreakableDoor = Interactables.Interobjects.BreakableDoor;
using BaseKeycardPermissions = Interactables.Interobjects.DoorUtils.KeycardPermissions;
using Breakable = BreakableDoor;
Expand Down
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
6 changes: 4 additions & 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 All @@ -26,6 +25,7 @@ namespace Exiled.API.Features.Items
using InventorySystem.Items.ThrowableProjectiles;
using InventorySystem.Items.ToggleableLights;
using InventorySystem.Items.Usables;
using InventorySystem.Items.Usables.Scp1344;
using InventorySystem.Items.Usables.Scp1576;
using InventorySystem.Items.Usables.Scp244;
using InventorySystem.Items.Usables.Scp330;
Expand Down Expand Up @@ -202,6 +202,7 @@ public static Item Get(ItemBase itemBase)
KeycardItem keycard => new Keycard(keycard),
UsableItem usable => usable switch
{
Scp1344Item scp1344Item => new Scp1344(scp1344Item),
Scp330Bag scp330Bag => new Scp330(scp330Bag),
Scp244Item scp244Item => new Scp244(scp244Item),
Scp1576Item scp1576 => new Scp1576(scp1576),
Expand All @@ -222,7 +223,7 @@ public static Item Get(ItemBase itemBase)
Scp018Projectile => new Scp018(throwable),
_ => new Throwable(throwable),
},
_ => new Item(itemBase),
_ => new(itemBase),
};
}

Expand Down Expand Up @@ -297,6 +298,7 @@ public static T Get<T>(ushort serial)
ItemType.KeycardGuard or ItemType.KeycardJanitor or ItemType.KeycardO5 or ItemType.KeycardScientist or ItemType.KeycardChaosInsurgency or ItemType.KeycardContainmentEngineer or ItemType.KeycardFacilityManager or ItemType.KeycardResearchCoordinator or ItemType.KeycardZoneManager or ItemType.KeycardMTFPrivate or ItemType.KeycardMTFOperative or
ItemType.KeycardMTFCaptain => new Keycard(type),
ItemType.ArmorLight or ItemType.ArmorCombat or ItemType.ArmorHeavy => new Armor(type),
ItemType.SCP1344 => new Scp1344(),
ItemType.SCP330 => new Scp330(),
ItemType.SCP2176 => new Scp2176(owner),
ItemType.SCP1576 => new Scp1576(),
Expand Down
60 changes: 60 additions & 0 deletions EXILED/Exiled.API/Features/Items/Scp1344.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// -----------------------------------------------------------------------
// <copyright file="Scp1344.cs" company="ExMod Team">
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Features.Items
{
using Exiled.API.Interfaces;
using InventorySystem.Items.Usables.Scp1344;

/// <summary>
/// A wrapper class for SCP-1344.
/// </summary>
public class Scp1344 : Usable, IWrapper<Scp1344Item>
{
/// <summary>
/// Initializes a new instance of the <see cref="Scp1344"/> class.
/// </summary>
/// <param name="itemBase">The item base to wrap.</param>
public Scp1344(Scp1344Item itemBase)
: base(itemBase)
{
Base = itemBase;
}

/// <summary>
/// Initializes a new instance of the <see cref="Scp1344"/> class.
/// </summary>
internal Scp1344()
: this((Scp1344Item)Server.Host.Inventory.CreateItemInstance(new(ItemType.SCP1344, 0), false))
{
}

/// <summary>
/// Gets the <see cref="Scp1344"/> base.
/// </summary>
public new Scp1344Item Base { get; }

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

/// <summary>
/// Gets or sets the status.
/// </summary>
public Scp1344Status Status
{
get => Base.Status;
set => Base.Status = value;
}

/// <summary>
/// Gets a value indicating whether it can be started to use.
/// </summary>
public bool CanStartUsing => Base.CanStartUsing;
}
}
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
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Features/PrefabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default
{
if (!Stored.TryGetValue(prefabType, out GameObject gameObject))
return null;

GameObject newGameObject = UnityEngine.Object.Instantiate(gameObject, position, rotation);
NetworkServer.Spawn(newGameObject);
return newGameObject;
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