public static Ship CreateTroopShipAtPoint(string key, Empire Owner, Vector2 point, Troop troop)
 {
     Ship newShip = new Ship()
     {
         Role = "troop",
         Name = key,
         VanityName = troop.Name
     };
     newShip.LoadContent(GetContentManager());
     SceneObject newSO = new SceneObject();
     if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated)
     {
         newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0])
         {
             ObjectType = ObjectType.Dynamic
         };
     }
     else
     {
         SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath);
         newSO = new SceneObject(model.Model);
         newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model);
     }
     newSO.ObjectType = ObjectType.Dynamic;
     newShip.SetSO(newSO);
     newShip.Position = point;
     foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList())
     {
         Thruster thr = new Thruster()
         {
             Parent = newShip,
             tscale = t.tscale,
             XMLPos = t.XMLPos
         };
         newShip.GetTList().Add(thr);
     }
     foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList)
     {
         ModuleSlot newSlot = new ModuleSlot();
         newSlot.SetParent(newShip);
         newSlot.SlotOptions = slot.SlotOptions;
         newSlot.Restrictions = slot.Restrictions;
         newSlot.Position = slot.Position;
         newSlot.facing = slot.facing;
         newSlot.InstalledModuleUID = slot.InstalledModuleUID;
         newShip.ModuleSlotList.AddLast(newSlot);
     }
     newShip.loyalty = Owner;
     newShip.Initialize();
     newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f));
     newShip.VanityName = troop.Name;
     lock (GlobalStats.ObjectManagerLocker)
     {
         Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO());
     }
     foreach (Thruster t in newShip.GetTList())
     {
         t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect);
         t.InitializeForViewing();
     }
     newShip.TroopList.Add(Ship_Game.ResourceManager.CopyTroop(troop));
     Owner.AddShip(newShip);
     return newShip;
 }
 public static Ship CreateShipForBattleMode(string key, Empire Owner, Vector2 p)
 {
     Ship newShip = new Ship()
     {
         Role = Ship_Game.ResourceManager.ShipsDict[key].Role,
         Name = Ship_Game.ResourceManager.ShipsDict[key].Name,
         BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength,
         BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp
     };
     newShip.LoadContent(GetContentManager());
     SceneObject newSO = new SceneObject();
     if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated)
     {
         newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0])
         {
             ObjectType = ObjectType.Dynamic
         };
         newShip.SetSO(newSO);
     }
     else
     {
         SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath);
         newSO = new SceneObject(model.Model);
         newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model);
     }
     foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList())
     {
         Thruster thr = new Thruster()
         {
             Parent = newShip,
             tscale = t.tscale,
             XMLPos = t.XMLPos
         };
         newShip.GetTList().Add(thr);
     }
     foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList)
     {
         ModuleSlot newSlot = new ModuleSlot();
         newSlot.SetParent(newShip);
         newSlot.SlotOptions = slot.SlotOptions;
         newSlot.Restrictions = slot.Restrictions;
         newSlot.Position = slot.Position;
         newSlot.facing = slot.facing;
         newSlot.state = slot.state;
         newSlot.InstalledModuleUID = slot.InstalledModuleUID;
         newShip.ModuleSlotList.AddLast(newSlot);
     }
     newShip.Position = p;
     newShip.loyalty = Owner;
     newShip.Initialize();
     newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f));
     newShip.isInDeepSpace = true;
     Owner.AddShip(newShip);
     return newShip;
 }
        //Added by McShooterz: for refit to keep name
        public static Ship CreateShipAt(string key, Empire Owner, Planet p, bool DoOrbit, string RefitName, byte RefitLevel)
        {
            Ship newShip;
            //if (universeScreen.MasterShipList.pendingRemovals.TryPop(out newShip))
            //{
            //    newShip.ShipRecreate();
            //    newShip.Role = Ship_Game.ResourceManager.ShipsDict[key].Role;
            //    newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name;
            //    newShip.BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength;
            //    newShip.BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp;
            //}
            //else
            newShip = new Ship()
            {
                Role = Ship_Game.ResourceManager.ShipsDict[key].Role,
                Name = Ship_Game.ResourceManager.ShipsDict[key].Name,
                BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength,
                BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp

            };
            newShip.LoadContent(GetContentManager());
            SceneObject newSO = new SceneObject();
            if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated)
            {
                newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0])
                {
                    ObjectType = ObjectType.Dynamic
                };
                newShip.SetSO(newSO);
            }
            else
            {
                SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath);
                newSO = new SceneObject(model.Model);
                newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model);
            }
            newSO.ObjectType = ObjectType.Dynamic;
            newShip.SetSO(newSO);
            foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList())
            {
                Thruster thr = new Thruster()
                {
                    Parent = newShip,
                    tscale = t.tscale,
                    XMLPos = t.XMLPos
                };
                newShip.GetTList().Add(thr);
            }
            foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList)
            {
                ModuleSlot newSlot = new ModuleSlot();
                newSlot.SetParent(newShip);
                newSlot.SlotOptions = slot.SlotOptions;
                newSlot.Restrictions = slot.Restrictions;
                newSlot.Position = slot.Position;
                newSlot.facing = slot.facing;
                newSlot.state = slot.state;
                newSlot.InstalledModuleUID = slot.InstalledModuleUID;
                newShip.ModuleSlotList.AddLast(newSlot);
            }
            newShip.Position = p.Position;
            newShip.loyalty = Owner;

            newShip.Initialize();
            //Added by McShooterz: add automatic ship naming
            newShip.VanityName = RefitName;
            newShip.Level = RefitLevel;
            newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f));
            lock (GlobalStats.ObjectManagerLocker)
            {
                Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO());
            }
            foreach (Thruster t in newShip.GetTList())
            {
                t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect);
                t.InitializeForViewing();
            }
            if (newShip.Role == "fighter")
            {
                Ship level = newShip;
                level.Level += Owner.data.BonusFighterLevels;
            }
            Owner.AddShip(newShip);
            newShip.GetAI().State = AIState.AwaitingOrders;
            return newShip;
        }
 public static Ship CreateShipAtPointNow(string key, Empire Owner, Vector2 p)
 {
     Ship newShip = new Ship();
     if (!Ship_Game.ResourceManager.ShipsDict.ContainsKey(key))
     {
         return null;
     }
     newShip.Role = Ship_Game.ResourceManager.ShipsDict[key].Role;
     newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name;
     newShip.BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength;
     newShip.BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp;
     newShip.LoadContent(GetContentManager());
     SceneObject newSO = new SceneObject();
     if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated)
     {
         newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0])
         {
             ObjectType = ObjectType.Dynamic
         };
         newShip.SetSO(newSO);
     }
     else
     {
         SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath);
         newSO = new SceneObject(model.Model);
         newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model);
     }
     newSO.ObjectType = ObjectType.Dynamic;
     newShip.SetSO(newSO);
     if (newShip.Role == "fighter" && Owner.data != null)
     {
         Ship level = newShip;
         level.Level = level.Level + Owner.data.BonusFighterLevels;
     }
     foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList())
     {
         Thruster thr = new Thruster()
         {
             Parent = newShip,
             tscale = t.tscale,
             XMLPos = t.XMLPos
         };
         newShip.GetTList().Add(thr);
     }
     foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList)
     {
         ModuleSlot newSlot = new ModuleSlot();
         newSlot.SetParent(newShip);
         newSlot.SlotOptions = slot.SlotOptions;
         newSlot.Restrictions = slot.Restrictions;
         newSlot.Position = slot.Position;
         newSlot.facing = slot.facing;
         newSlot.state = slot.state;
         newSlot.InstalledModuleUID = slot.InstalledModuleUID;
         newShip.ModuleSlotList.AddLast(newSlot);
     }
     newShip.Position = p;
     newShip.loyalty = Owner;
     newShip.Initialize();
     //Added by McShooterz: add automatic ship naming
     if (GlobalStats.ActiveMod != null && Ship_Game.ResourceManager.ShipNames.CheckForName(Owner.data.Traits.ShipType, newShip.Role))
         newShip.VanityName = Ship_Game.ResourceManager.ShipNames.GetName(Owner.data.Traits.ShipType, newShip.Role);
     newShip.GetSO().World = Matrix.CreateTranslation(new Vector3(newShip.Center, 0f));
     lock (GlobalStats.ObjectManagerLocker)
     {
         Ship_Game.ResourceManager.universeScreen.ScreenManager.inter.ObjectManager.Submit(newShip.GetSO());
     }
     newShip.isInDeepSpace = true;
     foreach (Thruster t in newShip.GetTList())
     {
         t.load_and_assign_effects(Ship_Game.ResourceManager.universeScreen.ScreenManager.Content, "Effects/ThrustCylinderB", "Effects/NoiseVolume", Ship_Game.ResourceManager.universeScreen.ThrusterEffect);
         t.InitializeForViewing();
     }
     Owner.AddShip(newShip);
     return newShip;
 }
        public static Ship GetShip(string key)
        {
            Ship newShip = new Ship()
            {
                Role = Ship_Game.ResourceManager.ShipsDict[key].Role,
                BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength,
                BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp
            };
            newShip.LoadContent(GetContentManager());
            newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].Name;
            SceneObject newSO = new SceneObject();
            if (!Ship_Game.ResourceManager.ShipsDict[key].GetShipData().Animated)
            {
                newSO = new SceneObject(Ship_Game.ResourceManager.GetModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath).Meshes[0])
                {
                    ObjectType = ObjectType.Dynamic
                };
                newShip.SetSO(newSO);
            }
            else
            {
                SkinnedModel model = Ship_Game.ResourceManager.GetSkinnedModel(Ship_Game.ResourceManager.ShipsDict[key].ModelPath);
                newSO = new SceneObject(model.Model);
                newShip.SetAnimationController(new AnimationController(model.SkeletonBones), model);
            }
            newSO.ObjectType = ObjectType.Dynamic;
            newShip.SetSO(newSO);
            foreach (Thruster t in Ship_Game.ResourceManager.ShipsDict[key].GetTList())
            {
                Thruster thr = new Thruster()
                {
                    Parent = newShip,
                    tscale = t.tscale,
                    XMLPos = t.XMLPos
                };
                newShip.GetTList().Add(thr);
            }
            foreach (ModuleSlot slot in Ship_Game.ResourceManager.ShipsDict[key].ModuleSlotList)
            {
                ModuleSlot newSlot = new ModuleSlot();
                newSlot.SetParent(newShip);
                newSlot.SlotOptions = slot.SlotOptions;
                newSlot.Restrictions = slot.Restrictions;
                newSlot.Position = slot.Position;
                newSlot.facing = slot.facing;
                newSlot.state = slot.state;
                newSlot.InstalledModuleUID = slot.InstalledModuleUID;
                newShip.ModuleSlotList.AddLast(newSlot);
            }

            return newShip;
        }