From a70b30a277d44d984ad5201093e9ad186e185fc4 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Sun, 10 Aug 2025 17:54:17 +0300
Subject: [PATCH 1/9] Create CustomizableKeycardType.cs
---
.../Enums/CustomizableKeycardType.cs | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
diff --git a/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs b/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
new file mode 100644
index 000000000..f30a063f4
--- /dev/null
+++ b/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
@@ -0,0 +1,41 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.API.Enums
+{
+ ///
+ /// Customizable Keycard types present in the game.
+ ///
+ ///
+ public enum CustomizableKeycardType
+ {
+ ///
+ /// Not Customizable Keycard.
+ ///
+ None,
+
+ ///
+ /// Used by .
+ ///
+ Vertical,
+
+ ///
+ /// Used by .
+ ///
+ MetalFramed,
+
+ ///
+ /// Used by .
+ ///
+ Perforated,
+
+ ///
+ /// Used by .
+ ///
+ Standart,
+ }
+}
From 7673d72341ca208c4af05b35d3509fe545b9ec68 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Sun, 10 Aug 2025 17:55:05 +0300
Subject: [PATCH 2/9] Update ItemExtensions.cs
---
EXILED/Exiled.API/Extensions/ItemExtensions.cs | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/EXILED/Exiled.API/Extensions/ItemExtensions.cs b/EXILED/Exiled.API/Extensions/ItemExtensions.cs
index 458fd10bc..c7839fa9e 100644
--- a/EXILED/Exiled.API/Extensions/ItemExtensions.cs
+++ b/EXILED/Exiled.API/Extensions/ItemExtensions.cs
@@ -201,6 +201,20 @@ public static int GetMaxAmmo(this FirearmType item)
_ => ItemType.None,
};
+ ///
+ /// Converts an into it's corresponding .
+ ///
+ /// The to convert.
+ /// The Item type of the specified customizable keycard.
+ public static ItemType GetItemType(this CustomizableKeycardType type) => type switch
+ {
+ CustomizableKeycardType.Vertical => ItemType.KeycardCustomManagement,
+ CustomizableKeycardType.Standart => ItemType.KeycardCustomSite02,
+ CustomizableKeycardType.MetalFramed => ItemType.KeycardCustomMetalCase,
+ CustomizableKeycardType.Perforated => ItemType.KeycardCustomTaskForce,
+ _ => ItemType.None,
+ };
+
///
/// Converts a into it's corresponding .
///
From 858223d1a8e3d49260d7d03e8c7f43bb939c77cd Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Sun, 10 Aug 2025 17:56:53 +0300
Subject: [PATCH 3/9] Update Keycard.cs
---
EXILED/Exiled.API/Features/Items/Keycard.cs | 80 ++++++++++++++++++++-
1 file changed, 77 insertions(+), 3 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Items/Keycard.cs b/EXILED/Exiled.API/Features/Items/Keycard.cs
index 4e68dd60a..38148b0bc 100644
--- a/EXILED/Exiled.API/Features/Items/Keycard.cs
+++ b/EXILED/Exiled.API/Features/Items/Keycard.cs
@@ -10,8 +10,12 @@ namespace Exiled.API.Features.Items
using System;
using Exiled.API.Enums;
+ using Exiled.API.Extensions;
using Exiled.API.Interfaces;
+ using Interactables.Interobjects.DoorUtils;
+ using InventorySystem;
using InventorySystem.Items.Keycards;
+ using UnityEngine;
///
/// A wrapper class for .
@@ -63,8 +67,78 @@ public KeycardPermissions Permissions
return KeycardPermissions.None;
}
- [Obsolete("Not functional anymore", true)]
- set => _ = value;
+ set
+ {
+ if (!Base.Customizable)
+ {
+ Log.Error($"The keycard {Type} is not customizable, so you cannot set permissions on it.");
+ return;
+ }
+
+ CustomPermsDetail._customLevels = new KeycardLevels((DoorPermissionFlags)value);
+
+ KeycardDetailSynchronizer.Database.Remove(Serial);
+ KeycardDetailSynchronizer.ServerProcessItem(Base);
+ }
+ }
+
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The display name of the keycard.
+ /// The label text shown on the card.
+ /// The name of the owner displayed on the card.
+ /// The door permission flags for the card.
+ /// The color representing the permission levels on the keycard.
+ /// The background/tint color of the card.
+ /// The color of the label text.
+ /// The newly created .
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, DoorPermissionFlags permissions, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(permissions), levelsColor, keycardTintColor, labelColor);
+
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The display name of the keycard.
+ /// The label text shown on the card.
+ /// The name of the owner displayed on the card.
+ /// The containment access level.
+ /// The armory access level.
+ /// The admin access level.
+ /// The color representing the permission levels on the keycard.
+ /// The background/tint color of the card.
+ /// The color of the label text.
+ /// Whether to clamp the access level values to valid ranges.
+ /// The newly created .
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, int containmentLevel, int armoryLevel, int adminLevel, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor, bool clampLevels = true) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(containmentLevel, armoryLevel, adminLevel, clampLevels), levelsColor, keycardTintColor, labelColor);
+
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The name of keycard.
+ /// The label text to display on the keycard.
+ /// The name of the owner to display on the keycard.
+ /// The level associated with the keycard.
+ /// The color representing the levels on the keycard.
+ /// The background color of the keycard.
+ /// The color of the label text on the keycard.
+ /// The newly created .
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, KeycardLevels levels, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor)
+ {
+ if (!keycardType.GetItemType().TryGetTemplate(out KeycardItem keycard) || !keycard.Customizable)
+ throw new ArgumentException($"The provided ItemType {keycardType} is not a valid keycard type or cant be customizable type.", nameof(keycardType));
+
+ NametagDetail._customNametag = ownerName;
+ CustomPermsDetail._customLevels = levels;
+ CustomLabelDetail._customText = labelText;
+ CustomLabelDetail._customColor = labelColor;
+ CustomPermsDetail._customColor = levelsColor;
+ CustomItemNameDetail._customText = keycardName;
+ CustomTintDetail._customColor = keycardTintColor;
+
+ return new Keycard(keycard.ItemTypeId);
}
///
@@ -73,4 +147,4 @@ public KeycardPermissions Permissions
/// A string containing Keycard-related data.
public override string ToString() => $"{Type} ({Serial}) [{Weight}] *{Scale}* |{Permissions}|";
}
-}
\ No newline at end of file
+}
From dfd825fd13640bdefb0b4c1b139981bba80b18ed Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Sun, 10 Aug 2025 18:09:34 +0300
Subject: [PATCH 4/9] Update Keycard.cs
---
EXILED/Exiled.API/Features/Items/Keycard.cs | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Items/Keycard.cs b/EXILED/Exiled.API/Features/Items/Keycard.cs
index 38148b0bc..162bdec0e 100644
--- a/EXILED/Exiled.API/Features/Items/Keycard.cs
+++ b/EXILED/Exiled.API/Features/Items/Keycard.cs
@@ -91,10 +91,10 @@ public KeycardPermissions Permissions
/// The name of the owner displayed on the card.
/// The door permission flags for the card.
/// The color representing the permission levels on the keycard.
- /// The background/tint color of the card.
+ /// The tint color of the card.
/// The color of the label text.
/// The newly created .
- public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, DoorPermissionFlags permissions, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(permissions), levelsColor, keycardTintColor, labelColor);
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, DoorPermissionFlags permissions, Color32 levelsColor, Color32 tintColor, Color32 labelColor) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(permissions), levelsColor, tintColor, labelColor);
///
/// Creates and returns a representing the provided .
@@ -107,11 +107,11 @@ public KeycardPermissions Permissions
/// The armory access level.
/// The admin access level.
/// The color representing the permission levels on the keycard.
- /// The background/tint color of the card.
+ /// The tint color of the card.
/// The color of the label text.
/// Whether to clamp the access level values to valid ranges.
/// The newly created .
- public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, int containmentLevel, int armoryLevel, int adminLevel, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor, bool clampLevels = true) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(containmentLevel, armoryLevel, adminLevel, clampLevels), levelsColor, keycardTintColor, labelColor);
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, int containmentLevel, int armoryLevel, int adminLevel, Color32 levelsColor, Color32 tintColor, Color32 labelColor, bool clampLevels = true) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(containmentLevel, armoryLevel, adminLevel, clampLevels), levelsColor, tintColor, labelColor);
///
/// Creates and returns a representing the provided .
@@ -122,10 +122,10 @@ public KeycardPermissions Permissions
/// The name of the owner to display on the keycard.
/// The level associated with the keycard.
/// The color representing the levels on the keycard.
- /// The background color of the keycard.
+ /// The tilt color of the keycard.
/// The color of the label text on the keycard.
/// The newly created .
- public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, KeycardLevels levels, Color32 levelsColor, Color32 keycardTintColor, Color32 labelColor)
+ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, KeycardLevels levels, Color32 levelsColor, Color32 tintColor, Color32 labelColor)
{
if (!keycardType.GetItemType().TryGetTemplate(out KeycardItem keycard) || !keycard.Customizable)
throw new ArgumentException($"The provided ItemType {keycardType} is not a valid keycard type or cant be customizable type.", nameof(keycardType));
@@ -133,10 +133,10 @@ public static Keycard CreateCustom(CustomizableKeycardType keycardType, string k
NametagDetail._customNametag = ownerName;
CustomPermsDetail._customLevels = levels;
CustomLabelDetail._customText = labelText;
+ CustomTintDetail._customColor = tintColor;
CustomLabelDetail._customColor = labelColor;
CustomPermsDetail._customColor = levelsColor;
CustomItemNameDetail._customText = keycardName;
- CustomTintDetail._customColor = keycardTintColor;
return new Keycard(keycard.ItemTypeId);
}
From b4c93bc456c6038d6a1020f91fa616ad76846e29 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Mon, 11 Aug 2025 18:08:17 +0300
Subject: [PATCH 5/9] Update EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
---
EXILED/Exiled.API/Enums/CustomizableKeycardType.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs b/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
index f30a063f4..323ac48d8 100644
--- a/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
+++ b/EXILED/Exiled.API/Enums/CustomizableKeycardType.cs
@@ -36,6 +36,6 @@ public enum CustomizableKeycardType
///
/// Used by .
///
- Standart,
+ Standard,
}
}
From 42e03e7703946685de5c4280b09e5d58b4cb5978 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Mon, 11 Aug 2025 18:11:48 +0300
Subject: [PATCH 6/9] Update ItemExtensions.cs
---
EXILED/Exiled.API/Extensions/ItemExtensions.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EXILED/Exiled.API/Extensions/ItemExtensions.cs b/EXILED/Exiled.API/Extensions/ItemExtensions.cs
index 9bbf3f6c4..9bd84ca2f 100644
--- a/EXILED/Exiled.API/Extensions/ItemExtensions.cs
+++ b/EXILED/Exiled.API/Extensions/ItemExtensions.cs
@@ -209,7 +209,7 @@ public static int GetMaxAmmo(this FirearmType item)
public static ItemType GetItemType(this CustomizableKeycardType type) => type switch
{
CustomizableKeycardType.Vertical => ItemType.KeycardCustomManagement,
- CustomizableKeycardType.Standart => ItemType.KeycardCustomSite02,
+ CustomizableKeycardType.Standard => ItemType.KeycardCustomSite02,
CustomizableKeycardType.MetalFramed => ItemType.KeycardCustomMetalCase,
CustomizableKeycardType.Perforated => ItemType.KeycardCustomTaskForce,
_ => ItemType.None,
From a09d8d2d06d5e3bf306ce448a1d684bd44a5d65d Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Mon, 11 Aug 2025 21:39:06 +0300
Subject: [PATCH 7/9] Update KeycardPickup.cs
---
.../Features/Pickups/KeycardPickup.cs | 75 +++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs b/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
index e7e29ff13..854bd85d3 100644
--- a/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
+++ b/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
@@ -51,6 +51,81 @@ internal KeycardPickup(ItemType type)
///
public new BaseKeycard Base { get; }
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The display name of the keycard.
+ /// The label text shown on the keycard.
+ /// The name of the owner displayed on the keycard.
+ /// The door permission flags for the card.
+ /// The color representing the permission levels on the keycard.
+ /// The tint color of the card.
+ /// The color of the label text.
+ /// The position of the pickup.
+ /// The rotation of pickup.
+ /// Whether the pickup will spawn or not.
+ /// The newly created .
+ public static KeycardPickup CreateCustomKeycardPickup(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, DoorPermissionFlags permissions, Color32 levelsColor, Color32 tintColor, Color32 labelColor, Vector3 spawnPosition, Quaternion rotation, bool spawn = false)
+ {
+ Keycard item = Keycard.CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(permissions), levelsColor, tintColor, labelColor);
+
+ KeycardPickup pickup = (KeycardPickup)item.CreatePickup(spawnPosition, rotation, spawn);
+
+ return pickup;
+ }
+
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The display name of the keycard.
+ /// The label text shown on the keycard.
+ /// The name of the owner displayed on the keycard.
+ /// The containment access level.
+ /// The armory access level.
+ /// The admin access level.
+ /// The color representing the permission levels on the keycard.
+ /// The tint color of the card.
+ /// The color of the label text.
+ /// The position of the pickup.
+ /// The rotation of pickup.
+ /// Whether the pickup will spawn or not.
+ /// /// Whether to clamp the access level values to valid ranges.
+ /// The newly created .
+ public static KeycardPickup CreateCustomKeycardPickup(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, int containmentLevel, int armoryLevel, int adminLevel, Color32 levelsColor, Color32 tintColor, Color32 labelColor, Vector3 spawnPosition, Quaternion rotation, bool spawn = false, bool clampLevels = true)
+ {
+ Keycard item = Keycard.CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(containmentLevel, armoryLevel, adminLevel, clampLevels), levelsColor, tintColor, labelColor);
+
+ KeycardPickup pickup = (KeycardPickup)item.CreatePickup(spawnPosition, rotation, spawn);
+
+ return pickup;
+ }
+
+ ///
+ /// Creates and returns a representing the provided .
+ ///
+ /// The type of keycard to create.
+ /// The display name of the keycard.
+ /// The label text shown on the keycard.
+ /// The name of the owner displayed on the keycard.
+ /// The level associated with the keycard.
+ /// The color representing the permission levels on the keycard.
+ /// The tint color of the card.
+ /// The color of the label text.
+ /// The position of the pickup.
+ /// The rotation of pickup.
+ /// Whether the pickup will spawn or not.
+ /// The newly created .
+ public static KeycardPickup CreateCustomKeycardPickup(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, KeycardLevels levels, Color32 levelsColor, Color32 tintColor, Color32 labelColor, Vector3 spawnPosition, Quaternion rotation, bool spawn = false)
+ {
+ Keycard item = Keycard.CreateCustom(keycardType, keycardName, labelText, ownerName, levels, levelsColor, tintColor, labelColor);
+
+ KeycardPickup pickup = (KeycardPickup)item.CreatePickup(spawnPosition, rotation, spawn);
+
+ return pickup;
+ }
+
///
internal override void ReadItemInfo(Item item)
{
From 9302d74e284c8c83d7fcbf62c3cfb1ec78031764 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Mon, 11 Aug 2025 21:40:21 +0300
Subject: [PATCH 8/9] Update KeycardPickup.cs
---
EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs b/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
index 854bd85d3..47c639eb3 100644
--- a/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
+++ b/EXILED/Exiled.API/Features/Pickups/KeycardPickup.cs
@@ -10,9 +10,10 @@ namespace Exiled.API.Features.Pickups
using Exiled.API.Enums;
using Exiled.API.Features.Items;
using Exiled.API.Interfaces;
-
+ using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items;
using InventorySystem.Items.Keycards;
+ using UnityEngine;
using BaseKeycard = InventorySystem.Items.Keycards.KeycardPickup;
From 627ece088165b1fd226a38710b77aaa70b9b4fa7 Mon Sep 17 00:00:00 2001
From: MS-crew <100300664+MS-crew@users.noreply.github.com>
Date: Mon, 11 Aug 2025 22:38:24 +0300
Subject: [PATCH 9/9] Update Keycard.cs
---
EXILED/Exiled.API/Features/Items/Keycard.cs | 39 ++++-----------------
1 file changed, 6 insertions(+), 33 deletions(-)
diff --git a/EXILED/Exiled.API/Features/Items/Keycard.cs b/EXILED/Exiled.API/Features/Items/Keycard.cs
index 162bdec0e..408f3a455 100644
--- a/EXILED/Exiled.API/Features/Items/Keycard.cs
+++ b/EXILED/Exiled.API/Features/Items/Keycard.cs
@@ -46,6 +46,11 @@ internal Keycard(ItemType type)
///
public new KeycardItem Base { get; }
+ ///
+ /// Gets a value indicating whether .
+ ///
+ public bool IsCustomizable => Base.Customizable;
+
///
/// Gets or sets the of the keycard.
///
@@ -75,44 +80,12 @@ public KeycardPermissions Permissions
return;
}
- CustomPermsDetail._customLevels = new KeycardLevels((DoorPermissionFlags)value);
-
KeycardDetailSynchronizer.Database.Remove(Serial);
+ CustomPermsDetail._customLevels = new KeycardLevels((DoorPermissionFlags)value);
KeycardDetailSynchronizer.ServerProcessItem(Base);
}
}
- ///
- /// Creates and returns a representing the provided .
- ///
- /// The type of keycard to create.
- /// The display name of the keycard.
- /// The label text shown on the card.
- /// The name of the owner displayed on the card.
- /// The door permission flags for the card.
- /// The color representing the permission levels on the keycard.
- /// The tint color of the card.
- /// The color of the label text.
- /// The newly created .
- public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, DoorPermissionFlags permissions, Color32 levelsColor, Color32 tintColor, Color32 labelColor) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(permissions), levelsColor, tintColor, labelColor);
-
- ///
- /// Creates and returns a representing the provided .
- ///
- /// The type of keycard to create.
- /// The display name of the keycard.
- /// The label text shown on the card.
- /// The name of the owner displayed on the card.
- /// The containment access level.
- /// The armory access level.
- /// The admin access level.
- /// The color representing the permission levels on the keycard.
- /// The tint color of the card.
- /// The color of the label text.
- /// Whether to clamp the access level values to valid ranges.
- /// The newly created .
- public static Keycard CreateCustom(CustomizableKeycardType keycardType, string keycardName, string labelText, string ownerName, int containmentLevel, int armoryLevel, int adminLevel, Color32 levelsColor, Color32 tintColor, Color32 labelColor, bool clampLevels = true) => CreateCustom(keycardType, keycardName, labelText, ownerName, new KeycardLevels(containmentLevel, armoryLevel, adminLevel, clampLevels), levelsColor, tintColor, labelColor);
-
///
/// Creates and returns a representing the provided .
///