3 static const string PORT_SPEAKER =
"SpeakerIn";
4 static const string PORT_TARGET =
"TargetIn";
5 static const string PORT_LOCATION =
"LocationIn";
6 static const string PORT_INT =
"EnumIn";
11 [
Attribute(
"0", UIWidgets.ComboBox,
"Determines priority, timeout, and other values. See SCR_EAITalkRequestPreset", enums: ParamEnumArray.FromEnum(SCR_EAITalkRequestPreset))]
12 protected SCR_EAITalkRequestPreset m_ePreset;
14 [
Attribute(
"0", UIWidgets.CheckBox,
"When true, the node will be running until the request is finished, and will fail if the request fails.")]
15 protected bool m_bSynchronous;
17 [
Attribute(
"0", UIWidgets.CheckBox,
"When true, request will be transmitted by speaker even if there is noone to potentially receive (hear) it.")]
18 protected bool m_bTransmitIfNoReceivers;
20 [
Attribute(
"1", UIWidgets.CheckBox,
"When true, request will be transmitted by speaker being a passanger of a vehicle.")]
21 protected bool m_bTransmitIfPassenger;
26 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
33 return ENodeResult.RUNNING;
38 return ENodeResult.SUCCESS;
44 return ENodeResult.FAIL;
51 bool speakerPortConnected = GetVariableIn(PORT_SPEAKER, speaker);
52 if (!speakerPortConnected)
57 else if (speakerPortConnected && !speaker)
61 return ENodeResult.FAIL;
70 GetCallstackStr(callstackStr);
71 Print(
string.Format(
"SCR_AITalk: was not able to find SCR_AICommsHandler for %1. BT: %2", speaker, callstackStr), LogLevel.ERROR);
73 return ENodeResult.FAIL;
77 if (commsHandler.CanBypass())
79 return ENodeResult.SUCCESS;
87 GetVariableIn(PORT_TARGET, rqTarget);
88 GetVariableIn(PORT_LOCATION, rqPos);
89 GetVariableIn(PORT_INT, rqEnum);
94 commsHandler.AddRequest(rq);
105 return ENodeResult.RUNNING;
112 return ENodeResult.SUCCESS;
122 AIAgent speakerAgent = AIAgent.Cast(speaker);
123 AIGroup speakerGroup = AIGroup.Cast(speaker);
129 AIAgent leaderAgent = speakerGroup.GetLeaderAgent();
134 SCR_AIUtilityComponent utility = SCR_AIUtilityComponent.Cast(leaderAgent.FindComponent(SCR_AIUtilityComponent));
138 return utility.m_CommsHandler;
140 else if (speakerAgent)
142 SCR_AIUtilityComponent utility = SCR_AIUtilityComponent.Cast(speakerAgent.FindComponent(SCR_AIUtilityComponent));
145 return utility.m_CommsHandler;
150 AIControlComponent contr = AIControlComponent.Cast(speaker.FindComponent(AIControlComponent));
154 speakerAgent = contr.GetControlAIAgent();
158 SCR_AIUtilityComponent utility = SCR_AIUtilityComponent.Cast(speakerAgent.FindComponent(SCR_AIUtilityComponent));
161 return utility.m_CommsHandler;
166 override void OnAbort(AIAgent owner, Node nodeCausingAbort)
173 protected void Reset()
179 override bool VisibleInPalette()
185 protected static ref TStringArray s_aVarsIn = {
191 override TStringArray GetVariablesIn()
198 override protected bool CanReturnRunning()
204 protected void _print(
string str)
206 Print(
string.Format(
"SCR_AITalk %1: %2",
this, str));