Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
752d39b
Some stuff
Someone-193 Aug 12, 2025
dda9729
RELEASE MEEEEEEEEEEEEEEE
Someone-193 Aug 20, 2025
04c6d69
Merge branch 'dev' into KeycardRework
Someone-193 Aug 20, 2025
002e540
Fix stuff
Someone-193 Aug 20, 2025
de1ada9
Add Create methods
Someone-193 Aug 20, 2025
6ec426b
I am Exceptionnally allowing this breaking change
louis1706 Aug 22, 2025
869ed26
do not look this
louis1706 Aug 22, 2025
1517da4
Merge branch 'ExMod-dev' into pr/632
louis1706 Aug 22, 2025
e73ffa2
Merge branch 'dev' into KeycardRework
louis1706 Aug 23, 2025
88fcf30
Refactor keycard item creation logic
louis1706 Aug 23, 2025
bf59e10
Merge branch 'KeycardRework' of https://github.com/Someone-193/EXILED…
louis1706 Aug 23, 2025
471811a
Fix using error
louis1706 Aug 23, 2025
30c8751
Many headaches
Someone-193 Aug 26, 2025
2788ee3
Fix color and CustomKeycards using old values,
Someone-193 Aug 27, 2025
3e6e63a
Modification on KeycardCustom being Inherited by Keycard
louis1706 Aug 27, 2025
3ced522
Fix build error
louis1706 Aug 27, 2025
f384d80
Using Color32 and use of void Prefix
louis1706 Aug 27, 2025
3d89006
Oups HarmonyPrefix
louis1706 Aug 27, 2025
0eb41ba
CustomSerialNumberDetail
louis1706 Aug 27, 2025
a486d70
Fix NW bug lol
Someone-193 Aug 27, 2025
c28f426
Consolidate dictionaries + add clearing
Someone-193 Aug 27, 2025
a3abb2f
Poor choice of method (and using error)
Someone-193 Aug 27, 2025
2639941
add ToString override
louis1706 Aug 27, 2025
05eed99
I fix
Someone-193 Aug 27, 2025
5683e24
Rename stuff, revert to Color, add FindMatch and CustomKeycardPickup …
Someone-193 Aug 28, 2025
bf15205
Add stability
Someone-193 Aug 28, 2025
b1c6c9f
Use Color.clear instead of new Color32
louis1706 Aug 28, 2025
e837150
just improving code readability and fix matchDesign
louis1706 Aug 28, 2025
13a2956
Add ChaosKeycard and SingleUseKeycard
louis1706 Aug 29, 2025
f0c30c9
PartiallyRevert previous commit
louis1706 Aug 29, 2025
7958173
Add the Pickup Class for SingleUse And Chaos Keycard
louis1706 Aug 29, 2025
2ffc80f
minor docs change
Someone-193 Aug 30, 2025
091dd44
Add SingleUseKeycard pickup info reading and ChaosKeycard SnakeEngine…
louis1706 Aug 30, 2025
bdc5f8b
Merge branch 'KeycardRework' of https://github.com/Someone-193/EXILED…
louis1706 Aug 30, 2025
4b09399
Fix Keycard::Create using wrong ItemType
louis1706 Sep 1, 2025
6ca8399
tinybrain moment :trollface:
Someone-193 Sep 1, 2025
e30dc9d
Add Uses property for SingleUseKeycard and implement functionality
Someone-193 Sep 1, 2025
317ab7b
Merge branch 'dev' into KeycardRework
louis1706 Sep 3, 2025
846235e
Fix a bit of silliness
Someone-193 Sep 4, 2025
13ff535
slight forgor?
Someone-193 Sep 4, 2025
5bd60b3
Fix Rank + Accidental Resync call
Someone-193 Sep 5, 2025
62f7e22
PredefinedPerms being editable (not sync)
louis1706 Sep 10, 2025
989f139
Remove blank lines between get and set methods
louis1706 Sep 10, 2025
29745b4
No need of multiple Log combine them all
louis1706 Sep 10, 2025
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: 2 additions & 0 deletions EXILED/Exiled.API/Exiled.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
<Reference Include="Pooling" HintPath="$(EXILED_REFERENCES)\Pooling.dll" Private="false" />
<Reference Include="Mirror" HintPath="$(EXILED_REFERENCES)\Mirror.dll" Private="false" />
<Reference Include="NorthwoodLib" HintPath="$(EXILED_REFERENCES)\NorthwoodLib.dll" Private="false" />
<Reference Include="Snake" HintPath="$(EXILED_REFERENCES)\Snake.dll" Private="false" />
<Reference Include="Unity.TextMeshPro" HintPath="$(EXILED_REFERENCES)\Unity.TextMeshPro.dll" Private="false" />
<Reference Include="UnityEngine" HintPath="$(EXILED_REFERENCES)\UnityEngine.dll" Private="false" />
<Reference Include="UnityEngine.CoreModule" HintPath="$(EXILED_REFERENCES)\UnityEngine.CoreModule.dll" Private="false" />
<Reference Include="UnityEngine.ParticleSystemModule" HintPath="$(EXILED_REFERENCES)\UnityEngine.ParticleSystemModule.dll" Private="false" />
<Reference Include="UnityEngine.PhysicsModule" HintPath="$(EXILED_REFERENCES)\UnityEngine.PhysicsModule.dll" Private="false" />
<Reference Include="UnityEngine.AudioModule" HintPath="$(EXILED_REFERENCES)\UnityEngine.AudioModule.dll" Private="false" />
<Reference Include="UnityEngine.UI" HintPath="$(EXILED_REFERENCES)\UnityEngine.UI.dll" Private="false" />
<Reference Include="YamlDotNet" HintPath="$(EXILED_REFERENCES)\YamlDotNet.dll" Private="false" />
</ItemGroup>

