/// <summary> /// Finds a suitable target for the input thinker. Will set the target of the input state /// </summary> public static void FindTarget(Entity thinker, ThinkState state) { // TODO: get target based on entity plan Entity player = Engine.instance.world.player; if (DetectsTarget(thinker, player)) { state.target = player; } }
/// <summary> /// Process the input state for the input entity. The output action contains all of the /// info on what the input entity should do. /// </summary> public static ThinkAction ProcessThinker(Entity thinker, ThinkState state) { ThinkAction action = new ThinkAction(); if (state.target == null) { FindTarget(thinker, state); } // TODO: other types of moves. This jsut moves to the target if (state.target != null) { Vector2 toTarget = state.target.position - thinker.position; action.moveStep = Vector2.OrthoNormal(toTarget); } else { action.moveStep = new Vector2(0, 0); } return(action); }