Files
Nitrox/NitroxPatcher/Patches/Dynamic/BeaconLabel_SetLabel_Patch.cs
2025-07-06 00:23:46 +02:00

26 lines
843 B
C#

using System.Reflection;
using NitroxClient.GameLogic;
using NitroxModel.DataStructures;
using NitroxModel.Helper;
namespace NitroxPatcher.Patches.Dynamic;
/// <summary>
/// Adds a callback to broadcast beacon label change when edited.
/// </summary>
public sealed partial class BeaconLabel_OnHandClick_Patch : NitroxPatch, IDynamicPatch
{
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((BeaconLabel t) => t.OnHandClick(default));
public static void Postfix(BeaconLabel __instance)
{
uGUI.main.userInput.callback += _ =>
{
if (__instance.transform.parent && __instance.transform.parent.TryGetIdOrWarn(out NitroxId id))
{
Resolve<Entities>().EntityMetadataChanged(__instance.transform.parent.GetComponent<Beacon>(), id);
}
};
}
}