3 protected static const string TARGET_INFO_PORT =
"TargetInfo";
5 protected static const string ENTITY_PORT =
"EntitytIn";
6 protected static const string AGENT_PORT =
"AgentIn";
7 protected static const string TARGET_PORT =
"DestinationIn";
9 protected ref TStringArray s_aVarsIn = {
15 CharacterControllerComponent m_charContr;
18 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
21 override bool VisibleInPalette() {
return true; }
24 override string GetOnHoverDescription() {
return "Sets (teleports) entity to target, that can be vector, smartAction or vehicle compartment"; };
27 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
29 IEntity entityToTeleport;
30 vector positionToTeleport;
32 if(!GetVariableIn(ENTITY_PORT, entityToTeleport))
36 if (!GetVariableIn(AGENT_PORT, agent))
37 return NodeError(
this, owner,
"Did not provided entity to teleport!");
38 entityToTeleport = agent.GetControlledEntity();
41 if (!entityToTeleport)
42 return NodeError(
this, owner,
"Entity is null!");
44 if (GetVariableType(
true,TARGET_PORT) == vector)
46 GetVariableIn(TARGET_PORT, positionToTeleport);
51 vector originOfObject;
53 GetVariableIn(TARGET_PORT, SAComponent);
54 originOfObject = SAComponent.GetOwner().GetOrigin();
55 positionToTeleport = originOfObject + SAComponent.GetActionOffset();
57 else if (GetVariableType(
true,TARGET_PORT).
IsInherited(BaseCompartmentSlot))
59 BaseCompartmentSlot compartmentSlot;
60 CompartmentAccessComponent CAComponent = CompartmentAccessComponent.Cast(entityToTeleport.FindComponent(CompartmentAccessComponent));
63 GetVariableIn(TARGET_PORT, compartmentSlot);
64 vehicle = compartmentSlot.GetOwner();
65 if (!CAComponent || !vehicle)
66 return NodeError(
this, owner,
"Enity to teleport does not have CompartmentAccessComponent or target is not an Entity!");
67 if (!CAComponent.MoveInVehicle(vehicle, compartmentSlot))
70 Print(
"Teleport to vehicle was not successful!", LogLevel.VERBOSE);
74 m_charContr = CharacterControllerComponent.Cast(entityToTeleport.FindComponent(CharacterControllerComponent));
76 return NodeError(
this, owner,
"Enity to teleport does not have CharacterControllerComponent!");
79 if (m_charContr.IsSwimming())
80 return ENodeResult.FAIL;
81 else if (m_charContr.IsFalling())
82 return ENodeResult.RUNNING;
84 return ENodeResult.FAIL;
86 return ENodeResult.SUCCESS;
89 BaseGameEntity gEntity = BaseGameEntity.Cast(entityToTeleport);
91 Math3D.MatrixIdentity4(mat);
92 mat[3] = positionToTeleport;
94 gEntity.Teleport(mat);
95 return ENodeResult.SUCCESS;
99 override bool CanReturnRunning()