Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AILookAction.c
Go to the documentation of this file.
1class SCR_AILookAction : Managed
2{
3 SCR_AIUtilityComponent m_Utility;
4
5 vector m_vPosition; // {0,0,0} is an invalid position
6 bool m_bCancelLook; // There was a request to cancel character looking
7 bool m_bRestartLook; // Restart might happen if we have a new request while previous one is still not Complete()
8 float m_fDuration; // How long to look at something
9
10 static const float PRIO_COMMANDER = 100;
11 static const float PRIO_ENEMY_TARGET = 80;
12 static const float PRIO_UNKNOWN_TARGET = 50;
13 static const float PRIO_DANGER_EVENT = 20;
14
15 protected float m_fPriority;
16
17 void SCR_AILookAction(SCR_AIUtilityComponent utility, bool prioritize)
18 {
19 m_Utility = utility;
20 }
21
22 void LookAt(vector pos, float priority, float duration = 0.8)
23 {
24 #ifdef AI_DEBUG
25 AddDebugMessage(string.Format("LookAt: pos: %1, priority: %2/%3", pos, priority, m_fPriority));
26 #endif
27
28 if (priority < m_fPriority)
29 return;
30
31 // Restart if a previous look action is in process
32 if (m_vPosition != vector.Zero)
33 m_bRestartLook = true;
34
35 m_vPosition = pos;
36 m_fPriority = priority;
37 m_fDuration = duration;
38 }
39
40 void LookAt(IEntity ent, float priority, float duration = 0.8)
41 {
42 #ifdef AI_DEBUG
43 AddDebugMessage(string.Format("LookAt: ent: %1, priority: %2/%3", ent, priority, m_fPriority));
44 #endif
45
46 if (priority < m_fPriority && ent)
47 return;
48
49 // Restart if a previous look action is in process
50 if (m_vPosition != vector.Zero)
51 m_bRestartLook = true;
52
53 vector min, max;
54 ent.GetBounds(min, max);
55 m_vPosition = ent.GetOrigin() + (min + max) * 0.5;
56 m_fPriority = priority;
57 m_fDuration = duration;
58 }
59
60 void Cancel()
61 {
62 #ifdef AI_DEBUG
63 AddDebugMessage(string.Format("Cancel"));
64 #endif
65
66 Complete();
67 m_bCancelLook = true;
68 }
69
70 void Complete()
71 {
72 #ifdef AI_DEBUG
73 AddDebugMessage(string.Format("Complete"));
74 #endif
75
76 m_vPosition = vector.Zero;
77 m_fPriority = 0;
78 }
79
80 #ifdef AI_DEBUG
81 protected void AddDebugMessage(string str, LogLevel logLevel = LogLevel.NORMAL)
82 {
83 SCR_AIInfoBaseComponent infoComp = m_Utility.m_AIInfo;
84 infoComp.AddDebugMessage(str, msgType: EAIDebugMsgType.LOOK, logLevel);
85 }
86 #endif
87
90 void MoveLookParametersToNode(out bool outCanLook, out vector outLookPos, out float outLookDuration, out bool outCancelLook, out bool outRestartLook)
91 {
92 outCanLook = m_vPosition != vector.Zero;
93
94 outCancelLook = m_bCancelLook;
95 m_bCancelLook = false; // Reset the flag if it was set
96
97 outRestartLook = m_bRestartLook;
98 m_bRestartLook = false; // Reset the flag if it was set
99
100 outLookPos = m_vPosition;
101 outLookDuration = m_fDuration;
102 }
103};
enum SCR_EAIActivityCause m_Utility
EAIDebugMsgType
proto external vector GetOrigin()
proto external void GetBounds(out vector mins, out vector maxs)
void SCR_AILookAction(SCR_AIUtilityComponent utility, bool prioritize)
void MoveLookParametersToNode(out bool outCanLook, out vector outLookPos, out float outLookDuration, out bool outCancelLook, out bool outRestartLook)
void LookAt(vector pos, float priority, float duration=0.8)
void LookAt(IEntity ent, float priority, float duration=0.8)
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14