using System.Reflection; using NitroxClient.Communication.Abstract; using NitroxModel.DataStructures; using NitroxModel.Helper; using NitroxModel.Packets; namespace NitroxPatcher.Patches.Dynamic; /// /// Broadcasts destruction of GrownPlants differently than because /// GrownPlants don't hold their own NitroxEntity /// public sealed partial class GrownPlant_OnKill_Patch : NitroxPatch, IDynamicPatch { public static readonly MethodInfo TARGET_METHOD = Reflect.Method((GrownPlant p) => p.OnKill()); public static void Prefix(GrownPlant __instance) { if (__instance.seed && __instance.seed.TryGetIdOrWarn(out NitroxId seedId)) { Resolve().Send(new EntityDestroyed(seedId)); } } }