forked from Onek8/LNXSDK
43 lines
1.2 KiB
Haxe
43 lines
1.2 KiB
Haxe
package leenkx.logicnode;
|
|
|
|
#if lnx_navigation
|
|
import leenkx.trait.navigation.Navigation;
|
|
import leenkx.trait.NavMesh;
|
|
import leenkx.trait.NavCrowd;
|
|
#end
|
|
|
|
import iron.object.Object;
|
|
import iron.math.Vec4;
|
|
|
|
class CrowdGoToLocationNode extends LogicNode {
|
|
|
|
public function new(tree: LogicTree) {
|
|
super(tree);
|
|
}
|
|
|
|
override function run(from: Int) {
|
|
var navMeshId: String = inputs[1].get();
|
|
var object: Object = inputs[2].get();
|
|
var location: Vec4 = inputs[3].get();
|
|
var maxSpeed: Float = inputs[4].get();
|
|
var maxAcceleration: Float = inputs[5].get();
|
|
var turnSpeed: Float = inputs[6].get();
|
|
|
|
assert(Error, object != null, "The object input not be null");
|
|
assert(Error, location != null, "The location to navigate to must not be null");
|
|
|
|
#if lnx_navigation
|
|
var activeNavMesh: NavMesh = Navigation.active.navMeshes.get(navMeshId);
|
|
assert(Error, activeNavMesh != null, "No Navigation Mesh Present");
|
|
|
|
var crowdAgent: NavCrowd = object.getTrait(NavCrowd);
|
|
assert(Error, crowdAgent != null, "Object does not have a NavCrowd trait");
|
|
crowdAgent.crowdAgentSetMaxSpeed(maxSpeed);
|
|
crowdAgent.crowdAgentSetMaxAcceleration(maxAcceleration);
|
|
crowdAgent.turnSpeed = turnSpeed;
|
|
crowdAgent.crowdAgentGoto(location);
|
|
#end
|
|
runOutput(0);
|
|
}
|
|
}
|