public void Update(MySmallShipBot bot, MyEntity entityTarget) { var smallShipTarget = entityTarget as MySmallShip; if (!m_followPosition.HasValue && !m_lookingForPosition && m_followPath == null && !m_lookingForPath) { if (smallShipTarget != null) { // Start looking for visible route position m_lookingForPosition = bot.TryFindRoute(smallShipTarget); } else { // No remembered position pathfinding m_lookingForPath = bot.TryFindPath(entityTarget.WorldAABB.GetCenter()); } } else if (m_lookingForPosition) { CheckIfRoutePositionComputed(bot, entityTarget); } else if (!m_lookingForPosition && m_followPosition.HasValue) { FollowToRoutePosition(bot); } else if (m_lookingForPath) { CheckIfPathComputed(bot); } else if (!m_lookingForPath && m_followPath != null) { FollowPath(bot); } }
public void Update(MySmallShipBot bot) { // Location visible, fly to it if (!lookingForPath) { UpdateTargetVisibility(bot); if (locationVisible) { FlyToLocation(bot); return; } } // Wait for path if (lookingForPath) { WaitForPath(bot); } // Path found, follow path else if (!lookingForPath && followPath != null) { FollowPath(bot); } // Start looking for path else if (!lookingForPath) { lookingForPath = bot.TryFindPath(location); } }
private void CheckIfRoutePositionComputed(MySmallShipBot bot, MyEntity entityTarget) { // Wait for result (visible route position) if (bot.TryGetRoute(out m_followPosition)) { m_lookingForPosition = false; if (!m_followPosition.HasValue) { //PathNotFound = true; m_lookingForPath = bot.TryFindPath(entityTarget.WorldAABB.GetCenter()); // can't get unstuck; try to find path using waypoints } ResetStuck(bot); } }
private void CheckIfRoutePositionComputed(MySmallShipBot bot, MyEntity entityTarget) { // Wait for result (visible route position) if (bot.TryGetRoute(out m_followPosition)) { m_lookingForPosition = false; if (!m_followPosition.HasValue) { //PathNotFound = true; m_lookingForPath = bot.TryFindPath(entityTarget.WorldAABB.GetCenter()); // can't get unstuck; try to find path using waypoints } ResetStuck(bot); } }
public void Update(MySmallShipBot bot) { // Location visible, fly to it if (!lookingForPath) { UpdateTargetVisibility(bot); if (locationVisible) { FlyToLocation(bot); return; } } // Wait for path if (lookingForPath) { WaitForPath(bot); } // Path found, follow path else if (!lookingForPath && followPath != null) { FollowPath(bot); } // Start looking for path else if (!lookingForPath) { lookingForPath = bot.TryFindPath(location); } }
public void Update(MySmallShipBot bot, MyEntity entityTarget) { var smallShipTarget = entityTarget as MySmallShip; if (!m_followPosition.HasValue && !m_lookingForPosition && m_followPath == null && !m_lookingForPath) { if (smallShipTarget != null) { // Start looking for visible route position m_lookingForPosition = bot.TryFindRoute(smallShipTarget); } else { // No remembered position pathfinding m_lookingForPath = bot.TryFindPath(entityTarget.WorldAABB.GetCenter()); } } else if (m_lookingForPosition) { CheckIfRoutePositionComputed(bot, entityTarget); } else if (!m_lookingForPosition && m_followPosition.HasValue) { FollowToRoutePosition(bot); } else if (m_lookingForPath) { CheckIfPathComputed(bot); } else if (!m_lookingForPath && m_followPath != null) { FollowPath(bot); } }