From 6bffafd9f958c13b28a12b5f9c9e33d7bc2610be Mon Sep 17 00:00:00 2001 From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com> Date: Wed, 28 May 2025 01:57:19 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=C2=AF\=5F(=E3=83=84)=5F/=C2=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Patches/Events/Scp914/UpgradingPlayer.cs | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs index 394fd8815b..e6a53933a0 100644 --- a/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs +++ b/EXILED/Exiled.Events/Patches/Events/Scp914/UpgradingPlayer.cs @@ -8,6 +8,7 @@ namespace Exiled.Events.Patches.Events.Scp914 { using System.Collections.Generic; + using System.Reflection; using System.Reflection.Emit; using API.Features; @@ -22,6 +23,7 @@ namespace Exiled.Events.Patches.Events.Scp914 using static HarmonyLib.AccessTools; + using OpCode = System.Reflection.Emit.OpCode; using Scp914 = Handlers.Scp914; /// @@ -112,8 +114,17 @@ private static IEnumerable Transpiler(IEnumerable x.opcode == OpCodes.Stloc_S && x.operand is LocalBuilder { LocalIndex: 10 }) + offset; - + //index = newInstructions.FindIndex(x => x.opcode == OpCodes.Stloc_S && x.operand is LocalBuilder { LocalIndex: 10 }) + offset; + ConstructorInfo plugin_api_constructor = typeof(LabApi.Events.Arguments.Scp914Events.Scp914ProcessingInventoryItemEventArgs) + .GetConstructor(new[] { + typeof(InventorySystem.Items.ItemBase), + typeof(Scp914KnobSetting), + typeof(ReferenceHub) + }); + index = newInstructions.FindIndex(x => x.Is(OpCodes.Newobj, plugin_api_constructor)) + offset; + //ridtp lcz914 + //noclip + //give tuxwonder7 47 newInstructions.InsertRange( index, new CodeInstruction[] @@ -121,34 +132,34 @@ private static IEnumerable Transpiler(IEnumerable Date: Thu, 29 May 2025 23:52:38 -0400 Subject: [PATCH 2/4] Test --- EXILED/Exiled.API/Exiled.API.csproj | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Exiled.API.csproj b/EXILED/Exiled.API/Exiled.API.csproj index c8737a790c..0d86a22672 100644 --- a/EXILED/Exiled.API/Exiled.API.csproj +++ b/EXILED/Exiled.API/Exiled.API.csproj @@ -41,7 +41,18 @@ - if not "$(EXILED_DEV_PLUGINAPI_REFERENCE)"=="" copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE)\dependencies\" && if not "$(EXILED_DEV_REFERENCES)"=="" copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_REFERENCES)\Plugins\dependencies\" + + if not "$(EXILED_DEV_PLUGINAPI_REFERENCE)"=="" ( + copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE)\dependencies\" + ) + if not "$(EXILED_DEV_REFERENCES)"=="" ( + copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_REFERENCES)\Plugins\dependencies\" + ) + if not "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)"=="" ( + if not exist "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global" mkdir "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global" + copy /y "$(OutputPath)$(AssemblyName).dll" "$(EXILED_DEV_PLUGINAPI_REFERENCE_GLOBAL)\dependencies\global\" + ) + if [[ ! -z "$EXILED_DEV_REFERENCES" ]]; then cp "$(OutputPath)$(AssemblyName).dll" "$EXILED_DEV_REFERENCES/Plugins/dependencies/"; fi From 26a7f3355226282e7a546e62407851130d072233 Mon Sep 17 00:00:00 2001 From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com> Date: Thu, 29 May 2025 23:52:42 -0400 Subject: [PATCH 3/4] test 2 --- EXILED/Exiled.API/Features/Items/Keycard.cs | 2 +- .../API/Features/CustomItem.cs | 1 + .../API/Features/CustomKeycard.cs | 109 +++++++++++++++--- 3 files changed, 93 insertions(+), 19 deletions(-) diff --git a/EXILED/Exiled.API/Features/Items/Keycard.cs b/EXILED/Exiled.API/Features/Items/Keycard.cs index 4e68dd60a5..6010ab6781 100644 --- a/EXILED/Exiled.API/Features/Items/Keycard.cs +++ b/EXILED/Exiled.API/Features/Items/Keycard.cs @@ -33,7 +33,7 @@ public Keycard(KeycardItem itemBase) /// /// The of the keycard. internal Keycard(ItemType type) - : this((KeycardItem)Server.Host.Inventory.CreateItemInstance(new(type, 0), false)) + : this((KeycardItem)Server.Host.Inventory.CreateItemInstance(new(type, 1), false)) { } diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index cf6d937b8b..b37d765afd 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -643,6 +643,7 @@ public virtual void Give(Player player, Item item, bool displayMessage = true) { try { + Log.Info($"Item base null? {item}, {item?.Base}, {item?.Base.ItemTypeId}"); Log.Debug($"{Name}.{nameof(Give)}: Item Serial: {item.Serial} Ammo: {(item is Firearm firearm ? firearm.MagazineAmmo : -1)}"); player.AddItem(item); diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs b/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs index d53846cbb0..0e9c5f9d00 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs @@ -17,9 +17,14 @@ namespace Exiled.CustomItems.API.Features using Exiled.API.Features.Items; using Exiled.API.Features.Lockers; using Exiled.API.Features.Pickups; + using Exiled.API.Interfaces; using Exiled.Events.EventArgs.Item; using Exiled.Events.EventArgs.Player; using Interactables.Interobjects.DoorUtils; + + using InventorySystem; + using InventorySystem.Items; + using InventorySystem.Items.Autosync; using InventorySystem.Items.Keycards; using UnityEngine; @@ -55,12 +60,12 @@ public override ItemType Type /// /// Gets or sets a color of keycard label. /// - public virtual Color32? KeycardLabelColor { get; set; } + public virtual Color32? KeycardLabelColor { get; set; } = new Color32(100, 100, 100, 222); /// /// Gets or sets a tint color. /// - public virtual Color32? TintColor { get; set; } + public virtual Color32? TintColor { get; set; } = new Color32(100, 200, 100, 222); /// /// Gets or sets the permissions for custom keycard. @@ -70,20 +75,23 @@ public override ItemType Type /// /// Gets or sets a color of keycard permissions. /// - public virtual Color32? KeycardPermissionsColor { get; set; } + public virtual Color32? KeycardPermissionsColor { get; set; } = new Color32(100, 100, 200, 222); /// public override void Give(Player player, Item item, bool displayMessage = true) { - base.Give(player, item, displayMessage); - + + Log.Info("Wuhhh 11111"); if (item.Is(out Keycard card)) SetupKeycard(card); + base.Give(player, item, displayMessage); + } /// public override Pickup? Spawn(Vector3 position, Item item, Player? previousOwner = null) { + Log.Info("Wuhhh 122222"); if (item.Is(out Keycard card)) SetupKeycard(card); @@ -96,30 +104,48 @@ public override void Give(Player player, Item item, bool displayMessage = true) /// Item instance. protected virtual void SetupKeycard(Keycard keycard) { + Log.Info("waaa"); if (!keycard.Base.Customizable) + { + Log.Info("Not Customizable"); return; - + } + // InventoryItemLoader.TryGetItem(keycard.Base.ItemTypeId, out item); + // if (!keycard.Base.TryGetTemplate(keycard.Base.ItemTypeId, out BaseKeycardItem template)) + // { + // + // } + // DetailBase[] details = keycard.Base.Details; - - NametagDetail? nameDetail = details.OfType().FirstOrDefault(); - - if (nameDetail != null && !string.IsNullOrEmpty(KeycardName)) - NametagDetail._customNametag = KeycardName; - + + CustomItemNameDetail? raNameDetail = details.OfType().FirstOrDefault(); if (raNameDetail != null) + { + if (string.IsNullOrEmpty(Name)) + { + Name = string.Empty; + } raNameDetail.Name = Name; + } + + + CustomLabelDetail? labelDetail = details.OfType().FirstOrDefault(); if (labelDetail != null) { - if (!string.IsNullOrEmpty(KeycardLabel)) - CustomLabelDetail._customText = KeycardLabel; + if (string.IsNullOrEmpty(KeycardLabel)) + { + KeycardLabel = string.Empty; + } + CustomLabelDetail._customText = KeycardLabel; - if (KeycardLabelColor.HasValue) - CustomLabelDetail._customColor = KeycardLabelColor.Value; + + KeycardLabelColor ??= new Color32(100, 200, 200, 222); + CustomLabelDetail._customColor = KeycardLabelColor.Value; } CustomPermsDetail? permsDetail = details.OfType().FirstOrDefault(); @@ -127,15 +153,62 @@ protected virtual void SetupKeycard(Keycard keycard) if (permsDetail != null) { CustomPermsDetail._customLevels = new((DoorPermissionFlags)Permissions); + KeycardPermissionsColor ??= new Color32(200, 100, 200, 222); CustomPermsDetail._customColor = KeycardPermissionsColor; } + + CustomRankDetail? rankDetail = details.OfType().FirstOrDefault(); - CustomTintDetail? tintDetail = details.OfType().FirstOrDefault(); + if (rankDetail != null) + { + + rankDetail.SetArguments(new ArraySegment(new object[] + { + 1, + }, 0, 1)); + } + + // SerialNumberDetail? serialDetail = details.OfType().FirstOrDefault(); + // + // if (serialDetail != null) + // { + // + // serialDetail.SetArguments(new ArraySegment(new object[] + // { + // 0 + // }, 0, 1)); + // } - if (tintDetail != null && TintColor.HasValue) + + CustomTintDetail? tintDetail = details.OfType().FirstOrDefault(); + if (tintDetail != null) { + TintColor ??= new Color32(100, 200, 100, 200); CustomTintDetail._customColor = TintColor.Value; } + + CustomWearDetail? wearDetail = details.OfType().FirstOrDefault(); + if (wearDetail != null) + { + wearDetail.SetArguments(new ArraySegment( + new object[] + { + 1, + }, 0, 1)); + } + + NametagDetail? nameDetail = details.OfType().FirstOrDefault(); + + if (nameDetail != null) + { + if (string.IsNullOrEmpty(KeycardName)) + { + KeycardName = string.Empty; + } + NametagDetail._customNametag = KeycardName; + } + + } /// From a657d171fbf027749813e3193fc51d09e73083fa Mon Sep 17 00:00:00 2001 From: Undid-Iridium <24619207+Undid-Iridium@users.noreply.github.com> Date: Thu, 29 May 2025 23:56:30 -0400 Subject: [PATCH 4/4] Unneeded --- .../API/Features/CustomItem.cs | 1 - .../API/Features/CustomKeycard.cs | 105 +++--------------- 2 files changed, 16 insertions(+), 90 deletions(-) diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs index b37d765afd..cf6d937b8b 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem.cs @@ -643,7 +643,6 @@ public virtual void Give(Player player, Item item, bool displayMessage = true) { try { - Log.Info($"Item base null? {item}, {item?.Base}, {item?.Base.ItemTypeId}"); Log.Debug($"{Name}.{nameof(Give)}: Item Serial: {item.Serial} Ammo: {(item is Firearm firearm ? firearm.MagazineAmmo : -1)}"); player.AddItem(item); diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs b/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs index 0e9c5f9d00..b9870d75d6 100644 --- a/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs +++ b/EXILED/Exiled.CustomItems/API/Features/CustomKeycard.cs @@ -17,14 +17,9 @@ namespace Exiled.CustomItems.API.Features using Exiled.API.Features.Items; using Exiled.API.Features.Lockers; using Exiled.API.Features.Pickups; - using Exiled.API.Interfaces; using Exiled.Events.EventArgs.Item; using Exiled.Events.EventArgs.Player; using Interactables.Interobjects.DoorUtils; - - using InventorySystem; - using InventorySystem.Items; - using InventorySystem.Items.Autosync; using InventorySystem.Items.Keycards; using UnityEngine; @@ -60,12 +55,12 @@ public override ItemType Type /// /// Gets or sets a color of keycard label. /// - public virtual Color32? KeycardLabelColor { get; set; } = new Color32(100, 100, 100, 222); + public virtual Color32? KeycardLabelColor { get; set; } /// /// Gets or sets a tint color. /// - public virtual Color32? TintColor { get; set; } = new Color32(100, 200, 100, 222); + public virtual Color32? TintColor { get; set; } /// /// Gets or sets the permissions for custom keycard. @@ -75,13 +70,11 @@ public override ItemType Type /// /// Gets or sets a color of keycard permissions. /// - public virtual Color32? KeycardPermissionsColor { get; set; } = new Color32(100, 100, 200, 222); + public virtual Color32? KeycardPermissionsColor { get; set; } /// public override void Give(Player player, Item item, bool displayMessage = true) { - - Log.Info("Wuhhh 11111"); if (item.Is(out Keycard card)) SetupKeycard(card); base.Give(player, item, displayMessage); @@ -91,7 +84,6 @@ public override void Give(Player player, Item item, bool displayMessage = true) /// public override Pickup? Spawn(Vector3 position, Item item, Player? previousOwner = null) { - Log.Info("Wuhhh 122222"); if (item.Is(out Keycard card)) SetupKeycard(card); @@ -104,48 +96,30 @@ public override void Give(Player player, Item item, bool displayMessage = true) /// Item instance. protected virtual void SetupKeycard(Keycard keycard) { - Log.Info("waaa"); if (!keycard.Base.Customizable) - { - Log.Info("Not Customizable"); return; - } - // InventoryItemLoader.TryGetItem(keycard.Base.ItemTypeId, out item); - // if (!keycard.Base.TryGetTemplate(keycard.Base.ItemTypeId, out BaseKeycardItem template)) - // { - // - // } - // + DetailBase[] details = keycard.Base.Details; - - + + NametagDetail? nameDetail = details.OfType().FirstOrDefault(); + + if (nameDetail != null && !string.IsNullOrEmpty(KeycardName)) + NametagDetail._customNametag = KeycardName; + CustomItemNameDetail? raNameDetail = details.OfType().FirstOrDefault(); if (raNameDetail != null) - { - if (string.IsNullOrEmpty(Name)) - { - Name = string.Empty; - } raNameDetail.Name = Name; - } - - - CustomLabelDetail? labelDetail = details.OfType().FirstOrDefault(); if (labelDetail != null) { - if (string.IsNullOrEmpty(KeycardLabel)) - { - KeycardLabel = string.Empty; - } - CustomLabelDetail._customText = KeycardLabel; - + if (!string.IsNullOrEmpty(KeycardLabel)) + CustomLabelDetail._customText = KeycardLabel; - KeycardLabelColor ??= new Color32(100, 200, 200, 222); - CustomLabelDetail._customColor = KeycardLabelColor.Value; + if (KeycardLabelColor.HasValue) + CustomLabelDetail._customColor = KeycardLabelColor.Value; } CustomPermsDetail? permsDetail = details.OfType().FirstOrDefault(); @@ -153,62 +127,15 @@ protected virtual void SetupKeycard(Keycard keycard) if (permsDetail != null) { CustomPermsDetail._customLevels = new((DoorPermissionFlags)Permissions); - KeycardPermissionsColor ??= new Color32(200, 100, 200, 222); CustomPermsDetail._customColor = KeycardPermissionsColor; } - - CustomRankDetail? rankDetail = details.OfType().FirstOrDefault(); - - if (rankDetail != null) - { - - rankDetail.SetArguments(new ArraySegment(new object[] - { - 1, - }, 0, 1)); - } - - // SerialNumberDetail? serialDetail = details.OfType().FirstOrDefault(); - // - // if (serialDetail != null) - // { - // - // serialDetail.SetArguments(new ArraySegment(new object[] - // { - // 0 - // }, 0, 1)); - // } - CustomTintDetail? tintDetail = details.OfType().FirstOrDefault(); - if (tintDetail != null) - { - TintColor ??= new Color32(100, 200, 100, 200); - CustomTintDetail._customColor = TintColor.Value; - } - CustomWearDetail? wearDetail = details.OfType().FirstOrDefault(); - if (wearDetail != null) + if (tintDetail != null && TintColor.HasValue) { - wearDetail.SetArguments(new ArraySegment( - new object[] - { - 1, - }, 0, 1)); - } - - NametagDetail? nameDetail = details.OfType().FirstOrDefault(); - - if (nameDetail != null) - { - if (string.IsNullOrEmpty(KeycardName)) - { - KeycardName = string.Empty; - } - NametagDetail._customNametag = KeycardName; + CustomTintDetail._customColor = TintColor.Value; } - - } ///