Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_AISendMessageGenerated.c
Go to the documentation of this file.
1 class SCR_AISendMessageGenerated : AITaskScripted
2 {
3  static const string PORT_RECEIVER = "Receiver";
4 
5  [Attribute("", UIWidgets.EditBox)]
6  protected string m_sText;
7 
8  //-----------------------------------------------------------------------------------------------------------------------------------------------
9  protected SCR_AIActivityBase GetRelatedActivity(AIAgent owner)
10  {
11  SCR_AIBaseUtilityComponent utilityComp = SCR_AIBaseUtilityComponent.Cast(owner.FindComponent(SCR_AIBaseUtilityComponent));
12  if (!utilityComp)
13  return null;
14 
15  if (SCR_AIGroup.Cast(owner))
16  return SCR_AIActivityBase.Cast(utilityComp.GetExecutedAction());
17  else
18  {
19  SCR_AIBehaviorBase behavior = SCR_AIBehaviorBase.Cast(utilityComp.GetExecutedAction());
20  if (behavior)
21  return SCR_AIActivityBase.Cast(behavior.GetRelatedGroupActivity());
22  else
23  return null;
24  }
25 
26  return null;
27  }
28 
29  //-----------------------------------------------------------------------------------------------------------------------------------------------
30  protected AIWaypoint GetRelatedWaypoint(AIAgent owner)
31  {
32  AIGroup group = AIGroup.Cast(owner);
33  if (!group)
34  return null;
35  return group.GetCurrentWaypoint();
36  }
37 
38  //-----------------------------------------------------------------------------------------------------------------------------------------------
39  protected bool SendMessage(AIAgent owner, AIAgent receiver, SCR_AIMessageBase msg)
40  {
41  AICommunicationComponent comms = owner.GetCommunicationComponent();
42  if (!comms || !receiver)
43  return false;
44 
45  #ifdef AI_DEBUG
46  InitDebugData(msg.m_sSentFromBt);
47  #endif
48 
49  return comms.RequestBroadcast(msg, receiver);
50  }
51 
52  //-----------------------------------------------------------------------------------------------------------------------------------------------
53  protected bool SendMessage(AIAgent owner, AIAgent receiver, SCR_AIOrderBase msg)
54  {
55  AICommunicationComponent comms = owner.GetCommunicationComponent();
56  if (!comms || !receiver)
57  return false;
58 
59  #ifdef AI_DEBUG
60  InitDebugData(msg.m_sSentFromBt);
61  #endif
62 
63  return comms.RequestBroadcast(msg, receiver);
64  }
65 
66  //-----------------------------------------------------------------------------------------------------------------------------------------------
67  protected void InitDebugData(out string outSentFromBt)
68  {
69  string parentTreeName;
70  GetParentTreeName(parentTreeName);
71  outSentFromBt = string.Format("%1, node: %2 %3", parentTreeName, GetNodeID(), this.Type());
72  }
73 
74  //-----------------------------------------------------------------------------------------------------------------------------------------------
75  protected AIAgent GetReceiverAgent(AIAgent owner)
76  {
77  AIAgent receiver;
78  if (!GetVariableIn(PORT_RECEIVER, receiver))
79  receiver = owner;
80 
81  return receiver;
82  }
83 
84  //-----------------------------------------------------------------------------------------------------------------------------------------------
85  override bool VisibleInPalette() { return false; }
86 }
SCR_AIOrderBase
Definition: SCR_AIOrder.c:14
SCR_AIActivityBase
Definition: SCR_AIActivity.c:1
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_AISendMessageGenerated
Definition: SCR_AISendMessageGenerated.c:1
SCR_AIGroup
Definition: SCR_AIGroup.c:68
SCR_AIBehaviorBase
Definition: SCR_AIBehavior.c:1
SCR_AIMessageBase
Definition: SCR_AIMessage.c:44