actioninput.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  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. change = true;
  379. m_selectedActionIndex = 0;
  380. m_SelectActions.Clear();
  381. }
  382. if (m_SelectActions.Count() > last_index)
  383. {
  384. change = true;
  385. for (i = last_index; i < m_SelectActions.Count(); i++)
  386. {
  387. m_SelectActions.Remove(last_index);
  388. }
  389. }
  390. if ( change )
  391. {
  392. m_selectedActionIndex = 0;
  393. m_Player.GetActionManager().SelectFirstActionCategory();
  394. }
  395. }
  396. override array<ActionBase> GetPossibleActions()
  397. {
  398. return m_SelectActions;
  399. }
  400. override int GetPossibleActionsCount()
  401. {
  402. return m_SelectActions.Count();
  403. }
  404. override bool HasTarget()
  405. {
  406. return m_HasTarget;
  407. }
  408. override int GetPossibleActionIndex()
  409. {
  410. return m_selectedActionIndex;
  411. }
  412. override ActionBase GetAction()
  413. {
  414. if (m_SelectActions.Count() > 0)
  415. return m_SelectActions[m_selectedActionIndex];
  416. return null;
  417. }
  418. override void ActionsSelectReset()
  419. {
  420. m_SelectActions.Clear();
  421. m_selectedActionIndex = 0;
  422. }
  423. override void SelectNextAction()
  424. {
  425. if(m_SelectActions.Count())
  426. {
  427. m_selectedActionIndex++;
  428. if(m_SelectActions.Count() <= m_selectedActionIndex )
  429. {
  430. m_selectedActionIndex = 0;
  431. }
  432. }
  433. }
  434. override void SelectPrevAction()
  435. {
  436. if(m_SelectActions.Count())
  437. {
  438. m_selectedActionIndex--;
  439. if(0 > m_selectedActionIndex )
  440. {
  441. m_selectedActionIndex = m_SelectActions.Count() - 1;
  442. }
  443. }
  444. }
  445. }
  446. class ContinuousInteractActionInput : StandardActionInput
  447. {
  448. void ContinuousInteractActionInput(PlayerBase player)
  449. {
  450. SetInput("UAAction");
  451. m_Priority = 60;
  452. m_InputType = ActionInputType.AIT_CONTINUOUS;
  453. m_DetectFromTarget = true;
  454. m_DetectFromItem = false;
  455. m_DetectFromPlayer = true;
  456. }
  457. };
  458. class InteractActionInput : ContinuousInteractActionInput
  459. {
  460. void InteractActionInput(PlayerBase player)
  461. {
  462. m_InputType = ActionInputType.AIT_SINGLE;
  463. m_Priority = 80;
  464. }
  465. override void OnActionStart()
  466. {
  467. super.OnActionStart();
  468. m_Active = false;
  469. }
  470. override bool WasEnded()
  471. {
  472. return false;
  473. }
  474. };
  475. class NoIndicationActionInputBase : ActionInput
  476. {
  477. void NoIndicationActionInputBase(PlayerBase player)
  478. {
  479. m_DetectFromTarget = false;
  480. }
  481. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  482. {
  483. m_MainItem = item;
  484. m_Target = target;
  485. m_ConditionMask = action_condition_mask;
  486. }
  487. override ActionBase GetAction()
  488. {
  489. if ( ForceActionCheck(m_Player) )
  490. return m_ForcedActionData.m_Action;
  491. if(m_MainItem)
  492. {
  493. array<ActionBase_Basic> possible_actions;
  494. ActionBase action;
  495. m_MainItem.GetActions(this.Type(), possible_actions);
  496. if(possible_actions)
  497. {
  498. for (int i = 0; i < possible_actions.Count(); i++)
  499. {
  500. action = ActionBase.Cast(possible_actions.Get(i));
  501. if ( action.Can(m_Player, m_Target, m_MainItem, m_ConditionMask) )
  502. {
  503. return action;
  504. }
  505. }
  506. }
  507. }
  508. return NULL;
  509. }
  510. override ActionBase GetPossibleAction()
  511. {
  512. return GetAction();
  513. }
  514. }
  515. class ContinuousDefaultActionInput : StandardActionInput
  516. {
  517. protected ActionBase m_SelectAction; //Do nothing only for back compatibilit, relevant only for inherited class
  518. void ContinuousDefaultActionInput(PlayerBase player)
  519. {
  520. SetInput("UADefaultAction");
  521. m_InputType = ActionInputType.AIT_CONTINUOUS;
  522. m_Priority = 20;
  523. m_DetectFromTarget = false;
  524. m_DetectFromItem = true;
  525. m_DetectFromPlayer = true;
  526. m_SelectAction = null;
  527. }
  528. override ActionBase GetPossibleAction()
  529. {
  530. return m_SelectAction;
  531. }
  532. override void ActionsSelectReset()
  533. {
  534. super.ActionsSelectReset();
  535. m_SelectAction = NULL;
  536. }
  537. };
  538. class DefaultActionInput : ContinuousDefaultActionInput
  539. {
  540. void DefaultActionInput(PlayerBase player)
  541. {
  542. m_InputType = ActionInputType.AIT_SINGLE;
  543. m_Priority = 40;
  544. }
  545. override void OnActionStart()
  546. {
  547. super.OnActionStart();
  548. m_Active = false;
  549. }
  550. override bool WasEnded()
  551. {
  552. return false;
  553. }
  554. };
  555. class DropActionInput : NoIndicationActionInputBase
  556. {
  557. void DropActionInput(PlayerBase player)
  558. {
  559. SetInput("UADropitem");
  560. m_InputType = ActionInputType.AIT_HOLDSINGLE;
  561. }
  562. };
  563. class CarHornShortActionInput : ContinuousDefaultActionInput
  564. {
  565. ref ActionTarget targetNew;
  566. void CarHornShortActionInput(PlayerBase player)
  567. {
  568. SetInput("UACarHorn");
  569. m_InputType = ActionInputType.AIT_SINGLE;
  570. m_Priority = 100;
  571. m_DetectFromItem = false;
  572. m_DetectFromTarget = false;
  573. m_DetectFromPlayer = false;
  574. }
  575. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  576. {
  577. if (ForceActionCheck(player))
  578. {
  579. m_SelectAction = m_ForcedActionData.m_Action;
  580. return;
  581. }
  582. m_SelectAction = null;
  583. array<ActionBase_Basic> possibleActions;
  584. ActionBase action;
  585. int i;
  586. m_MainItem = null;
  587. if (player && player.IsInVehicle())
  588. {
  589. HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
  590. if (vehCommand)
  591. {
  592. Transport trans = vehCommand.GetTransport();
  593. if (trans)
  594. {
  595. targetNew = new ActionTarget(trans, null, -1, vector.Zero, -1);
  596. ForceActionTarget(targetNew);
  597. }
  598. }
  599. if (!targetNew)
  600. {
  601. ClearForcedTarget();
  602. }
  603. }
  604. target = m_ForcedTarget;
  605. m_Target = m_ForcedTarget;
  606. if (target && target.GetObject())
  607. {
  608. target.GetObject().GetActions(this.Type(), possibleActions);
  609. if (possibleActions)
  610. {
  611. for (i = 0; i < possibleActions.Count(); i++)
  612. {
  613. action = ActionBase.Cast(possibleActions.Get(i));
  614. if (action.Can(player, target, m_MainItem, action_condition_mask))
  615. {
  616. m_SelectAction = action;
  617. return;
  618. }
  619. }
  620. }
  621. }
  622. }
  623. override ActionBase GetAction()
  624. {
  625. return m_SelectAction;
  626. }
  627. }
  628. class CarHornLongActionInput : CarHornShortActionInput
  629. {
  630. void CarHornLongActionInput(PlayerBase player)
  631. {
  632. SetInput("UACarHorn");
  633. m_InputType = ActionInputType.AIT_CONTINUOUS;
  634. m_Priority = 101;
  635. m_DetectFromItem = false;
  636. m_DetectFromTarget = false;
  637. m_DetectFromPlayer = false;
  638. }
  639. }
  640. class ToggleLightsActionInput : DefaultActionInput
  641. {
  642. ref ActionTarget target_new;
  643. void ToggleLightsActionInput(PlayerBase player)
  644. {
  645. SetInput("UAToggleHeadlight");
  646. m_InputType = ActionInputType.AIT_SINGLE;
  647. m_Priority = 100;
  648. }
  649. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  650. {
  651. if( ForceActionCheck(player) )
  652. {
  653. m_SelectAction = m_ForcedActionData.m_Action;
  654. return;
  655. }
  656. //ForceActionTarget(player.m_PlayerLightManager.
  657. m_SelectAction = NULL;
  658. array<ActionBase_Basic> possible_actions;
  659. ActionBase action;
  660. int i;
  661. m_MainItem = NULL;
  662. if ( player && !player.IsInVehicle() )
  663. {
  664. Clothing headgear = Clothing.Cast(player.FindAttachmentBySlotName("Headgear"));
  665. Clothing eyewear = Clothing.Cast(player.FindAttachmentBySlotName("Eyewear"));
  666. //TODO - extend this to allow for a switchable control over all possible light sources (depth 0 or 1 only?)
  667. if ( headgear && headgear.GetLightSourceItem() )
  668. {
  669. target_new = new ActionTarget(headgear, null, -1, vector.Zero, -1);
  670. ForceActionTarget(target_new);
  671. }
  672. else if ( eyewear && eyewear.GetLightSourceItem() )
  673. {
  674. target_new = new ActionTarget(eyewear, null, -1, vector.Zero, -1);
  675. ForceActionTarget(target_new);
  676. }
  677. else
  678. ClearForcedTarget();
  679. }
  680. else if ( player && player.IsInVehicle() )
  681. {
  682. HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
  683. if( vehCommand )
  684. {
  685. Transport trans = vehCommand.GetTransport();
  686. if( trans )
  687. {
  688. target_new = new ActionTarget(trans, null, -1, vector.Zero, -1);
  689. ForceActionTarget(target_new);
  690. }
  691. }
  692. if ( !target_new )
  693. ClearForcedTarget();
  694. }
  695. target = m_ForcedTarget;
  696. m_Target = m_ForcedTarget;
  697. if(target && target.GetObject())
  698. {
  699. target.GetObject().GetActions(this.Type(), possible_actions);
  700. if(possible_actions)
  701. {
  702. for (i = 0; i < possible_actions.Count(); i++)
  703. {
  704. action = ActionBase.Cast(possible_actions.Get(i));
  705. if ( action.Can(player, target, m_MainItem, action_condition_mask) )
  706. {
  707. m_SelectAction = action;
  708. return;
  709. }
  710. }
  711. }
  712. }
  713. }
  714. override ActionBase GetAction()
  715. {
  716. return m_SelectAction;
  717. }
  718. };
  719. class ToggleNVGActionInput : DefaultActionInput
  720. {
  721. ref ActionTarget target_new;
  722. void ToggleNVGActionInput(PlayerBase player)
  723. {
  724. SetInput("UAToggleNVG");
  725. m_InputType = ActionInputType.AIT_HOLDSINGLE;
  726. m_Priority = 100;
  727. }
  728. override void UpdatePossibleActions(PlayerBase player, ActionTarget target, ItemBase item, int action_condition_mask)
  729. {
  730. if( ForceActionCheck(player) )
  731. {
  732. m_SelectAction = m_ForcedActionData.m_Action;
  733. return;
  734. }
  735. //ForceActionTarget(player.m_PlayerLightManager.
  736. m_SelectAction = NULL;
  737. array<ActionBase_Basic> possible_actions;
  738. ActionBase action;
  739. int i;
  740. m_MainItem = NULL;
  741. if ( player )
  742. {
  743. Mich2001Helmet helmet = Mich2001Helmet.Cast(player.FindAttachmentBySlotName("Headgear"));
  744. NVGHeadstrap headstrap = NVGHeadstrap.Cast(player.FindAttachmentBySlotName("Eyewear"));
  745. if ( helmet )
  746. {
  747. //m_MainItem = Headtorch_ColorBase.Cast(player.FindAttachmentBySlotName("Headgear"));
  748. target_new = new ActionTarget(helmet, null, -1, vector.Zero, -1);
  749. ForceActionTarget(target_new);
  750. }
  751. else if ( headstrap )
  752. {
  753. target_new = new ActionTarget(headstrap, null, -1, vector.Zero, -1);
  754. ForceActionTarget(target_new);
  755. }
  756. else
  757. ClearForcedTarget();
  758. }
  759. target = m_ForcedTarget;
  760. m_Target = m_ForcedTarget;
  761. if(target && target.GetObject())
  762. {
  763. target.GetObject().GetActions(this.Type(), possible_actions);
  764. if(possible_actions)
  765. {
  766. for (i = 0; i < possible_actions.Count(); i++)
  767. {
  768. action = ActionBase.Cast(possible_actions.Get(i));
  769. if ( action.Can(player, target, m_MainItem, action_condition_mask) )
  770. {
  771. m_SelectAction = action;
  772. return;
  773. }
  774. }
  775. }
  776. }
  777. }
  778. override ActionBase GetAction()
  779. {
  780. return m_SelectAction;
  781. }
  782. };
  783. class ContinuousWeaponManipulationActionInput : NoIndicationActionInputBase
  784. {
  785. void ContinuousWeaponManipulationActionInput(PlayerBase player)
  786. {
  787. SetInput("UAReloadMagazine");
  788. m_InputType = ActionInputType.AIT_CONTINUOUS;
  789. }
  790. };
  791. class WeaponManipulationActionInput : NoIndicationActionInputBase
  792. {
  793. void WeaponManipulationActionInput(PlayerBase player)
  794. {
  795. SetInput("UAReloadMagazine");
  796. m_InputType = ActionInputType.AIT_SINGLE;
  797. }
  798. };
  799. class ExternalControlledActionInput : NoIndicationActionInputBase
  800. {
  801. void ExternalControlledActionInput(PlayerBase player)
  802. {
  803. //SetInput("UAReloadMagazine");
  804. m_InputType = ActionInputType.AIT_NOINPUTCONTROL;
  805. }
  806. };
  807. class InventoryOnlyActionInput : NoIndicationActionInputBase
  808. {
  809. void InventoryOnlyActionInput(PlayerBase player)
  810. {
  811. //SetInput("UAReloadMagazine");
  812. m_InputType = ActionInputType.AIT_INVENTORYINPUT;
  813. }
  814. };
  815. class QuickaBarActionInput : ExternalControlledActionInput
  816. {
  817. };