From aba514f42c1c6c80baebe71cf1683e54ad7b550f Mon Sep 17 00:00:00 2001 From: IRacle Date: Fri, 27 Dec 2024 23:26:31 +0300 Subject: [PATCH] [fix(test):] Microhid fix --- EXILED/Exiled.API/Features/Items/Firearm.cs | 2 ++ EXILED/Exiled.API/Features/Items/Item.cs | 2 ++ .../Patches/Fixes/ServerHubMicroHidFix.cs | 32 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 EXILED/Exiled.Events/Patches/Fixes/ServerHubMicroHidFix.cs diff --git a/EXILED/Exiled.API/Features/Items/Firearm.cs b/EXILED/Exiled.API/Features/Items/Firearm.cs index e77622d67..9be796772 100644 --- a/EXILED/Exiled.API/Features/Items/Firearm.cs +++ b/EXILED/Exiled.API/Features/Items/Firearm.cs @@ -23,6 +23,7 @@ namespace Exiled.API.Features.Items using Extensions; using InventorySystem; using InventorySystem.Items; + using InventorySystem.Items.Autosync; using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.Attachments; using InventorySystem.Items.Firearms.Attachments.Components; @@ -690,6 +691,7 @@ public override Item Clone() /// new owner. internal override void ChangeOwner(Player oldOwner, Player newOwner) { + Base.InstantiationStatus = newOwner == Server.Host ? AutosyncInstantiationStatus.SimulatedInstance : AutosyncInstantiationStatus.InventoryInstance; Base.Owner = newOwner.ReferenceHub; Base._footprintCacheSet = false; foreach (ModuleBase module in Base.Modules) diff --git a/EXILED/Exiled.API/Features/Items/Item.cs b/EXILED/Exiled.API/Features/Items/Item.cs index c55a6e75b..757e31f2c 100644 --- a/EXILED/Exiled.API/Features/Items/Item.cs +++ b/EXILED/Exiled.API/Features/Items/Item.cs @@ -62,6 +62,8 @@ public Item(ItemBase itemBase) ushort serial = ItemSerialGenerator.GenerateNext(); Serial = serial; itemBase.OnAdded(null); + if (Base is ModularAutosyncItem syncItem) + syncItem.InstantiationStatus = AutosyncInstantiationStatus.SimulatedInstance; #if DEBUG Log.Debug($"{nameof(Item)}.ctor: Generating new serial number. Serial should now be: {serial}. // {Serial}"); #endif diff --git a/EXILED/Exiled.Events/Patches/Fixes/ServerHubMicroHidFix.cs b/EXILED/Exiled.Events/Patches/Fixes/ServerHubMicroHidFix.cs new file mode 100644 index 000000000..8bd604cb5 --- /dev/null +++ b/EXILED/Exiled.Events/Patches/Fixes/ServerHubMicroHidFix.cs @@ -0,0 +1,32 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.Events.Patches.Fixes +{ +#pragma warning disable SA1313 + using API.Features.Items; + using Exiled.API.Features; + + using HarmonyLib; + + using InventorySystem.Items.Autosync; + using InventorySystem.Items.MicroHID.Modules; + using InventorySystem.Items.Pickups; + using InventorySystem.Items.Usables.Scp330; + + /// + /// Patches to fix phantom for . + /// + [HarmonyPatch(typeof(CycleSyncModule), nameof(CycleSyncModule.Update))] + internal static class ServerHubMicroHidFix + { + private static bool Prefix(CycleSyncModule __instance) + { + return __instance.MicroHid.InstantiationStatus == AutosyncInstantiationStatus.InventoryInstance; + } + } +}