Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. internal static class ManagedHook
  2. {
  3. private const BindingFlags AllFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static |
  4. BindingFlags.Instance | BindingFlags.DeclaredOnly;
  5.  
  6. internal delegate void d_UpdatePhysicsLogic(Boy boy);
  7. internal static d_UpdatePhysicsLogic origUpdatePhysicsLogic;
  8. internal static Hook OnUpdatePhysicsLogic;
  9.  
  10. internal static void Init()
  11. {
  12. try
  13. {
  14. var fr = typeof(BoyRunState).GetMethod("UpdatePhysicsLogic", AllFlags);
  15. var to = typeof(ManagedHook).GetMethod("HookUpdatePhysicsLogic", AllFlags);
  16.  
  17. OnUpdatePhysicsLogic = new Hook(typeof(BoyRunState).GetMethod("UpdatePhysicsLogic", AllFlags),
  18. typeof(ManagedHook).GetMethod("HookUpdatePhysicsLogic", AllFlags));
  19. origUpdatePhysicsLogic = OnUpdatePhysicsLogic.GenerateTrampoline<d_UpdatePhysicsLogic>();
  20. }
  21. catch (Exception e)
  22. {
  23. Logger.Logger.Log(e.ToString(), LogLevel.Error);
  24. }
  25. }
  26.  
  27. private static void HookUpdatePhysicsLogic(Boy boy)
  28. {
  29. origUpdatePhysicsLogic(boy);
  30.  
  31. /*if (boy.state is BoyRunState boyRunState)
  32. {
  33. boyRunState.UpdateImpulses();
  34. BoyRunState.UpdatePhysicsAndCrawling(boy, vector2f.zero);
  35. //Logger.Logger.Log("a", LogLevel.Error);
  36. //boy.gameObject.transform.SetLocalPositionRotation(boy.gameObject.transform.localPosition + new Vector3(1000, 0, 0), Quaternion.identity);
  37. if (Input.GetKeyDown(KeyCode.RightArrow))
  38. {
  39.  
  40.  
  41. }
  42. }*/
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement