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
30 changes: 30 additions & 0 deletions SecretAPI.Examples/Cards/ExampleCustomCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace SecretAPI.Examples.Cards
{
using Interactables.Interobjects.DoorUtils;
using SecretAPI.Features.CustomKeycards;
using UnityEngine;

/// <summary>
/// Example for <see cref="CustomManagementKeycardInfo"/>.
/// </summary>
public class ExampleCustomCard : CustomManagementKeycardInfo
{
/// <inheritdoc/>
public override string ItemName { get; set; } = "Example Custom Card";

/// <inheritdoc/>
public override KeycardLevels KeycardPermissions { get; set; } = new(0, 0, 0);

/// <inheritdoc/>
public override Color KeycardColor { get; set; } = Color.white;

/// <inheritdoc/>
public override Color PermissionsColor { get; set; } = Color.white;

/// <inheritdoc/>
public override string CardLabel { get; set; } = "Example Label";

/// <inheritdoc/>
public override Color LabelColor { get; set; } = Color.white;
}
}
44 changes: 44 additions & 0 deletions SecretAPI/Features/CustomKeycards/CustomKeycardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace SecretAPI.Features.CustomKeycards
{
using Interactables.Interobjects.DoorUtils;
using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Base class for handling information related to custom keycards.
/// </summary>
public abstract class CustomKeycardInfo
{
/// <summary>
/// Gets the ItemType associated with the custom keycard.
/// </summary>
public abstract ItemType ItemType { get; }

/// <summary>
/// Gets or sets the name of the item.
/// </summary>
public abstract string ItemName { get; set; }

/// <summary>
/// Gets or sets the <see cref="KeycardPermissions"/> associated.
/// </summary>
public abstract KeycardLevels KeycardPermissions { get; set; }

/// <summary>
/// Gets or sets the color of the keycard.
/// </summary>
public abstract Color KeycardColor { get; set; }

/// <summary>
/// Gets or sets the color of the permissions on the card.
/// </summary>
public abstract Color PermissionsColor { get; set; }

/// <summary>
/// Creates and grants a keycard item based on the instance's information to a player.
/// </summary>
/// <param name="player">The player to give the keycard to.</param>
/// <returns>The newly created keycard.</returns>
public abstract KeycardItem GiveKeycard(Player player);
}
}
34 changes: 34 additions & 0 deletions SecretAPI/Features/CustomKeycards/CustomManagementKeycardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace SecretAPI.Features.CustomKeycards
{
using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Handles info related to <see cref="ItemType.KeycardCustomManagement"/>.
/// </summary>
public abstract class CustomManagementKeycardInfo : CustomKeycardInfo
{
/// <inheritdoc />
public override ItemType ItemType => ItemType.KeycardCustomManagement;

/// <summary>
/// Gets or sets the label of the card.
/// </summary>
public abstract string CardLabel { get; set; }

/// <summary>
/// Gets or sets the color of the label.
/// </summary>
public abstract Color LabelColor { get; set; }

/// <inheritdoc />
public override KeycardItem GiveKeycard(Player player) => KeycardItem.CreateCustomKeycardManagement(
player,
ItemName,
CardLabel,
KeycardPermissions,
KeycardColor,
PermissionsColor,
LabelColor)!;
}
}
44 changes: 44 additions & 0 deletions SecretAPI/Features/CustomKeycards/CustomMetalKeycardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace SecretAPI.Features.CustomKeycards
{
using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Handles info related to <see cref="ItemType.KeycardCustomMetalCase"/>.
/// </summary>
public abstract class CustomMetalKeycardInfo : CustomKeycardInfo, IHolderCardInfo, ILabelCardInfo, ISerialLabelCardInfo
{
/// <inheritdoc />
public override ItemType ItemType => ItemType.KeycardCustomMetalCase;

/// <inheritdoc />
public abstract string CardLabel { get; set; }

/// <inheritdoc />
public abstract Color LabelColor { get; set; }

/// <summary>
/// Gets or sets the wear level.
/// </summary>
public abstract byte WearLevel { get; set; }

/// <inheritdoc />
public abstract string SerialLabel { get; set; }

/// <inheritdoc />
public abstract string GetHolderName(Player player);

/// <inheritdoc />
public override KeycardItem GiveKeycard(Player player) => KeycardItem.CreateCustomKeycardMetal(
player,
ItemName,
GetHolderName(player),
CardLabel,
KeycardPermissions,
PermissionsColor,
KeycardColor,
LabelColor,
WearLevel,
SerialLabel)!;
}
}
40 changes: 40 additions & 0 deletions SecretAPI/Features/CustomKeycards/CustomSite02KeycardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace SecretAPI.Features.CustomKeycards
{
using LabApi.Features.Wrappers;
using UnityEngine;

/// <summary>
/// Handles info related to <see cref="ItemType.KeycardCustomSite02"/>.
/// </summary>
public abstract class CustomSite02KeycardInfo : CustomKeycardInfo, IHolderCardInfo, ILabelCardInfo
{
/// <inheritdoc />
public override ItemType ItemType => ItemType.KeycardCustomSite02;

/// <inheritdoc />
public abstract string CardLabel { get; set; }

/// <inheritdoc />
public abstract Color LabelColor { get; set; }

/// <summary>
/// Gets or sets the wear level.
/// </summary>
public abstract byte WearLevel { get; set; }

/// <inheritdoc />
public abstract string GetHolderName(Player player);

/// <inheritdoc />
public override KeycardItem GiveKeycard(Player player) => KeycardItem.CreateCustomKeycardSite02(
player,
ItemName,
GetHolderName(player),
CardLabel,
KeycardPermissions,
KeycardColor,
PermissionsColor,
LabelColor,
WearLevel)!;
}
}
35 changes: 35 additions & 0 deletions SecretAPI/Features/CustomKeycards/CustomTaskForceKeycardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace SecretAPI.Features.CustomKeycards
{
using LabApi.Features.Wrappers;

/// <summary>
/// Handles info related to <see cref="ItemType.KeycardCustomTaskForce"/>.
/// </summary>
public abstract class CustomTaskForceKeycardInfo : CustomKeycardInfo, IHolderCardInfo, ISerialLabelCardInfo
{
/// <inheritdoc />
public override ItemType ItemType => ItemType.KeycardCustomTaskForce;

/// <inheritdoc/>
public abstract string SerialLabel { get; set; }

/// <summary>
/// Gets or sets rank index.
/// </summary>
public abstract int RankIndex { get; set; }

/// <inheritdoc />
public abstract string GetHolderName(Player player);

/// <inheritdoc />
public override KeycardItem GiveKeycard(Player player) => KeycardItem.CreateCustomKeycardTaskForce(
player,
ItemName,
GetHolderName(player),
KeycardPermissions,
KeycardColor,
PermissionsColor,
SerialLabel,
RankIndex)!;
}
}
17 changes: 17 additions & 0 deletions SecretAPI/Features/CustomKeycards/IHolderCardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace SecretAPI.Features.CustomKeycards
{
using LabApi.Features.Wrappers;

/// <summary>
/// Interface for keycards with a Holder Name.
/// </summary>
public interface IHolderCardInfo
{
/// <summary>
/// Gets a holder name based on a player.
/// </summary>
/// <param name="player">The player to get holder name based on.</param>
/// <returns>The holder name to give.</returns>
public string GetHolderName(Player player);
}
}
20 changes: 20 additions & 0 deletions SecretAPI/Features/CustomKeycards/ILabelCardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace SecretAPI.Features.CustomKeycards
{
using UnityEngine;

/// <summary>
/// Interface for cards with a Label.
/// </summary>
public interface ILabelCardInfo
{
/// <summary>
/// Gets or sets the label of the card.
/// </summary>
public string CardLabel { get; set; }

/// <summary>
/// Gets or sets the color of the label.
/// </summary>
public Color LabelColor { get; set; }
}
}
13 changes: 13 additions & 0 deletions SecretAPI/Features/CustomKeycards/ISerialLabelCardInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SecretAPI.Features.CustomKeycards
{
/// <summary>
/// Interface for cards with a Serial Label.
/// </summary>
public interface ISerialLabelCardInfo
{
/// <summary>
/// Gets or sets the label of the serial.
/// </summary>
public string SerialLabel { get; set; }
}
}