actiontoggletentopen.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. class ActionToggleTentOpen: ActionInteractBase
  2. {
  3. void ActionToggleTentOpen()
  4. {
  5. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_INTERACTONCE;
  6. m_Text = "#toggle_opening";
  7. }
  8. override void CreateConditionComponents()
  9. {
  10. m_ConditionItem = new CCINone;
  11. m_ConditionTarget = new CCTCursorParent(UAMaxDistances.DEFAULT);
  12. }
  13. override bool IsUsingProxies()
  14. {
  15. return true;
  16. }
  17. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  18. {
  19. Object targetObject = target.GetObject();
  20. Object targetParent = target.GetParent();
  21. if ( player && targetObject && targetParent )
  22. {
  23. if ( targetParent.IsInherited(TentBase) )
  24. {
  25. array<string> selections = new array<string>;
  26. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  27. TentBase tent = TentBase.Cast( targetParent );
  28. for (int s = 0; s < selections.Count(); s++)
  29. {
  30. if ( tent.CanToggleAnimations(selections[s]) )
  31. {
  32. //Print("nazov selekcie: " + selections[s]);
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. override void OnExecuteServer( ActionData action_data )
  41. {
  42. Object targetObject = action_data.m_Target.GetObject();
  43. Object targetParent = action_data.m_Target.GetParent();
  44. if ( targetParent && targetParent.IsInherited(TentBase) )
  45. {
  46. array<string> selections = new array<string>;
  47. targetObject.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
  48. TentBase tent = TentBase.Cast( targetParent );
  49. for ( int s = 0; s < selections.Count(); s++)
  50. {
  51. if ( tent.CanToggleAnimations(selections[s]) )
  52. {
  53. tent.ToggleAnimation( selections[s] );
  54. }
  55. }
  56. //regenerate pathgraph
  57. tent.SetAffectPathgraph( true, false );
  58. if ( tent.CanAffectPathgraph() )
  59. {
  60. //Start update
  61. tent.RegenerateNavmesh();
  62. }
  63. }
  64. }
  65. };