Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionanimatecarselection.c
Go to the documentation of this file.
2 {
3  string m_AnimSource = "";
4 
6  {
7  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
8  m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
9  m_Text = "#manipulate";
10  }
11 
12  override void CreateConditionComponents()
13  {
16  }
17 
18  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
19  {
20  if (!target)
21  {
22  return false;
23  }
24 
25  if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
26  {
27  return false;
28  }
29 
30  Object targetObject = target.GetObject();
31  Entity targetEnt = Entity.Cast(targetObject);
32 
33  array<string> selections = new array<string>();
34  targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
35 
36  CarScript car;
37  if (Class.CastTo(car, targetEnt))
38  {
39  for (int i = 0; i < selections.Count(); i++)
40  {
41  m_AnimSource = car.GetAnimSourceFromSelection(selections[i]);
42  if (m_AnimSource != "")
43  {
44  return true;
45  }
46  }
47  }
48 
49  return false;
50  }
51 
52  override void OnStartServer(ActionData action_data)
53  {
54  Entity targetEnt;
55  if (Class.CastTo(targetEnt, action_data.m_Target.GetObject()))
56  {
57  if (targetEnt.GetAnimationPhase(m_AnimSource) > 0.5)
58  {
59  targetEnt.SetAnimationPhase(m_AnimSource, 0.0);
60  }
61 
62  if (targetEnt.GetAnimationPhase(m_AnimSource) <= 0.5)
63  {
64  targetEnt.SetAnimationPhase(m_AnimSource, 1.0);
65  }
66  }
67 
68  CarScript car;
69  if (Class.CastTo(car, action_data.m_Target.GetObject()))
70  {
71  car.ForceUpdateLightsStart();
72  }
73  }
74 
75  override void OnEndServer( ActionData action_data )
76  {
77  CarScript car;
78  if (Class.CastTo(car, action_data.m_Target.GetObject()))
79  {
80  car.ForceUpdateLightsEnd();
81  }
82  }
83 };
ItemBase
Definition: inventoryitem.c:730
CCINone
Definition: ccinone.c:1
CarScript
Definition: civiliansedan.c:1
CCTNone
Definition: cctnone.c:1
UAMaxDistances
Definition: actionconstants.c:104
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Object
Definition: objecttyped.c:1
IsInReach
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition: actionbase.c:928
array< string >
m_Text
protected string m_Text
Definition: actionbase.c:49
Entity
Definition: camera.c:1
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
ActionAnimateCarSelection
Definition: actionanimatecarselection.c:1
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53