public override Vector3 GetFormationPosition(MySmallShipBot bot) { int followerIndex = Followers.IndexOf(bot); if (followerIndex < 0) { System.Diagnostics.Debug.Fail("GetFormationPosition - Follower not found!"); return bot.GetPosition(); } return GetFormationPosition(followerIndex); }
/// <summary> /// For debugging, add text to the debug screen which details the state of this bot. /// TODO: Move this to MyGuiScreenDebugBot. That class is specific to bot so this stuff could/should go there. /// </summary> /// <param name="bot">Computer-controlled ship.</param> /// <param name="player">The bot's target.</param> public static void AddToFrameDebugText(MySmallShipBot bot, MySmallShip player) { // Get a reference to the debug screen. MyGuiScreenDebugBot debugScreen = MyGuiManager.GetScreenDebugBot(); if (debugScreen != null) { // Here's the bot info we're adding to the debug screen text. debugScreen.AddToFrameDebugText("MyPhysObjectBot"); // Hello. debugScreen.AddToFrameDebugText(" Message: Hello!"); // Position. debugScreen.AddToFrameDebugText(" Player.Position: " + MyUtils.GetFormatedVector3(player.GetPosition(), 0)); // Offest between bot and player. Vector3 playerPos = player.GetPosition(); Vector3 botPos = bot.GetPosition(); Vector3 botToPlayer = botPos - playerPos; debugScreen.AddToFrameDebugText(" BotToPlayer: " + botToPlayer.ToString()); // Offest between player and bot. Vector3 playerToBot = playerPos - botPos; debugScreen.AddToFrameDebugText(" PlayerToBot: " + playerToBot.ToString()); // Bot forward Vector3 forward = bot.WorldMatrix.Forward; debugScreen.AddToFrameDebugText(" Bot.WorldMatrix.Forward: " + MyUtils.GetFormatedVector3(forward, 0)); // m_playersRelativePosition //debugScreen.AddToFrameDebugText(" Bot.m_playersRelativePosition: " + MyUtils.GetFormatedVector3(bot.Behavior.TargetsRelativePosition, 0)); // Aimed at player? //debugScreen.AddToFrameDebugText(" Bot.IsAimedAtPlayer: " + bot.IsBotPrettyMuchAimedAtPlayer()); // Distance to player. //debugScreen.AddToFrameDebugText(" Bot.DistanceToPlayer: " + ((int)(bot.DistanceTo(bot.Decision.Target))).ToString()); // Rotation indicator. //debugScreen.AddToFrameDebugText(" Bot.RotationIndicator: " + MyUtils.GetFormatedVector2(bot.RotationIndicator, 1)); // Blank line. debugScreen.AddToFrameDebugText(" "); } }
public virtual Vector3 GetFormationPosition(MySmallShipBot bot) { Vector3 centerToBot = bot.GetPosition() - WorldVolume.Center; Vector3 centerToBotNormalized = Vector3.Normalize(centerToBot); return WorldVolume.Center + centerToBotNormalized * (WorldVolume.Radius + MyAIConstants.FORMATION_SPACING); }