Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIPlayAnimation.c
Go to the documentation of this file.
2{
3 static const string PORT_ENTITY_IN = "RootEntityIn";
4 static const string PORT_AGENT_SCRIPT_IN = "AgentScriptIn";
5 static const string PORT_ANIMATION_INDEX_IN = "AnimationIndexIn";
6 static const string PORT_ABORT_SLOW = "AbortSlowIn";
7 static const string PORT_RELATED_INVOKER = "RelatedInvoker";
8
10 protected bool m_bAbortDone;
11 protected bool m_bInPlayed;
12 protected ref ScriptInvokerBase<SCR_AIOnAnimationBehaviorAction> m_OnAnimationBehaviorAction; // related invoker for signaling the starting or stopping of some animation
13 protected int m_iAnimationIndex;
14
15 //------------------------------------------------------------------------------------------------
16 override void OnEnter(AIAgent owner)
17 {
18 m_bAbortDone = false;
19 m_bInPlayed = false;
20 }
21
22 //------------------------------------------------------------------------------------------------
23 override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
24 {
25 vector mat[4];
26 if (!m_bInPlayed)
27 {
28 IEntity rootEntity;
29 if (!GetVariableIn(PORT_ENTITY_IN, rootEntity))
30 return ENodeResult.FAIL;
31
32 SCR_AIAnimationScript agentScript;
33 GetVariableIn(PORT_AGENT_SCRIPT_IN, agentScript);
34 GetVariableIn(PORT_ANIMATION_INDEX_IN, m_iAnimationIndex);
35 if (!rootEntity || !agentScript || !agentScript.IsAnimationIndexValid(m_iAnimationIndex))
36 return ENodeResult.FAIL;
37 agentScript.GetAnimationWorldTransform(rootEntity, m_iAnimationIndex, mat);
39 if (!m_AIAnimation)
40 return ENodeResult.FAIL;
41 GetVariableIn(PORT_RELATED_INVOKER, m_OnAnimationBehaviorAction);
44
45 m_AIAnimation.StartAnimation(owner.GetControlledEntity(), mat);
46 m_bInPlayed = true;
47 }
48
49 return ENodeResult.RUNNING;
50 }
51
52 //------------------------------------------------------------------------------------------------
53 override void OnAbort(AIAgent owner, Node nodeCausingAbort)
54 {
56 {
57 bool abortSlow;
58 GetVariableIn(PORT_ABORT_SLOW, abortSlow);
61 m_AIAnimation.StopAnimation(owner.GetControlledEntity(), !abortSlow);
62 }
63 m_bAbortDone = true;
64 }
65
66 //------------------------------------------------------------------------------------------------
67 protected static override bool VisibleInPalette() { return true; }
68
69 //------------------------------------------------------------------------------------------------
70 protected static ref TStringArray s_aVarsIn = {
71 PORT_ENTITY_IN,
72 PORT_AGENT_SCRIPT_IN,
73 PORT_ANIMATION_INDEX_IN,
74 PORT_ABORT_SLOW,
75 PORT_RELATED_INVOKER,
76 };
77
78 //------------------------------------------------------------------------------------------------
80 {
81 return s_aVarsIn;
82 }
83
84 //------------------------------------------------------------------------------------------------
85 static override bool CanReturnRunning() {return true;}
86
87 //------------------------------------------------------------------------------------------------
88 static override string GetOnHoverDescription()
89 {
90 return "PlayAnimation: plays animation stored in SCR_AIAnimationScript given by index of that animation and root entity (usually the waypoint). OnAbort plays OUT animation.\nThe node does not check when animation ends! Must be aborted from above!";
91 }
92};
Definition Node.c:13
proto bool GetVariableIn(string name, out void val)
void GetAnimationWorldTransform(IEntity rootEntity, int animationIndex, out vector transform[4])
SCR_AIAnimation_Base GetAnimationClass(int animationIndex)
bool IsAnimationIndexValid(int animationIndex)
override TStringArray GetVariablesIn()
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
override void OnEnter(AIAgent owner)
static override string GetOnHoverDescription()
SCR_AIAnimation_Base m_AIAnimation
static override bool VisibleInPalette()
override void OnAbort(AIAgent owner, Node nodeCausingAbort)
static ref TStringArray s_aVarsIn
ref ScriptInvokerBase< SCR_AIOnAnimationBehaviorAction > m_OnAnimationBehaviorAction
static override bool CanReturnRunning()
ENodeResult
Definition ENodeResult.c:13
array< string > TStringArray
Definition Types.c:385