actioninput.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  1. enum ActionInputType
  2. {
  3. AIT_CONTINUOUS, //React to hold input and release after it
  4. AIT_SINGLE, //React to click input - single use actions
  5. AIT_DOUBLECLICK, //React to double click input - single use actions
  6. AIT_HOLDSINGLE, //React to hold input - single use actions
  7. AIT_CLICKCONTINUOUS, //React to click input for start and click for end
  8. AIT_NOINPUTCONTROL,
  9. AIT_INVENTORYINPUT, //Inventory specific actions
  10. }
  11. class ForcedActionData
  12. {
  13. ActionBase m_Action;
  14. ref ActionTarget m_Target;
  15. ItemBase m_Item;
  16. }
  17. class ActionInput : ActionInput_Basic
  18. {
  19. UAIDWrapper m_input; //Input ID automaticly generated from name.
  20. int m_InputType; //Use from action manager for handling input
  21. int m_Priority;
  22. bool m_DetectFromItem; //Can be used action from item in hands?
  23. bool m_DetectFromTarget; //Can be used action from target in vicinity?
  24. bool m_DetectFromPlayer; //Can be used action from player?
  25. bool m_Enabled;
  26. bool m_JustActivate;
  27. bool m_HasTarget;
  28. PlayerBase m_Player;
  29. ref ActionTarget m_ForcedTarget;
  30. ref ForcedActionData m_ForcedActionData;
  31. ref ActionTarget m_Target;
  32. ItemBase m_MainItem;
  33. int m_ConditionMask;
  34. bool m_Active;
  35. void ActionInput()
  36. {
  37. m_Active = false;
  38. m_Enabled = true;
  39. m_ForcedTarget = null;
  40. m_ForcedActionData = null;
  41. m_HasTarget = false;
  42. m_JustActivate = false;
  43. m_DetectFromTarget = false;
  44. m_DetectFromItem = true;
  45. m_DetectFromPlayer = true;
  46. m_Priority = 100;
  47. }
  48. void Init(PlayerBase player, ActionManagerClient am)
  49. {
  50. m_Player = player;
  51. if ( LogManager.IsActionLogEnable())
  52. {
  53. Debug.ActionLog("n/a",this.ToString(), "n/a","Init()", player.ToString());
  54. }
  55. }
  56. void SetEnablity(bool value)
  57. {
  58. m_Enabled = value;
  59. }
  60. protected void SetInput(string input_name)
  61. {
  62. m_input = GetUApi().GetInputByName(input_name).GetPersistentWrapper();
  63. if ( LogManager.IsActionLogEnable())
  64. {
  65. if (m_input && m_input.InputP())
  66. Debug.ActionLog("(+) input set to " + input_name ,this.ToString(), "n/a","SetInput()", "n/a");
  67. else
  68. Debug.ActionLog("(-) input is not set to " + input_name ,this.ToString(), "n/a","SetInput()","n/a");
  69. }
  70. }
  71. int GetInputType()
  72. {
  73. return m_InputType;
  74. }
  75. UAInput GetUAInput()
  76. {
  77. return m_input.InputP();
  78. }
  79. bool JustActivate()
  80. {
  81. return m_JustActivate;
  82. }
  83. bool IsActive()
  84. {
  85. return m_Active;
  86. }
  87. bool WasEnded()
  88. {
  89. return !m_Active;
  90. }
  91. void Update()
  92. {
  93. if( !m_Enabled )
  94. {
  95. m_Active = false;
  96. m_JustActivate = false;
  97. return;
  98. }
  99. switch ( m_InputType )
  100. {
  101. case ActionInputType.AIT_CONTINUOUS:
  102. m_JustActivate = false;
  103. if(m_Active)
  104. {
  105. m_Active = m_input.InputP().LocalHold();
  106. }
  107. else
  108. {
  109. m_Active = m_input.InputP().LocalHoldBegin();
  110. m_JustActivate = m_Active;
  111. }
  112. break;
  113. case ActionInputType.AIT_SINGLE:
  114. m_Active = m_input.InputP().LocalClick();
  115. m_JustActivate = m_Active;
  116. break;
  117. case ActionInputType.AIT_DOUBLECLICK:
  118. m_Active = m_input.InputP().LocalDoubleClick();
  119. m_JustActivate = m_Active;
  120. break;
  121. break;
  122. case ActionInputType.AIT_HOLDSINGLE:
  123. m_Active = m_input.InputP().LocalHoldBegin();
  124. m_JustActivate = m_Active;
  125. break;
  126. break;
  127. case ActionInputType.AIT_CLICKCONTINUOUS:
  128. m_JustActivate = false;
  129. if(m_Active)
  130. {
  131. if ( m_input.InputP().LocalClick() )
  132. {
  133. m_Active = false;
  134. }
  135. }
  136. else
  137. {
  138. m_Active = m_input.InputP().LocalClick();
  139. m_JustActivate = m_Active;
  140. }
  141. break;
  142. break;
  143. default:
  144. break;
  145. }
  146. }
  147. void Reset()
  148. {
  149. m_Active = false;
  150. ActionsSelectReset();
  151. }
  152. void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  153. {
  154. }
  155. ActionBase GetAction()
  156. {
  157. return NULL;
  158. }
  159. ActionTarget GetUsedActionTarget()
  160. {
  161. return m_Target;
  162. }
  163. ItemBase GetUsedMainItem()
  164. {
  165. return m_MainItem;
  166. }
  167. array<ActionBase> GetPossibleActions()
  168. {
  169. return NULL;
  170. }
  171. ActionBase GetPossibleAction()
  172. {
  173. return NULL;
  174. }
  175. int GetPossibleActionIndex()
  176. {
  177. return -1;
  178. }
  179. bool HasTarget()
  180. {
  181. return false;
  182. }
  183. void OnActionStart()
  184. {
  185. ActionsSelectReset();
  186. }
  187. void OnActionEnd()
  188. {
  189. Reset();
  190. }
  191. void ActionsSelectReset()
  192. {}
  193. void ForceAction(ActionBase action, ActionTarget target, ItemBase item )
  194. {
  195. m_ForcedActionData = new ForcedActionData;
  196. m_ForcedActionData.m_Action = action;
  197. m_ForcedActionData.m_Target = target;
  198. m_ForcedActionData.m_Item = item;
  199. }
  200. void ForceActionTarget( ActionTarget target )
  201. {
  202. m_ForcedTarget = target;
  203. }
  204. void ClearForcedAction()
  205. {
  206. m_ForcedActionData = null;
  207. }
  208. void ClearForcedTarget()
  209. {
  210. m_ForcedTarget = NULL;
  211. }
  212. bool ForceActionCheck(PlayerBase player)
  213. {
  214. if (m_ForcedActionData)
  215. {
  216. if (m_ForcedActionData.m_Action.Can(player, m_ForcedActionData.m_Target, m_ForcedActionData.m_Item))
  217. {
  218. m_MainItem = m_ForcedActionData.m_Item;
  219. m_Target = m_ForcedActionData.m_Target;
  220. return true;
  221. }
  222. }
  223. return false;
  224. }
  225. void SelectNextAction()
  226. {
  227. }
  228. void SelectPrevAction()
  229. {}
  230. int GetPossibleActionsCount()
  231. {
  232. return -1;
  233. }
  234. bool HasInput()
  235. {
  236. return m_input != NULL;
  237. }
  238. int GetPriority()
  239. {
  240. return m_Priority;
  241. }
  242. }
  243. class StandardActionInput : ActionInput
  244. {
  245. ref array<ActionBase> m_SelectActions;
  246. int m_selectedActionIndex;
  247. void StandardActionInput(PlayerBase player)
  248. {
  249. m_selectedActionIndex = 0;
  250. m_SelectActions = new array<ActionBase>;
  251. }
  252. override void ForceAction(ActionBase action, ActionTarget target, ItemBase item )
  253. {
  254. super.ForceAction(action, target, item);
  255. m_selectedActionIndex = 0;
  256. }
  257. void _GetSelectedActions( Object action_source_object, out array<ActionBase> select_actions_all, out bool has_any_action_target)
  258. {
  259. if ( !action_source_object )
  260. return;
  261. array<ActionBase_Basic> possible_actions;
  262. array<ref ActionBase> variant_actions;
  263. action_source_object.GetActions(this.Type(), possible_actions);
  264. ActionBase action;
  265. if(possible_actions)
  266. {
  267. for (int i = 0; i < possible_actions.Count(); i++)
  268. {
  269. action = ActionBase.Cast(possible_actions.Get(i));
  270. if ( action.HasVariants() )
  271. {
  272. action.UpdateVariants( m_MainItem, m_Target.GetObject(), m_Target.GetComponentIndex() );
  273. action.GetVariants( variant_actions);
  274. for (int j = 0; j < variant_actions.Count(); j++)
  275. {
  276. action = variant_actions[j];
  277. if ( action.Can(m_Player, m_Target, m_MainItem, m_ConditionMask) )
  278. {
  279. select_actions_all.Insert(action);
  280. if (action.HasTarget())
  281. has_any_action_target = true;
  282. }
  283. }
  284. }
  285. else
  286. {
  287. if ( action.Can(m_Player, m_Target, m_MainItem, m_ConditionMask) )
  288. {
  289. select_actions_all.Insert(action);
  290. if (action.HasTarget())
  291. has_any_action_target = true;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  298. {
  299. if ( ForceActionCheck(player))
  300. {
  301. m_SelectActions.Clear();
  302. m_SelectActions.Insert(m_ForcedActionData.m_Action);
  303. return;
  304. }
  305. if(m_ForcedTarget)
  306. {
  307. target = m_ForcedTarget;
  308. }
  309. array<ActionBase> select_actions_all = new array<ActionBase>;
  310. int i, last_index;
  311. bool change = false;
  312. m_HasTarget = false;
  313. m_MainItem = item;
  314. m_Target = target;
  315. m_ConditionMask = action_condition_mask;
  316. if( m_DetectFromItem )
  317. {
  318. _GetSelectedActions( item, select_actions_all, m_HasTarget);
  319. }
  320. if( m_DetectFromTarget )
  321. {
  322. _GetSelectedActions( target.GetObject(), select_actions_all, m_HasTarget);
  323. _GetSelectedActions( target.GetParent(), select_actions_all, m_HasTarget);
  324. }
  325. if( m_DetectFromPlayer )
  326. {
  327. _GetSelectedActions( player, select_actions_all, m_HasTarget);
  328. }
  329. if ( select_actions_all.Count() )
  330. {
  331. last_index = 0;
  332. for ( i = 0; i < select_actions_all.Count(); i++ )
  333. {
  334. ActionBase action = select_actions_all[i];
  335. if ( m_HasTarget )
  336. {
  337. if ( action.HasTarget() )
  338. {
  339. if ( m_SelectActions.Count() > last_index )
  340. {
  341. if ( m_SelectActions[last_index] != action )
  342. {
  343. change = true;
  344. m_SelectActions[last_index] = action;
  345. }
  346. }
  347. else
  348. {
  349. change = true;
  350. m_SelectActions.Insert(action);
  351. }
  352. action.OnActionInfoUpdate(player, target, item);
  353. last_index++;
  354. }
  355. }
  356. else
  357. {
  358. if ( m_SelectActions.Count() > last_index )
  359. {
  360. if ( m_SelectActions[last_index] != action )
  361. {
  362. change = true;
  363. m_SelectActions[last_index++] = action;
  364. }
  365. }
  366. else
  367. {
  368. change = true;
  369. m_SelectActions.Insert(action);
  370. }
  371. action.OnActionInfoUpdate(player, target, item);
  372. last_index++;
  373. }
  374. }
  375. }
  376. else
  377. {
  378. m_selectedActionIndex = 0;
  379. m_SelectActions.Clear();
  380. }
  381. if (m_SelectActions.Count() > last_index)
  382. {
  383. change = true;
  384. for (i = last_index; i < m_SelectActions.Count(); i++)
  385. {
  386. m_SelectActions.Remove(last_index);
  387. }
  388. }
  389. if ( change )
  390. {
  391. m_selectedActionIndex = 0;
  392. m_Player.GetActionManager().SelectFirstActionCategory();
  393. }
  394. }
  395. override array<ActionBase> GetPossibleActions()
  396. {
  397. return m_SelectActions;
  398. }
  399. override int GetPossibleActionsCount()
  400. {
  401. return m_SelectActions.Count();
  402. }
  403. override bool HasTarget()
  404. {
  405. return m_HasTarget;
  406. }
  407. override int GetPossibleActionIndex()
  408. {
  409. return m_selectedActionIndex;
  410. }
  411. override ActionBase GetAction()
  412. {
  413. if (m_SelectActions.Count() > 0)
  414. return m_SelectActions[m_selectedActionIndex];
  415. return null;
  416. }
  417. override void ActionsSelectReset()
  418. {
  419. m_SelectActions.Clear();
  420. m_selectedActionIndex = 0;
  421. }
  422. override void SelectNextAction()
  423. {
  424. if(m_SelectActions.Count())
  425. {
  426. m_selectedActionIndex++;
  427. if(m_SelectActions.Count() <= m_selectedActionIndex )
  428. {
  429. m_selectedActionIndex = 0;
  430. }
  431. }
  432. }
  433. override void SelectPrevAction()
  434. {
  435. if(m_SelectActions.Count())
  436. {
  437. m_selectedActionIndex--;
  438. if(0 > m_selectedActionIndex )
  439. {
  440. m_selectedActionIndex = m_SelectActions.Count() - 1;
  441. }
  442. }
  443. }
  444. }
  445. class ContinuousInteractActionInput : StandardActionInput
  446. {
  447. void ContinuousInteractActionInput(PlayerBase player)
  448. {
  449. SetInput("UAAction");
  450. m_Priority = 60;
  451. m_InputType = ActionInputType.AIT_CONTINUOUS;
  452. m_DetectFromTarget = true;
  453. m_DetectFromItem = false;
  454. m_DetectFromPlayer = true;
  455. }
  456. };
  457. class InteractActionInput : ContinuousInteractActionInput
  458. {
  459. void InteractActionInput(PlayerBase player)
  460. {
  461. m_InputType = ActionInputType.AIT_SINGLE;
  462. m_Priority = 80;
  463. }
  464. override void OnActionStart()
  465. {
  466. super.OnActionStart();
  467. m_Active = false;
  468. }
  469. override bool WasEnded()
  470. {
  471. return false;
  472. }
  473. };
  474. class NoIndicationActionInputBase : ActionInput
  475. {
  476. void NoIndicationActionInputBase(PlayerBase player)
  477. {
  478. m_DetectFromTarget = false;
  479. }
  480. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  481. {
  482. m_MainItem = item;
  483. m_Target = target;
  484. m_ConditionMask = action_condition_mask;
  485. }
  486. override ActionBase GetAction()
  487. {
  488. if ( ForceActionCheck(m_Player) )
  489. return m_ForcedActionData.m_Action;
  490. if(m_MainItem)
  491. {
  492. array<ActionBase_Basic> possible_actions;
  493. ActionBase action;
  494. m_MainItem.GetActions(this.Type(), possible_actions);
  495. if(possible_actions)
  496. {
  497. for (int i = 0; i < possible_actions.Count(); i++)
  498. {
  499. action = ActionBase.Cast(possible_actions.Get(i));
  500. if ( action.Can(m_Player, m_Target, m_MainItem, m_ConditionMask) )
  501. {
  502. return action;
  503. }
  504. }
  505. }
  506. }
  507. return NULL;
  508. }
  509. override ActionBase GetPossibleAction()
  510. {
  511. return GetAction();
  512. }
  513. }
  514. class ContinuousDefaultActionInput : StandardActionInput
  515. {
  516. protected ActionBase m_SelectAction; //Do nothing only for back compatibilit, relevant only for inherited class
  517. void ContinuousDefaultActionInput(PlayerBase player)
  518. {
  519. SetInput("UADefaultAction");
  520. m_InputType = ActionInputType.AIT_CONTINUOUS;
  521. m_Priority = 20;
  522. m_DetectFromTarget = false;
  523. m_DetectFromItem = true;
  524. m_DetectFromPlayer = true;
  525. m_SelectAction = null;
  526. }
  527. override ActionBase GetPossibleAction()
  528. {
  529. return m_SelectAction;
  530. }
  531. override void ActionsSelectReset()
  532. {
  533. super.ActionsSelectReset();
  534. m_SelectAction = NULL;
  535. }
  536. };
  537. class DefaultActionInput : ContinuousDefaultActionInput
  538. {
  539. void DefaultActionInput(PlayerBase player)
  540. {
  541. m_InputType = ActionInputType.AIT_SINGLE;
  542. m_Priority = 40;
  543. }
  544. override void OnActionStart()
  545. {
  546. super.OnActionStart();
  547. m_Active = false;
  548. }
  549. override bool WasEnded()
  550. {
  551. return false;
  552. }
  553. };
  554. class DropActionInput : NoIndicationActionInputBase
  555. {
  556. void DropActionInput(PlayerBase player)
  557. {
  558. SetInput("UADropitem");
  559. m_InputType = ActionInputType.AIT_HOLDSINGLE;
  560. }
  561. };
  562. class CarHornShortActionInput : ContinuousDefaultActionInput
  563. {
  564. ref ActionTarget targetNew;
  565. void CarHornShortActionInput(PlayerBase player)
  566. {
  567. SetInput("UACarHorn");
  568. m_InputType = ActionInputType.AIT_SINGLE;
  569. m_Priority = 100;
  570. m_DetectFromItem = false;
  571. m_DetectFromTarget = false;
  572. m_DetectFromPlayer = false;
  573. }
  574. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  575. {
  576. if (ForceActionCheck(player))
  577. {
  578. m_SelectAction = m_ForcedActionData.m_Action;
  579. return;
  580. }
  581. m_SelectAction = null;
  582. array<ActionBase_Basic> possibleActions;
  583. ActionBase action;
  584. int i;
  585. m_MainItem = null;
  586. if (player && player.IsInVehicle())
  587. {
  588. HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
  589. if (vehCommand)
  590. {
  591. Transport trans = vehCommand.GetTransport();
  592. if (trans)
  593. {
  594. targetNew = new ActionTarget(trans, null, -1, vector.Zero, -1);
  595. ForceActionTarget(targetNew);
  596. }
  597. }
  598. if (!targetNew)
  599. {
  600. ClearForcedTarget();
  601. }
  602. }
  603. target = m_ForcedTarget;
  604. m_Target = m_ForcedTarget;
  605. if (target && target.GetObject())
  606. {
  607. target.GetObject().GetActions(this.Type(), possibleActions);
  608. if (possibleActions)
  609. {
  610. for (i = 0; i < possibleActions.Count(); i++)
  611. {
  612. action = ActionBase.Cast(possibleActions.Get(i));
  613. if (action.Can(player, target, m_MainItem, action_condition_mask))
  614. {
  615. m_SelectAction = action;
  616. return;
  617. }
  618. }
  619. }
  620. }
  621. }
  622. override ActionBase GetAction()
  623. {
  624. return m_SelectAction;
  625. }
  626. }
  627. class CarHornLongActionInput : CarHornShortActionInput
  628. {
  629. void CarHornLongActionInput(PlayerBase player)
  630. {
  631. SetInput("UACarHorn");
  632. m_InputType = ActionInputType.AIT_CONTINUOUS;
  633. m_Priority = 101;
  634. m_DetectFromItem = false;
  635. m_DetectFromTarget = false;
  636. m_DetectFromPlayer = false;
  637. }
  638. }
  639. class ToggleLightsActionInput : DefaultActionInput
  640. {
  641. ref ActionTarget target_new;
  642. void ToggleLightsActionInput(PlayerBase player)
  643. {
  644. SetInput("UAToggleHeadlight");
  645. m_InputType = ActionInputType.AIT_SINGLE;
  646. m_Priority = 100;
  647. }
  648. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  649. {
  650. if( ForceActionCheck(player) )
  651. {
  652. m_SelectAction = m_ForcedActionData.m_Action;
  653. return;
  654. }
  655. //ForceActionTarget(player.m_PlayerLightManager.
  656. m_SelectAction = NULL;
  657. array<ActionBase_Basic> possible_actions;
  658. ActionBase action;
  659. int i;
  660. m_MainItem = NULL;
  661. if ( player && !player.IsInVehicle() )
  662. {
  663. Clothing headgear = Clothing.Cast(player.FindAttachmentBySlotName("Headgear"));
  664. Clothing eyewear = Clothing.Cast(player.FindAttachmentBySlotName("Eyewear"));
  665. //TODO - extend this to allow for a switchable control over all possible light sources (depth 0 or 1 only?)
  666. if ( headgear && headgear.GetLightSourceItem() )
  667. {
  668. target_new = new ActionTarget(headgear, null, -1, vector.Zero, -1);
  669. ForceActionTarget(target_new);
  670. }
  671. else if ( eyewear && eyewear.GetLightSourceItem() )
  672. {
  673. target_new = new ActionTarget(eyewear, null, -1, vector.Zero, -1);
  674. ForceActionTarget(target_new);
  675. }
  676. else
  677. ClearForcedTarget();
  678. }
  679. else if ( player && player.IsInVehicle() )
  680. {
  681. HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
  682. if( vehCommand )
  683. {
  684. Transport trans = vehCommand.GetTransport();
  685. if( trans )
  686. {
  687. target_new = new ActionTarget(trans, null, -1, vector.Zero, -1);
  688. ForceActionTarget(target_new);
  689. }
  690. }
  691. if ( !target_new )
  692. ClearForcedTarget();
  693. }
  694. target = m_ForcedTarget;
  695. m_Target = m_ForcedTarget;
  696. if(target && target.GetObject())
  697. {
  698. target.GetObject().GetActions(this.Type(), possible_actions);
  699. if(possible_actions)
  700. {
  701. for (i = 0; i < possible_actions.Count(); i++)
  702. {
  703. action = ActionBase.Cast(possible_actions.Get(i));
  704. if ( action.Can(player, target, m_MainItem, action_condition_mask) )
  705. {
  706. m_SelectAction = action;
  707. return;
  708. }
  709. }
  710. }
  711. }
  712. }
  713. override ActionBase GetAction()
  714. {
  715. return m_SelectAction;
  716. }
  717. };
  718. class ToggleNVGActionInput : DefaultActionInput
  719. {
  720. ref ActionTarget target_new;
  721. void ToggleNVGActionInput(PlayerBase player)
  722. {
  723. SetInput("UAToggleNVG");
  724. m_InputType = ActionInputType.AIT_HOLDSINGLE;
  725. m_Priority = 100;
  726. }
  727. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  728. {
  729. if( ForceActionCheck(player) )
  730. {
  731. m_SelectAction = m_ForcedActionData.m_Action;
  732. return;
  733. }
  734. //ForceActionTarget(player.m_PlayerLightManager.
  735. m_SelectAction = NULL;
  736. array<ActionBase_Basic> possible_actions;
  737. ActionBase action;
  738. int i;
  739. m_MainItem = NULL;
  740. if ( player )
  741. {
  742. Mich2001Helmet helmet = Mich2001Helmet.Cast(player.FindAttachmentBySlotName("Headgear"));
  743. NVGHeadstrap headstrap = NVGHeadstrap.Cast(player.FindAttachmentBySlotName("Eyewear"));
  744. if ( helmet )
  745. {
  746. //m_MainItem = Headtorch_ColorBase.Cast(player.FindAttachmentBySlotName("Headgear"));
  747. target_new = new ActionTarget(helmet, null, -1, vector.Zero, -1);
  748. ForceActionTarget(target_new);
  749. }
  750. else if ( headstrap )
  751. {
  752. target_new = new ActionTarget(headstrap, null, -1, vector.Zero, -1);
  753. ForceActionTarget(target_new);
  754. }
  755. else
  756. ClearForcedTarget();
  757. }
  758. target = m_ForcedTarget;
  759. m_Target = m_ForcedTarget;
  760. if(target && target.GetObject())
  761. {
  762. target.GetObject().GetActions(this.Type(), possible_actions);
  763. if(possible_actions)
  764. {
  765. for (i = 0; i < possible_actions.Count(); i++)
  766. {
  767. action = ActionBase.Cast(possible_actions.Get(i));
  768. if ( action.Can(player, target, m_MainItem, action_condition_mask) )
  769. {
  770. m_SelectAction = action;
  771. return;
  772. }
  773. }
  774. }
  775. }
  776. }
  777. override ActionBase GetAction()
  778. {
  779. return m_SelectAction;
  780. }
  781. };
  782. class ContinuousWeaponManipulationActionInput : NoIndicationActionInputBase
  783. {
  784. void ContinuousWeaponManipulationActionInput(PlayerBase player)
  785. {
  786. SetInput("UAReloadMagazine");
  787. m_InputType = ActionInputType.AIT_CONTINUOUS;
  788. }
  789. };
  790. class WeaponManipulationActionInput : NoIndicationActionInputBase
  791. {
  792. void WeaponManipulationActionInput(PlayerBase player)
  793. {
  794. SetInput("UAReloadMagazine");
  795. m_InputType = ActionInputType.AIT_SINGLE;
  796. }
  797. };
  798. class ExternalControlledActionInput : NoIndicationActionInputBase
  799. {
  800. void ExternalControlledActionInput(PlayerBase player)
  801. {
  802. //SetInput("UAReloadMagazine");
  803. m_InputType = ActionInputType.AIT_NOINPUTCONTROL;
  804. }
  805. };
  806. class InventoryOnlyActionInput : NoIndicationActionInputBase
  807. {
  808. void InventoryOnlyActionInput(PlayerBase player)
  809. {
  810. //SetInput("UAReloadMagazine");
  811. m_InputType = ActionInputType.AIT_INVENTORYINPUT;
  812. }
  813. };
  814. class QuickaBarActionInput : ExternalControlledActionInput
  815. {
  816. };