private void Button_ResetDestroyedRobot(bool spawn = true)
        {
            if (robot != null && !robot.Destroyed)
            {
                robot.Destroy(DestroyMode.Vanish);
            }

            this.robot       = null;
            robotIsDestroyed = false;
            if (spawn)
            {
                Button_SpawnBot();
            }
        }
 public void DespawnRobot(X2_AIRobot bot, bool destroying = false)
 {
     if (bot != null && !bot.Destroyed)
     {
         if (destroying)
         {
             bot.Destroy(DestroyMode.Vanish);
         }
         else
         if (bot.Spawned)
         {
             bot.DeSpawn();
         }
     }
     robot = null;
 }
        private void Button_RepairDamagedRobot()
        {
            NameTriple name = null;
            string     first = null, nick = null, last = null;

            Area area = null;

            X2_AIRobot bot = this.robot;

            if (bot == null && this.container.FirstOrDefault() != null)
            {
                bot = this.container.FirstOrDefault();
            }

            if (bot != null)
            {
                name = AIRobot_Helper.GetRobotName(bot);
            }
            if (bot != null && bot.playerSettings != null)
            {
                area = bot.playerSettings.AreaRestriction;
            }

            if (name != null)
            {
                first = name.First;
                nick  = name.Nick;
                last  = name.Last;
                name  = null;
            }

            if (bot != null && !bot.Destroyed && bot.Spawned)
            {
                bot.Destroy(DestroyMode.Vanish);
            }

            this.container.Clear();
            this.robot                 = null;
            this.robotIsDestroyed      = false;
            this.isRepairRequestActive = false;

            Button_SpawnBot();

            this.disabledRobot = null;

            if (first != null && nick != null && last != null)
            {
                name = new NameTriple(first, nick, last);
            }

            // Robot should again be filled (with the new robot)
            if (this.robot != null)
            {
                if (name != null)
                {
                    AIRobot_Helper.SetRobotName(this.robot, name);
                }
                if (area != null)
                {
                    this.robot.playerSettings.AreaRestriction = area;
                }
            }
        }