handreplacingitemelsewherewithnewinhands.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. class HandStartReplacingItemElsewhereWithNewInHands extends HandStateBase
  2. {
  3. void HandStartReplacingItemElsewhereWithNewInHands (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. HandEventReplaceWithNewBase edr = HandEventReplaceWithNewBase.Cast(e);
  10. if (edr)
  11. {
  12. if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[hndfsm] HandStartReplacingItemElsewhereWithNewInHands about to execute lambda");
  13. HumanInventoryWithFSM inv = HumanInventoryWithFSM.Cast(player.GetInventory());
  14. edr.m_Lambda.Execute(inv);
  15. return;
  16. }
  17. else
  18. Error("[hndfsm] HandStartReplacingItemElsewhereWithNewInHands - not a HandEvenReplaceWithNewBase event");
  19. }
  20. override void OnAbort (HandEventBase e)
  21. {
  22. super.OnAbort(e);
  23. }
  24. override void OnExit (HandEventBase e)
  25. {
  26. super.OnExit(e);
  27. }
  28. override bool IsWaitingForActionFinish () { return true; }
  29. };
  30. class HandReplacingItemElsewhereWithNewInHands extends HandStateBase
  31. {
  32. ref HandStartReplacingItemElsewhereWithNewInHands m_Replacing;
  33. void HandReplacingItemElsewhereWithNewInHands (Man player = NULL, HandStateBase parent = NULL)
  34. {
  35. // setup nested state machine
  36. m_Replacing = new HandStartReplacingItemElsewhereWithNewInHands(player, this);
  37. // events:
  38. HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
  39. m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
  40. m_FSM.AddTransition(new HandTransition( m_Replacing, _fin_, NULL ));
  41. m_FSM.SetInitialState(m_Replacing);
  42. }
  43. };