handreplacingiteminhands.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. class HandStartReplacingItemInHands extends HandStateBase
  2. {
  3. void HandStartReplacingItemInHands (Man player = NULL, HandStateBase parent = NULL)
  4. { }
  5. override void OnEntry (HandEventBase e)
  6. {
  7. super.OnEntry(e);
  8. Man player = e.m_Player;
  9. EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
  10. InventoryLocation src = new InventoryLocation;
  11. if (itemInHands.GetInventory().GetCurrentInventoryLocation(src))
  12. {
  13. HandEventDestroyAndReplaceWithNew edr = HandEventDestroyAndReplaceWithNew.Cast(e);
  14. if (edr)
  15. {
  16. if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandStartReplacingItemInHands about to execute lambda");
  17. HumanInventoryWithFSM inv = HumanInventoryWithFSM.Cast(player.GetInventory());
  18. edr.m_Lambda.Execute(inv);
  19. //player.GetItemAccessor().OnItemInHandsChanged();
  20. return;
  21. }
  22. else
  23. Error("[hndfsm] HandStartReplacingItemInHands - not a HandEventDestroyAndReplaceWithNew event");
  24. }
  25. else
  26. Error("[hndfsm] HandStartReplacingItemInHands - itemInHands has no InventoryLocation");
  27. }
  28. override void OnAbort (HandEventBase e)
  29. {
  30. super.OnAbort(e);
  31. }
  32. override void OnExit (HandEventBase e)
  33. {
  34. super.OnExit(e);
  35. }
  36. override bool IsWaitingForActionFinish () { return true; }
  37. };
  38. class HandReplacingItemInHands extends HandStateBase
  39. {
  40. ref HandStartReplacingItemInHands m_Replacing;
  41. void HandReplacingItemInHands (Man player = NULL, HandStateBase parent = NULL)
  42. {
  43. // setup nested state machine
  44. m_Replacing = new HandStartReplacingItemInHands(player, this);
  45. // events:
  46. HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
  47. m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
  48. m_FSM.AddTransition(new HandTransition( m_Replacing, _fin_, NULL ));
  49. m_FSM.SetInitialState(m_Replacing);
  50. }
  51. override void OnEntry (HandEventBase e)
  52. {
  53. super.OnEntry(e);
  54. }
  55. override void OnAbort (HandEventBase e)
  56. {
  57. super.OnAbort(e);
  58. }
  59. override void OnExit (HandEventBase e)
  60. {
  61. super.OnExit(e);
  62. }
  63. };