Expand Down
8 changes: 8 additions & 0 deletions EXILED/Exiled.API/Extensions/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public static class ItemExtensions
/// <returns>Returns whether the <see cref="ItemType"/> is a keycard.</returns>
public static bool IsKeycard(this ItemType type) => GetCategory(type) == ItemCategory.Keycard;

/// <summary>
/// Checks if an <see cref="ItemType"/> is a custom keycard.
/// </summary>
/// <param name="type">The item to be checked.</param>
/// <returns>Returns where the <see cref="ItemType"/> is a custom keycard.</returns>
/// <remarks>This just signifies whether the ItemType represents a keycard that has modifiable properties.</remarks>
public static bool IsCustomKeycard(this ItemType type) => type is ItemType.KeycardCustomTaskForce or ItemType.KeycardCustomSite02 or ItemType.KeycardCustomManagement or ItemType.KeycardCustomMetalCase;

/// <summary>
/// Given an <see cref="ItemType"/>, returns the matching <see cref="ItemBase"/>.
/// </summary>
Expand Down
27 changes: 27 additions & 0 deletions EXILED/Exiled.API/Extensions/MirrorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ namespace Exiled.API.Extensions
using CustomPlayerEffects;
using Exiled.API.Enums;
using Exiled.API.Features.Items;
using Exiled.API.Features.Items.Keycards;
using Exiled.API.Features.Pickups.Keycards;
using Features;
using Features.Pools;
using InventorySystem;
using InventorySystem.Items;
using InventorySystem.Items.Firearms;
using InventorySystem.Items.Firearms.Modules;
using InventorySystem.Items.Keycards;
using MEC;
using Mirror;
using PlayerRoles;
Expand Down Expand Up @@ -401,6 +404,30 @@ public static void SendFakeEffectTo(this Player effectOwner, Player target, Effe
});
}

/// <summary>
/// Makes the server resend a message to all clients updating a keycards details to current values.
/// </summary>
/// <param name="customKeycardItem">The keycard to resync.</param>
public static void ResyncKeycardItem(CustomKeycardItem customKeycardItem)
{
if (KeycardDetailSynchronizer.Database.Remove(customKeycardItem.Serial))
{
KeycardDetailSynchronizer.ServerProcessItem(customKeycardItem.Base);
}
}

/// <summary>
/// Makes the server resend a message to all clients updating a keycards details to current values.
/// </summary>
/// <param name="customKeycard">The keycard to resync.</param>
public static void ResyncKeycardPickup(CustomKeycardPickup customKeycard)
{
if (KeycardDetailSynchronizer.Database.Remove(customKeycard.Serial))
{
KeycardDetailSynchronizer.ServerProcessPickup(customKeycard.Base);
}
}

/// <summary>
/// Send CASSIE announcement that only <see cref="Player"/> can hear.
/// </summary>
Expand Down
29 changes: 27 additions & 2 deletions EXILED/Exiled.API/Features/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Exiled.API.Features.Items

