/// <summary> /// Goes through all possible paths and picks the one with the lowest score to address the next desire. /// </summary> private void pickNextPath() { if (roomPathMap.Count == 0 && IPpathMap.Count == 0) { return; } float lowestScore = float.MaxValue; int IPidx = -1; RoomObject targetObj = null; bool useIPmap = false; //get the score for each interaction point to determine the final target foreach (RoomObject obj in objectsToTarget) { Room room = obj.GetRoom(); //The camper is not in the same room as this object if (roomPathMap.ContainsKey(room)) { if (getLowestRoomPathScore(room, obj, ref lowestScore, ref IPidx, ref targetObj)) { useIPmap = false; } } else //the camper is in the same room as this object { if (getLowestIPpathScore(obj, ref lowestScore, ref IPidx, ref targetObj)) { useIPmap = true; } } } if (targetObj == null || IPidx == -1) { SetPathStateNone(); return; //TODO better handle } //set up the roomTarget with the lowest scoring path if (roomTarget == null) { roomTarget = new Room.RoomTarget(targetObj.GetRoom(), targetObj, IPidx); } else { roomTarget.Initialize(targetObj.GetRoom(), targetObj, IPidx); } //create a path to the room, not the IP if (useIPmap) { path = IPpathMap[targetObj.interactionPoints[IPidx]]; roomTarget.GetInteractionPoint().AddCamperEnRoute(this); } //create a path to the IP else { path = roomPathMap[targetObj.GetRoom()]; //append the IP path so we go straight to that path.AppendPathToEnd(roomTarget.GetInteractionPoint().GetPath()); roomTarget.GetInteractionPoint().AddCamperEnRoute(this); } pathState = PathState.TravelingOnPath; }