Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 4
0
 // 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));
 }