using Exiled.API.Extensions;
using Exiled.API.Features.Core;
using Exiled.API.Features.Items.Keycards;
using Exiled.API.Features.Pickups;
using Exiled.API.Interfaces;
using InventorySystem;
Expand Down Expand Up @@ -217,7 +218,19 @@ public static Item Get(ItemBase itemBase)
return itemBase switch
{
InventorySystem.Items.Firearms.Firearm firearm => new Firearm(firearm),
KeycardItem keycard => new Keycard(keycard),
KeycardItem keycard => keycard switch
{
ChaosKeycardItem chaosKeycardItem => new ChaosKeycard(chaosKeycardItem),
SingleUseKeycardItem singleUseKeycardItem => new SingleUseKeycard(singleUseKeycardItem),
_ => keycard.ItemTypeId switch
{
ItemType.KeycardCustomTaskForce => new TaskForceKeycard(keycard),
ItemType.KeycardCustomSite02 => new Site02Keycard(keycard),
ItemType.KeycardCustomManagement => new ManagementKeycard(keycard),
ItemType.KeycardCustomMetalCase => new MetalKeycard(keycard),
_ => new Keycard(keycard),
}
},
UsableItem usable => usable switch
{
Scp330Bag scp330Bag => new Scp330(scp330Bag),
Expand Down Expand Up @@ -304,7 +317,19 @@ public static T Get<T>(ushort serial)
public static Item Create(ItemType type, Player owner = null) => type.GetTemplate() switch
{
InventorySystem.Items.Firearms.Firearm => new Firearm(type),
KeycardItem => new Keycard(type),
KeycardItem keycard => keycard switch
{
ChaosKeycardItem => new ChaosKeycard(type),
SingleUseKeycardItem => new SingleUseKeycard(type),
_ => type switch
{
ItemType.KeycardCustomTaskForce => new TaskForceKeycard(type),
ItemType.KeycardCustomSite02 => new Site02Keycard(type),
ItemType.KeycardCustomManagement => new ManagementKeycard(type),
ItemType.KeycardCustomMetalCase => new MetalKeycard(type),
_ => new Keycard(type, owner),
}
},
UsableItem usable => usable switch
{
Scp330Bag => new Scp330(),
Expand Down
34 changes: 20 additions & 14 deletions EXILED/Exiled.API/Features/Items/Keycard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

namespace Exiled.API.Features.Items
{
using System;

using Exiled.API.Enums;
using Exiled.API.Interfaces;
using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items.Keycards;

/// <summary>
Expand All @@ -32,8 +31,9 @@ public Keycard(KeycardItem itemBase)
/// Initializes a new instance of the <see cref="Keycard"/> class.
/// </summary>
/// <param name="type">The <see cref="ItemType"/> of the keycard.</param>
internal Keycard(ItemType type)
: this((KeycardItem)Server.Host.Inventory.CreateItemInstance(new(type, 0), false))
/// <param name="owner">The owner of the grenade. Leave <see langword="null"/> for no owner.</param>
internal Keycard(ItemType type, Player owner = null)
: this((KeycardItem)(owner ?? Server.Host).Inventory.CreateItemInstance(new(type, 0), false))
{
}

Expand All @@ -45,26 +45,32 @@ internal Keycard(ItemType type)
/// <summary>
/// Gets or sets the <see cref="KeycardPermissions"/> of the keycard.
/// </summary>
public KeycardPermissions Permissions
public virtual KeycardPermissions Permissions
{
get
{
foreach (DetailBase detail in Base.Details)
{
switch (detail)
{
case PredefinedPermsDetail predefinedPermsDetail:
return (KeycardPermissions)predefinedPermsDetail.Levels.Permissions;
case CustomPermsDetail customPermsDetail:
return (KeycardPermissions)customPermsDetail.GetPermissions(null);
}
if (detail is IDoorPermissionProvider doorPermissionProvider)
return (KeycardPermissions)doorPermissionProvider.GetPermissions(null);
}

return KeycardPermissions.None;
}

[Obsolete("Not functional anymore", true)]
set => _ = value;
set
{
foreach (DetailBase detail in Base.Details)
{
if (detail is PredefinedPermsDetail doorPermissionProvider)
{
KeycardLevels keycardLevels = new((DoorPermissionFlags)value);
doorPermissionProvider._containmentLevel = keycardLevels.Containment;
doorPermissionProvider._armoryLevel = keycardLevels.Armory;
doorPermissionProvider._adminLevel = keycardLevels.Admin;
}
}
}
}

/// <summary>
Expand Down
54 changes: 54 additions & 0 deletions EXILED/Exiled.API/Features/Items/Keycards/ChaosKeycard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// -----------------------------------------------------------------------
// <copyright file="ChaosKeycard.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.Keycards
{
using InventorySystem.Items;
using InventorySystem.Items.Keycards;
using InventorySystem.Items.Keycards.Snake;

/// <summary>
/// A base class for chaos keycard items.
/// </summary>
public class ChaosKeycard : Keycard
{
/// <summary>
/// Initializes a new instance of the <see cref="ChaosKeycard"/> class.
/// </summary>
/// <param name="itemBase">The <see cref="ItemBase"/> to encapsulate.</param>
internal ChaosKeycard(ChaosKeycardItem itemBase)
: base(itemBase)
{
Base = itemBase;
}

/// <summary>
/// Initializes a new instance of the <see cref="ChaosKeycard"/> class.
/// </summary>
/// <param name="type">The <see cref="ItemType"/> of the item to create.</param>
internal ChaosKeycard(ItemType type)
: this((ChaosKeycardItem)Server.Host.Inventory.CreateItemInstance(new(type, 0), false))
{
}

/// <summary>
/// Gets the <see cref="KeycardItem"/> this encapsulates.
/// </summary>
public new ChaosKeycardItem Base { get; }

/// <summary>
/// Gets the <see cref="InventorySystem.Items.Keycards.Snake.SnakeEngine"/> this encapsulates.
/// </summary>
public SnakeEngine SnakeEngine => Base._localEngine;

/// <summary>
/// Returns the Keycard in a human readable format.
/// </summary>
/// <returns>A string containing Keycard-related data.</returns>
public override string ToString() => $"{Type} == ({Serial}) [{Weight}] *{Scale}* |{Permissions}|";
}
}
Loading
Loading