3 static const string WAYPOINT_PORT =
"Waypoint";
4 static const string ORIGIN_PORT =
"Origin";
5 static const string RADIUS_PORT =
"Radius";
6 static const string EXCLUSION_RADIUS_PORT =
"ExclusionRadius";
7 static const string PORT_RESULT_VECTOR =
"ResultVector";
9 [
Attribute(
"10", UIWidgets.EditBox,
"Radius around origin")]
10 protected float m_Radius;
12 [
Attribute(
"0", UIWidgets.EditBox,
"Exclusion radius around origin")]
13 protected float m_ExclusionRadius;
16 override void OnEnter(AIAgent owner)
18 if (GetVariableType(
false, PORT_RESULT_VECTOR) != vector)
20 NodeError(
this, owner, PORT_RESULT_VECTOR +
" has to be vector");
23 if (GetVariableIn(RADIUS_PORT, m_Radius) && (GetVariableType(
true, RADIUS_PORT) !=
int && GetVariableType(
true, RADIUS_PORT) !=
float))
25 NodeError(
this, owner, RADIUS_PORT +
" type should be number");
30 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
32 vector origin = vector.Zero;
35 if (GetVariableIn(WAYPOINT_PORT,waypointEnt))
37 AIWaypoint waypoint = AIWaypoint.Cast(waypointEnt);
40 NodeError(
this,owner, WAYPOINT_PORT +
" is null! or wrong type");
41 return ENodeResult.FAIL;
43 m_Radius = waypoint.GetCompletionRadius();
44 origin = waypoint.GetOrigin();
48 if (GetVariableType(
true, RADIUS_PORT) ==
int)
51 GetVariableIn(RADIUS_PORT, radius);
54 else if (GetVariableType(
true, RADIUS_PORT) ==
float)
56 GetVariableIn(RADIUS_PORT, m_Radius);
59 if (GetVariableType(
true, ORIGIN_PORT) == vector)
61 GetVariableIn(ORIGIN_PORT, origin);
65 vector result = s_AIRandomGenerator.GenerateRandomPointInRadius(m_ExclusionRadius, m_Radius, origin,
true);
66 result[1] = origin[1];
67 SetVariableOut(PORT_RESULT_VECTOR, result);
69 return ENodeResult.SUCCESS;
73 override bool VisibleInPalette()
79 override protected string GetOnHoverDescription()
81 return "Returns random position in circle (2D) from given point or within radius of a waypoint. When origin vector isn't present it will assume zero vector instead.";
85 protected static ref TStringArray s_aVarsIn = {
90 override TStringArray GetVariablesIn()
96 protected static ref TStringArray s_aVarsOut = {
99 override TStringArray GetVariablesOut()