3 static const string PORT_DISTANCE =
"Distance";
4 static const string PORT_RESULT_VECTOR =
"ResultVector";
5 static const string PORT_TARGET =
"Target";
7 [
Attribute(
"10", UIWidgets.EditBox, PORT_DISTANCE)]
10 protected vector m_ResultVector;
11 protected IEntity m_Target;
12 protected vector m_vPosition;
15 override void OnInit(AIAgent owner)
17 if (GetVariableType(
false, PORT_RESULT_VECTOR) != vector)
19 NodeError(
this, owner, PORT_RESULT_VECTOR +
" should be vector");
22 if (GetVariableIn(PORT_DISTANCE, m_Distance) && (GetVariableType(
true, PORT_DISTANCE) !=
int && GetVariableType(
true, PORT_DISTANCE) !=
float) )
24 NodeError(
this, owner, PORT_DISTANCE +
" type should be number");
27 if (GetVariableType(
true, PORT_TARGET) != vector && GetVariableType(
true, PORT_TARGET) != IEntity)
29 NodeError(
this, owner, PORT_TARGET +
" should be IEntity or vector");
34 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
36 IEntity controlledEntity = owner.GetControlledEntity();
37 if (GetVariableType(
true, PORT_TARGET) == vector)
41 else if (GetVariableType(
true, PORT_TARGET) == IEntity)
45 return ENodeResult.FAIL;
48 return NodeError(
this, owner, PORT_TARGET +
" can't be the same as owner entity");
51 if (GetVariableType(
true, PORT_DISTANCE) ==
int)
54 GetVariableIn(PORT_DISTANCE,
distance);
57 else if (GetVariableType(
true, PORT_DISTANCE) ==
float)
59 GetVariableIn(PORT_DISTANCE, m_Distance);
63 vector ownerPos = controlledEntity.GetOrigin();
69 vector
direction = vector.Direction(ownerPos, pos).Normalized();
70 vector forwardVector = ownerPos + (
direction * m_Distance );
72 forwardVector[1] = controlledEntity.GetWorld().GetSurfaceY(forwardVector[0], forwardVector[2]);
74 m_ResultVector = forwardVector;
76 SetVariableOut(PORT_RESULT_VECTOR, m_ResultVector);
80 return ENodeResult.SUCCESS;
84 protected override string GetOnHoverDescription()
86 return "It will return world position in direction to target away from owner position. Doesn't take navmesh in account. Target can be entity or vector.";
92 int color = ARGB(255, 255, 64, 64);
94 Shape dbgShape = Shape.CreateSphere(color, ShapeFlags.TRANSP | ShapeFlags.DOUBLESIDE | ShapeFlags.NOZWRITE | ShapeFlags.ONCE | ShapeFlags.NOOUTLINE, vector.Zero, 1.0);
97 Math3D.MatrixIdentity4(mat);
98 mat[3] = m_ResultVector;
99 dbgShape.SetMatrix(mat);
103 override bool VisibleInPalette()
109 protected static ref TStringArray s_aVarsIn = {
113 override TStringArray GetVariablesIn()
119 protected static ref TStringArray s_aVarsOut = {
122 override TStringArray GetVariablesOut()