public static Ship CreateShipAt(string key, Empire Owner, Planet p, bool DoOrbit, string role, List<Troop> Troops) { Ship newShip = new Ship() { Role = role, BaseStrength = Ship_Game.ResourceManager.ShipsDict[key].BaseStrength, BaseCanWarp = Ship_Game.ResourceManager.ShipsDict[key].BaseCanWarp }; if (role == "troop") { if (Troops.Count <= 0) { newShip.VanityName = "Troop Shuttle"; } else { newShip.VanityName = Troops[0].Name; } } newShip.Name = Ship_Game.ResourceManager.ShipsDict[key].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); } newShip.SetSO(newSO); newShip.Position = p.Position; 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); } if (newShip.Role == "fighter") { Ship level = newShip; level.Level = level.Level + Owner.data.BonusFighterLevels; } newShip.loyalty = Owner; newShip.Initialize(); //Added by McShooterz: add automatic ship naming if (GlobalStats.ActiveModInfo != 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()); } 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 (DoOrbit) { newShip.DoOrbit(p); } foreach (Troop t in Troops) { newShip.TroopList.Add(Ship_Game.ResourceManager.CopyTroop(t)); } Owner.AddShip(newShip); return newShip; }