Skip to content
Closed
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
2 changes: 1 addition & 1 deletion LabApi/Features/Enums/DoorName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Enum type that represents all the door name tags defined in the game.
/// </summary>
public enum DoorName
public enum DoorType
{
None = 0,
LczPc,// LCZ_CAFE
Expand Down
99 changes: 54 additions & 45 deletions LabApi/Features/Wrappers/Facility/Doors/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,47 @@ internal static void Initialize()
private static readonly Dictionary<Type, Func<DoorVariant, Door>> typeWrappers = [];

/// <summary>
/// Contains all the <see cref="Enums.DoorName"/> values for the associated <see cref="NameTag"/>.
/// Contains all the <see cref="Enums.DoorType"/> values for the associated <see cref="NameTag"/>.
/// </summary>
private static readonly Dictionary<string, DoorName> doorNameDictionary = new()
private static readonly Dictionary<string, DoorType> doorNameDictionary = new()
{
{ "LCZ_CAFE", DoorName.LczPc },
{ "LCZ_WC", DoorName.LczWc },
{ "CHECKPOINT_LCZ_A", DoorName.LczCheckpointA },
{ "CHECKPOINT_LCZ_B", DoorName.LczCheckpointB },
{ "LCZ_ARMORY", DoorName.LczArmory },
{ "173_BOTTOM", DoorName.Lcz173Bottom },
{ "173_GATE", DoorName.Lcz173Gate },
{ "173_CONNECTOR", DoorName.Lcz173Connector },
{ "173_ARMORY", DoorName.Lcz173Armory },
{ "GR18_INNER", DoorName.LczGr18Inner },
{ "GR18", DoorName.LczGr18Gate },
{ "914", DoorName.Lcz914Gate },
{ "330", DoorName.Lcz330 },
{ "330_CHAMBER", DoorName.Lcz330Chamber },
{ "079_FIRST", DoorName.Hcz079FirstGate },
{ "079_SECOND", DoorName.Hcz079SecondGate },
{ "079_ARMORY", DoorName.Hcz079Armory },
{ "096", DoorName.Hcz096 },
{ "939_CRYO", DoorName.Hcz939Cryo },
{ "HCZ_ARMORY", DoorName.HczArmory },
{ "049_ARMORY", DoorName.Hcz049Armory },
{ "HID_CHAMBER", DoorName.HczHidChamber },
{ "HID_UPPER", DoorName.HczHidUpper },
{ "HID_LOWER", DoorName.HczHidLower },
{ "NUKE_ARMORY", DoorName.HczNukeArmory },
{ "106_PRIMARY", DoorName.Hcz106Primiary },
{ "106_SECONDARY", DoorName.Hcz106Secondary },
{ "HCZ_127_LAB", DoorName.Hcz127Lab },
{ "CHECKPOINT_EZ_HCZ_A", DoorName.HczCheckpoint },
{ "INTERCOM", DoorName.EzIntercom },
{ "GATE_A", DoorName.EzGateA },
{ "GATE_B", DoorName.EzGateB },
{ "SURFACE_GATE", DoorName.SurfaceGate },
{ "SURFACE_NUKE", DoorName.SurfaceNuke },
{ "ESCAPE_PRIMARY", DoorName.SurfaceEscapePrimary },
{ "ESCAPE_SECONDARY", DoorName.SurfaceEscapeSecondary },
{ "ESCAPE_FINAL", DoorName.SurfaceEscapeFinal }
{ "LCZ_CAFE", DoorType.LczPc },
{ "LCZ_WC", DoorType.LczWc },
{ "CHECKPOINT_LCZ_A", DoorType.LczCheckpointA },
{ "CHECKPOINT_LCZ_B", DoorType.LczCheckpointB },
{ "LCZ_ARMORY", DoorType.LczArmory },
{ "173_BOTTOM", DoorType.Lcz173Bottom },
{ "173_GATE", DoorType.Lcz173Gate },
{ "173_CONNECTOR", DoorType.Lcz173Connector },
{ "173_ARMORY", DoorType.Lcz173Armory },
{ "GR18_INNER", DoorType.LczGr18Inner },
{ "GR18", DoorType.LczGr18Gate },
{ "914", DoorType.Lcz914Gate },
{ "330", DoorType.Lcz330 },
{ "330_CHAMBER", DoorType.Lcz330Chamber },
{ "079_FIRST", DoorType.Hcz079FirstGate },
{ "079_SECOND", DoorType.Hcz079SecondGate },
{ "079_ARMORY", DoorType.Hcz079Armory },
{ "096", DoorType.Hcz096 },
{ "939_CRYO", DoorType.Hcz939Cryo },
{ "HCZ_ARMORY", DoorType.HczArmory },
{ "049_ARMORY", DoorType.Hcz049Armory },
{ "HID_CHAMBER", DoorType.HczHidChamber },
{ "HID_UPPER", DoorType.HczHidUpper },
{ "HID_LOWER", DoorType.HczHidLower },
{ "NUKE_ARMORY", DoorType.HczNukeArmory },
{ "106_PRIMARY", DoorType.Hcz106Primiary },
{ "106_SECONDARY", DoorType.Hcz106Secondary },
{ "HCZ_127_LAB", DoorType.Hcz127Lab },
{ "CHECKPOINT_EZ_HCZ_A", DoorType.HczCheckpoint },
{ "INTERCOM", DoorType.EzIntercom },
{ "GATE_A", DoorType.EzGateA },
{ "GATE_B", DoorType.EzGateB },
{ "SURFACE_GATE", DoorType.SurfaceGate },
{ "SURFACE_NUKE", DoorType.SurfaceNuke },
{ "ESCAPE_PRIMARY", DoorType.SurfaceEscapePrimary },
{ "ESCAPE_SECONDARY", DoorType.SurfaceEscapeSecondary },
{ "ESCAPE_FINAL", DoorType.SurfaceEscapeFinal }
};

/// <summary>
Expand All @@ -104,8 +104,8 @@ protected Door(DoorVariant doorVariant)

if (doorVariant.TryGetComponent(out DoorNametagExtension nametag) && !string.IsNullOrEmpty(nametag.GetName))
{
if (doorNameDictionary.TryGetValue(nametag.GetName, out DoorName doorName))
DoorName = doorName;
if (doorNameDictionary.TryGetValue(nametag.GetName, out DoorType doorName))
Type = doorName;
else
Logger.Warn($"Missing DoorName enum value for door name tag {nametag.GetName}");
}
Expand All @@ -125,18 +125,27 @@ internal virtual void OnRemove()
public DoorVariant Base { get; }

/// <summary>
/// Gets the <see cref="Enums.DoorName"/> of the door.
/// Gets the <see cref="DoorName"/> of the door.
/// </summary>
/// <remarks>
/// Is the enum version of <see cref="NameTag"/>.
/// </remarks>
public DoorName DoorName { get; } = DoorName.None;
[Obsolete("Use Type instead.")]
public DoorType DoorName { get; } = DoorType.None;

/// <summary>
/// Gets the type of the door.
/// </summary>
/// <remarks>
/// Is the enum version of <see cref="NameTag"/>.
/// </remarks>
public DoorType Type { get; } = DoorType.None;

/// <summary>
/// Gets the name tag of the door.
/// </summary>
/// <remarks>
/// Is the string version of <see cref="DoorName"/>.
/// Is the string version of <see cref="DoorType"/>.
/// </remarks>
public string NameTag => Base.DoorName;

Expand Down Expand Up @@ -245,7 +254,7 @@ public bool Bypass2176
/// <inheritdoc />
public override string ToString()
{
return $"[{GetType().Name}: DoorName={DoorName}, NameTag={NameTag}, Zone={Zone}, IsOpened={IsOpened}, IsLocked={IsLocked}, Permissions={Permissions}]";
return $"[{GetType().Name}: DoorName or Type={Type}, NameTag={NameTag}, Zone={Zone}, IsOpened={IsOpened}, IsLocked={IsLocked}, Permissions={Permissions}]";
}

/// <summary>
Expand Down
13 changes: 10 additions & 3 deletions LabApi/Features/Wrappers/Facility/Rooms/Room.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Generators;
using Interactables.Interobjects.DoorUtils;
using MapGeneration;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand Down Expand Up @@ -71,7 +72,13 @@ internal virtual void OnRemoved()
/// <summary>
/// The room's name.
/// </summary>
public RoomName Name => Base.Name;
[Obsolete("Use Type instead.", false)]
public RoomName RoomName => Base.Name;

/// <summary>
/// The room's type, which is the same as <see cref="RoomIdentifier.Name"/>.<br/>
/// </summary>
public RoomName Type => Base.Name;

/// <summary>
/// The zone in which this room is located.
Expand Down Expand Up @@ -139,7 +146,7 @@ public IEnumerable<Door> Doors
/// <inheritdoc />
public override string ToString()
{
return $"[{GetType().Name}: Name={Name}, Shape={Shape}, Zone={Zone}]";
return $"[{GetType().Name}: Name={Type}, Shape={Shape}, Zone={Zone}]";
}

/// <summary>
Expand Down Expand Up @@ -170,7 +177,7 @@ public override string ToString()
/// <param name="roomName">The name of the room.</param>
/// <returns>The requested room.</returns>
public static IEnumerable<Room> Get(RoomName roomName) =>
List.Where(x => x.Name == roomName);
List.Where(x => x.Type == roomName);

/// <summary>
/// Gets the rooms by their shape.
Expand Down
34 changes: 34 additions & 0 deletions LabApi/Features/Wrappers/Pickups/Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,40 @@ public override string ToString()
return Get(newPickupBase);
}

