protected override void OnPrefabInit() { base.OnPrefabInit(); if (Storage_OnQueueDestroyObjectDelegate == null) { Storage_OnQueueDestroyObjectDelegate = Traverse.Create <Storage>().Field <EventSystem.IntraObjectHandler <Storage> >("OnQueueDestroyObjectDelegate").Value; Storage_OnQueueDestroyObjectHandler = Traverse.Create(Storage_OnQueueDestroyObjectDelegate).Field <Action <Storage, object> >("handler").Value; } }
public static void Patch(Harmony harmony) { if (!PRegistry.GetData <bool>(PATCH_KEY)) { OnRefreshUserMenuDelegate = Traverse.Create <ManualDeliveryKG>() .Field <EventSystem.IntraObjectHandler <ManualDeliveryKG> >(nameof(OnRefreshUserMenuDelegate)).Value; harmony.Patch(typeof(ManualDeliveryKG), nameof(OnSpawn), postfix: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(OnSpawn))); harmony.Patch(typeof(ManualDeliveryKG), nameof(OnCleanUp), prefix: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(OnCleanUp))); harmony.PatchTranspile(typeof(ManualDeliveryKG), "OnRefreshUserMenu", transpiler: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(Transpiler))); PRegistry.PutData(PATCH_KEY, true); } }
public static int Subscribe <ComponentType>(this GameObject go, int hash, EventSystem.IntraObjectHandler <ComponentType> handler) { return(KObjectManager.Instance.GetOrCreateObject(go).GetEventSystem().Subscribe(hash, handler)); }
// wrapper to avoid typecasting hash internal static int Subscribe <ComponentType>(this KMonoBehaviour behaviour, GameHashes hash, EventSystem.IntraObjectHandler <ComponentType> handler) where ComponentType : Component { return(behaviour.Subscribe((int)hash, handler)); }