void CycleDestinations(Grid grid, Random rng, Overseer os) { if (wait) { if (os.Ais[destinations[0]].WayPoints.Count > 0) { destination = Grid.ToGridPosition(os.Ais[destinations[0]].WayPoints.Last(), Grid.GetTileSize); } else { destination = Grid.ToGridPosition(os.Ais[destinations[0]].Position, Grid.GetTileSize); } target = destinations[0]; Think_Pathing(grid, rng); } else if (PFResult != null) { if (PFResult.GetType() == typeof(TileStates)) { destinations.RemoveAt(0); } else { Think_Pathing(grid, rng); destinations.Clear(); } } if (destinations.Count == 0) { Ai_States = Ai_States.Thinking; } }
protected bool Think_Pathing(Grid grid, Random rng) { WayPoints.Clear(); if (PFResult != null) { wait = false; if (PFResult.GetType() == typeof(TileStates)) { PFResult = null; Ai_States = Ai_States.Target; WayPoints.Clear(); p_wait = true; return(false); } if (PFResult.GetType() == typeof(bool)) { PFResult = null; Ai_States = Ai_States.Target; WayPoints.Clear(); p_wait = true; stuck = true; return(false); } WayPoints = ((List <Vector2>)(PFResult)); if (grid.CheckPositions(WayPoints).Count != WayPoints.Count) //theres a break in a waypoint { PFResult = null; Ai_States = Ai_States.Idle; WayPoints.Clear(); p_wait = true; return(false); } else { PFResult = null; p_wait = false; Ai_States = Ai_States.Moving; return(true); } } else if (freeCorners.Count > 0) { if (!GetPath(grid, Center, destination, rng)) { CheckActivity(); pathAttempts++; } else { wait = false; pathAttempts = 0; return(true); } wait = true; } return(false); }