/// <summary>
/// Creates and spawns a new <see cref="Pickup"/>.
/// </summary>
/// <param name="type">The <see cref="ItemType"/>.</param>
/// <param name="position">The initial position.</param>
/// <returns>The instantiated <see cref="Pickup"/></returns>
public static Pickup? CreateAndSpawn(ItemType type, Vector3 position) => CreateAndSpawn(type, position, Quaternion.identity, Vector3.one);

/// <summary>
/// Creates and spawns a new <see cref="Pickup"/>.
/// </summary>
/// <param name="type">The <see cref="ItemType"/>.</param>
/// <param name="position">The initial position.</param>
/// <param name="rotation">The initial rotation.</param>
/// <returns>The instantiated <see cref="Pickup"/></returns>
public static Pickup? CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation) => CreateAndSpawn(type, position, rotation, Vector3.one);


/// <summary>
/// Creates and spawns a new <see cref="Pickup"/>.
/// </summary>
/// <param name="type">The <see cref="ItemType"/>.</param>
/// <param name="position">The initial position.</param>
/// <param name="rotation">The initial rotation.</param>
/// <param name="scale">The initial scale.</param>
/// <returns>The instantiated <see cref="Pickup"/></returns>
public static Pickup? CreateAndSpawn(ItemType type, Vector3 position, Quaternion rotation, Vector3 scale)
{
Pickup? pickup = Create(type, position, rotation, scale);

pickup?.Spawn();
return pickup;
}

/// <summary>
/// A private method to handle the creation of new pickups in the server.
/// </summary>
Expand Down