public void SelectShipToBuild(ShipTemplate template) { DeselectTile(); targetToBuild = template; Tile.iSActive = true; }
public static Ship mockShip() { SpacegameServer.Core.ShipBuild builder = new ShipBuild(Core.Instance); var hull = mockShipHull(); hull.ShipHullsModulePositions.Add(Mock.mockShipHullsModulePosition(hull.id, 2, 3)); hull.ShipHullGain = Mock.mockShipHullsGain(hull.id, crew: 3); Core.Instance.ShipHulls[hull.id] = hull; int newShipId = (int)Core.Instance.identities.shipLock.getNext(); Field field = Mock.mockField(); User user = Mock.MockUser(id: (int)Core.Instance.identities.allianceId.getNext()); Core.Instance.users.TryAdd(user.id, user); int userId = user.id; Colony colony = Mock.mockColony(ColonyUserId: userId); bool fastBuild = false; ShipTemplate template = Mock.mockShipTemplate(shiphullid: hull.id, userid: userId); Module crew = Mock.mockModule(); crew.moduleGain = Mock.mockModulesGain(crew.id, crew: 5); Core.Instance.Modules[crew.id] = crew; template.shipModules.Add(Mock.mockShipTemplateModules()); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, fastBuild); return(newShip); }
public void LoadCraft(string filename, string flagname) { this.filename = filename; this.flagname = flagname; ConfigNode craft = ConfigNode.Load(filename); foreach (ConfigNode node in craft.nodes) { if (node.name == "PART") { string name = ShipTemplate.GetPartName(node); string id = ShipTemplate.GetPartId(node); if (name == "launchClamp1") { node.SetValue("part", "ELExtendingLaunchClamp_" + id); foreach (ConfigNode subnode in node.nodes) { if (subnode.name == "MODULE") { string modname = subnode.GetValue("name"); if (modname == "LaunchClamp") { subnode.SetValue("name", "ELExtendingLaunchClamp"); } } } } } } if ((buildCost = getBuildCost(craft)) != null) { craftConfig = craft; state = State.Planning; } }
internal static bool FindSubassembly(ShipTemplate ship) { if (ship == null) { return(false); } if (Text == string.Empty) { return(true); } string _shipinfo = ShipInfo(ship); if (_shipinfo == string.Empty) { return(false); } string _Text = Regex.Replace(Text, @"^/([^/]+)/$", "$1"); if (_Text != Text) { try { return(Regex.IsMatch(_shipinfo, _Text)); } catch { return(FindStandard(_shipinfo, _Text)); } } else { return(FindStandard(_shipinfo, Text)); } }
private Dictionary <int, List <ShipTemplate> > GetShipTemplatesByFactionId(IDbConnection connection) { Dictionary <int, List <ShipTemplate> > factionTemplateMap = new Dictionary <int, List <ShipTemplate> >(); IDbCommand command = connection.CreateCommand(); command.CommandText = "SELECT * FROM ShipTemplate"; var reader = command.ExecuteReader(); while (reader.Read()) { int id = reader.GetInt32(0); int factionId = reader.GetInt32(1); string name = reader[2].ToString(); ushort soldierCap = (ushort)reader.GetInt16(3); ushort boatCap = (ushort)reader.GetInt16(4); ushort landerCap = (ushort)reader.GetInt16(5); ShipTemplate boatTemplate = new ShipTemplate(id, name, soldierCap, boatCap, landerCap); if (!factionTemplateMap.ContainsKey(factionId)) { factionTemplateMap[factionId] = new List <ShipTemplate>(); } factionTemplateMap[factionId].Add(boatTemplate); } return(factionTemplateMap); }
void DrawWindow(int windowID) { GUILayout.BeginVertical(); scroll = GUILayout.BeginScrollView(scroll); ShipTemplate toLoad = null; for (int i = 0, count = buttons.Count; i < count; i++) { var button = buttons[i]; GUILayout.BeginHorizontal(); if (GUILayout.Button(button, Styles.boxed_label, GUILayout.ExpandWidth(true))) { toLoad = subs[i]; } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); if (toLoad != null && load_ship != null) { load_ship(toLoad); Show(false); } if (GUILayout.Button("Close", Styles.close_button, GUILayout.ExpandWidth(true))) { Show(false); } GUILayout.EndVertical(); TooltipsAndDragWindow(); }
// Returns a list of all the parts (as part-definitions) of the given template: public static List <AvailablePart> GetTemplateParts(ShipTemplate template) { var parts = new List <AvailablePart>(); if (template?.config == null) { throw new Exception("invalid template"); } foreach (var node in template.config.GetNodes()) { if (node.name.ToLower() != "part") { continue; // There are no other nodes-types in the vessel-config, but lets be safe. } if (!node.HasValue("part")) { continue; } var partName = node.GetValue("part"); partName = Regex.Replace(partName, "_[0-9A-Fa-f]+$", ""); // The name of the part is appended by the UID (eg "Mark2Cockpit_4294755350"), which is numeric, but it won't hurt if we also remove hex-characters here. if (!KSTS.partDictionary.ContainsKey(partName)) { Debug.LogError("[KSTS] part '" + partName + "' not found in global part-directory"); continue; } parts.Add(KSTS.partDictionary[partName]); } return(parts); }
void ReplaceLaunchClamps(ConfigNode craft) { foreach (ConfigNode node in craft.nodes) { if (node.name == "PART") { string name = ShipTemplate.GetPartName(node); string id = ShipTemplate.GetPartId(node); if (name == "launchClamp1") { foreach (ConfigNode subnode in node.nodes) { if (subnode.name == "MODULE") { string modname = subnode.GetValue("name"); if (modname == "LaunchClamp") { subnode.SetValue("name", "ELExtendingLaunchClamp"); node.SetValue("part", "ELExtendingLaunchClamp_" + id); } } } } } } }
public static Mission CreateConstruction(string shipName, ShipTemplate template, Vessel spaceDock, MissionProfile profile, List <string> crew, string flagURL, double constructionTime) { var mission = new Mission { missionType = MissionType.CONSTRUCT, shipTemplateFilename = SanitizePath(template.filename), targetVesselId = spaceDock.protoVessel.vesselID, shipName = shipName, profileName = profile.profileName, eta = Planetarium.GetUniversalTime() + constructionTime, crewToDeliver = crew, flagURL = flagURL }; // The crew we want the new vessel to start with. if (KACWrapper.APIReady) { var KACalarmID = KACWrapper.KAC.CreateAlarm( KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Construction: " + shipName, mission.eta ); var a = KACWrapper.KAC.Alarms.FirstOrDefault(z => z.ID == KACalarmID); if (a != null) { a.AlarmAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarp; a.AlarmMargin = 0; //a.VesselID = FlightGlobals.ActiveVessel.id.ToString(); a.Notes = "Construction of " + shipName + " by Kerbal Space Transport System"; } } return(mission); }
public void AddToConstruction(ShipTemplate shipTemplate) { var vessel = VesselUtils.ShipName(shipTemplate); var constructionTime = ConstructionTime(shipTemplate); var universalTime = Planetarium.GetUniversalTime(); var alarmToSet = new AlarmTypeRaw { title = $"{shipTemplate.shipName}: Construction...", description = "The vessel is in construction, each bolt must be tightened.", actions = { warp = AlarmActions.WarpEnum.KillWarp, message = AlarmActions.MessageEnum.Yes, deleteWhenDone = true }, ut = universalTime + constructionTime }; AlarmClockScenario.AddAlarm(alarmToSet); construction.Add(new VesselConstruction { AlarmId = alarmToSet.Id, Vessel = vessel, Name = shipTemplate.shipName, StartedAt = universalTime, Time = constructionTime }); }
public static Mission CreateDeployment(string shipName, ShipTemplate template, Orbit orbit, MissionProfile profile, List <string> crew, string flagURL) { var mission = new Mission { missionType = MissionType.DEPLOY, shipTemplateFilename = SanitizePath(template.filename), orbit = orbit, shipName = shipName, profileName = profile.profileName, eta = Planetarium.GetUniversalTime() + profile.missionDuration, crewToDeliver = crew, flagURL = flagURL, }; if (KACWrapper.APIReady) { var KACalarmID = KACWrapper.KAC.CreateAlarm( KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Deployment: " + shipName, mission.eta ); var a = KACWrapper.KAC.Alarms.FirstOrDefault(z => z.ID == KACalarmID); if (a != null) { a.AlarmAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarp; a.AlarmMargin = 0; //a.VesselID = FlightGlobals.ActiveVessel.id.ToString(); a.Notes = "Vessel deployment of " + shipName + " by Kerbal Space Transport System"; } } // The filename contains silly portions like "KSP_x64_Data/..//saves", which break savegames because "//" starts a comment in the savegame ... // The crew we want the new vessel to start with. return(mission); }
public bool CanLaunchVessel(KCT_BuildListVessel vessel, out string reason) { if (vessel == null) { reason = "No vessel"; return(false); } double mass = vessel.GetTotalMass(); if (mass > MaxMass) { reason = $"mass ({mass:0.#}t) is higher than the allowed {MaxMass:0.#}"; return(false); } ShipTemplate template = new ShipTemplate(); template.LoadShip(vessel.shipNode); Vector3 dimensions = ShipConstruction.CalculateCraftSize(template); if (dimensions.x > MaxSize.x | dimensions.y > MaxSize.y | dimensions.z > MaxSize.z) { reason = $"size ({dimensions.x:0.#} x {dimensions.y:0.#} x {dimensions.z:0.#} m) is more than the allowed {MaxSize.x:0.#} x {MaxSize.y:0.#} x {MaxSize.z:0.#} m"; return(false); } reason = null; return(true); }
private static void LoadSupport() { ShipTemplate template = TemplateDatabase.AddShip("DefensePlatform"); template.SetName(Resources.Corvette_DefensePlatformName); template.SetDescription(Resources.Corvette_DefensePlatformDescription); template.SetClass("Corvette", "Support"); template.SetModel("space_station_4"); template.SetRadarTrace("radartrace_smallstation.png"); template.SetHull(150); template.SetShields(new float[] { 120, 120, 120, 120, 120, 120 }); template.SetSpeed(0, 0.5f, 0); // Arc, Dir, Range, CycleTime, Dmg template.SetupBeamWeapon(0, 30, 0, 4000.0f, 1.5f, 20); template.SetupBeamWeapon(1, 30, 60, 4000.0f, 1.5f, 20); template.SetupBeamWeapon(2, 30, 120, 4000.0f, 1.5f, 20); template.SetupBeamWeapon(3, 30, 180, 4000.0f, 1.5f, 20); template.SetupBeamWeapon(4, 30, 240, 4000.0f, 1.5f, 20); template.SetupBeamWeapon(5, 30, 300, 4000.0f, 1.5f, 20); ShipTemplate.DockingPortInfo port = new ShipTemplate.DockingPortInfo(); port.Legacy = true; port.MaxSize = DockingClasses.Small; template.DockingPorts.Add(port); }
private static void LoadStarhammer() { ShipTemplate template = TemplateDatabase.AddShip("Starhammer2"); template.SetName(Resources.Corvette_StarhammerName); template.SetDescription(Resources.Corvette_StarhammerDescription); template.SetClass("Corvette", "Destroyer"); template.SetModel("battleship_destroyer_4_upgraded"); template.SetRadarTrace("radar_dread.png"); template.SetHull(200); template.SetShields(new float[] { 450, 350, 150, 150, 350 }); template.SetSpeed(335, 6, 10); template.SetJumpDrive(); // Arc, Dir, Range, CycleTime, Dmg template.SetupBeamWeapon(0, 60, -10, 2000, 8, 11); template.SetupBeamWeapon(1, 60, 10, 2000, 8, 11); template.SetupBeamWeapon(2, 60, -20, 1500, 8, 11); template.SetupBeamWeapon(3, 60, 20, 1500, 8, 11); template.SetMissleTubeCount(2, 10); template.SetupMissileMagazine(MissileWeaponTypes.HVLI, 20); template.SetupMissileMagazine(MissileWeaponTypes.Homing, 4); template.SetupMissileMagazine(MissileWeaponTypes.EMP, 2); template.RemoveTubeLoadTypes(1, MissileWeaponTypes.EMP); }
public CraftTemplate(string filePath, ShipTemplate temp) { path = filePath; template = temp; if (template == null) throw new KOSException("Failed to load template from given path:\n " + filePath); InitializeSuffixes(); }
void BuildShip(ShipTemplate template) { currentShip = Instantiate(template.ship, transform.position, Quaternion.identity); Stats.money -= template.cost; ShipTempl = template; }
public static string PrepareMessage(ShipTemplate shipTemplate) { return(ConstructScenario.Instance.CanLaunch(shipTemplate) ? PrepareReadyMessage(shipTemplate) : ConstructScenario.Instance.ConstructionStarted(shipTemplate) ? PrepareStartedMessage(shipTemplate) : PrepareNotBuildMessage(shipTemplate)); }
/// <summary> /// Fix the default vessel crew listing when a vessel is selected. (Callback) /// </summary> /// This is called after the list has been entirely rewritten, and /// kerbals have already been (temporarily) assigned to the ship. /// <param name="ship">The vessel selected</param> protected void VesselSelect(ShipTemplate ship) { try { Utilities.FixDefaultVesselCrew(vesselCrew, availableCrew, sortBar); } catch (Exception e) { Debug.LogError("KerbalSorter: Unexpected error in LaunchWindowHook: " + e); } }
public void getCommNodeMessageTest() { instance.commNodes.First().Value.commNodeMessages.Clear(); instance.identities.commNodeMessage.id = 0; //create user User user = Mock.mockGeneratedUser(instance); List <SpacegameServer.BC.XMLGroups.CommNode> commNodes = SpacegameServer.BC.XMLGroups.CommNodes.createKnownAndNearNodesList(user); var node = commNodes.First().node; //create ship SpacegameServer.Core.ShipBuild builder = new ShipBuild(instance); int newShipId = (int)instance.identities.shipLock.getNext(); ShipTemplate template = instance.shipTemplate.Where(e => e.Value.hullid == 1).First().Value; var targetRegionId = GeometryIndex.calcRegionId(node.positionX, node.positionY); Field field = GeometryIndex.regions[targetRegionId].findOrCreateField(node.positionX, node.positionY); Colony colony = Mock.mockColony(ColonyUserId: user.id); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, false); //add user to commNode node.checkAndAddUser(user, newShip); node.sendCommMessage(user, "head1", "body1"); node.sendCommMessage(user, "head2", "body2"); SpacegameServer.BC.BusinessConnector bc = new SpacegameServer.BC.BusinessConnector(); string ret = bc.getCommNodeMessage(user.id, node.id, 0, 50); string expected = @"<messages> <message> <id>2</id> <commNodeId>" + node.id.ToString() + @"</commNodeId> <sender>" + user.id.ToString() + @"</sender> <headline>head2</headline> <messageBody>body2</messageBody> <sendingDate>2015-07-08T20:48:43.2544728Z</sendingDate> <newMessage>0</newMessage> </message> <message> <id>1</id> <commNodeId>" + node.id.ToString() + @"</commNodeId> <sender>1</sender> <headline>head1</headline> <messageBody>body1</messageBody> <sendingDate>2015-07-08T20:48:43.2464723Z</sendingDate> <newMessage>0</newMessage> </message> </messages>"; //sendingDate can't be tested, since it is set to Now() // so only the first few lines are compared ret = String.Join("", ret.Split(new[] { '\r', '\n' }).Where((e, i) => i < 14)); expected = String.Join("", expected.Split(new[] { '\r', '\n' }).Where((e, i) => i < 14)); Assert.AreEqual(expected, ret); }
private void OnGUILaunchScreenVesselSelected(ShipTemplate data) { selectedShip = data; ButtonUtils.RefreshButton(data, launchBtn, constructBtn); ConstructScenario.Instance.spaceCenterSelectedShipName = VesselUtils.ShipName(data); Debug.Log($"[QuickConstruct]({name}): Vessel selected"); }
public double ConstructionFinishAt(ShipTemplate shipTemplate) { var vessel = construction.Find(c => c.Vessel.Equals(VesselUtils.ShipName(shipTemplate))); if (vessel == null) { return(ConstructionTime(shipTemplate)); } return(vessel.StartedAt + vessel.Time - Planetarium.GetUniversalTime()); }
public CraftTemplate(string filePath, ShipTemplate temp) { path = filePath; template = temp; if (template == null) { throw new KOSException("Failed to load template from given path:\n " + filePath); } InitializeSuffixes(); }
public void SetShipTemplate(ShipTemplate template) { Template = template; // 节*1807米/ 3600 * SpeedZoom MaxMoveSpeed = template.Speed * 1807 / 60 / 60 * SpeedZoom; // 加速度等于 最大速度/加速时间 Acceleration = MaxMoveSpeed / Template.SpeededUpSec; }
public static ShipTemplate mockShipTemplate(int id = 1, int userid = userid, byte shiphullid = shiphullid, string NAME = NAME, string gif = gif, int energy = energy, int crew = crew, byte scanrange = scanrange, short attack = attack, short defense = defense, short hitpoints = hitpoints, byte damagereduction = damagereduction, short cargoroom = cargoroom, short fuelroom = fuelroom, int systemmovesperturn = systemmovesperturn, int galaxymovesperturn = galaxymovesperturn, Decimal systemmovesmax = systemmovesmax, Decimal galaxymovesmax = galaxymovesmax, int iscolonizer = iscolonizer, long population = population, int constructionduration = constructionduration, bool constructable = constructable, int amountbuilt = amountbuilt, bool obsolete = obsolete, int shiphullsimage = shiphullsimage) { ShipTemplate template = new ShipTemplate(); template.userId = userid; template.hullid = shiphullid; template.name = NAME; template.gif = gif; template.energy = energy; template.crew = crew; template.scanRange = scanrange; template.attack = attack; template.defense = defense; template.hitpoints = hitpoints; template.damagereduction = damagereduction; template.cargoroom = cargoroom; template.fuelroom = fuelroom; template.systemmovesperturn = systemmovesperturn; template.galaxymovesperturn = galaxymovesperturn; template.max_impuls = systemmovesmax; template.max_hyper = galaxymovesmax; template.iscolonizer = iscolonizer; template.population = population; template.constructionduration = constructionduration; template.isConstructable = constructable; template.amountbuilt = amountbuilt; template.obsolete = obsolete; template.shipHullsImage = shiphullsimage; return(template); }
public static Ship CreateShipAtField(Core instance, User user, Field field) { SpacegameServer.Core.ShipBuild builder = new ShipBuild(instance); int newShipId = (int)instance.identities.shipLock.getNext(); ShipTemplate template = instance.shipTemplate.Where(e => e.Value.hullid == 1).First().Value; Colony colony = Mock.mockColony(ColonyUserId: user.id); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, false); return(newShip); }
private VesselCrewManifest BuildCrewManifest(ShipTemplate shipTemplate, ListValue crew) { var manifest = VesselCrewManifest.FromConfigNode(shipTemplate.config); KerbalRoster shipRoster = new KerbalRoster(HighLogic.CurrentGame.Mode); foreach (var name in crew) { var protoCrewMember = HighLogic.CurrentGame.CrewRoster.Crew.FirstOrDefault(pcm => pcm.name == name.ToString()); if (protoCrewMember != null && protoCrewMember.rosterStatus == ProtoCrewMember.RosterStatus.Available) { shipRoster.AddCrewMember(protoCrewMember); } } // first pass: use auto-assignment to make sure pilots get command parts, etc manifest = shipRoster.DefaultCrewForVessel(shipTemplate.config, manifest); // add anyone missing if (manifest.CrewCount < shipRoster.Count) { foreach (var pcm in shipRoster.Crew) { if (!manifest.Contains(pcm)) { bool AddCrewToManifest(ProtoCrewMember crewMember) { foreach (var pm in manifest.PartManifests) { for (int seatIndex = 0; seatIndex < pm.partCrew.Length; ++seatIndex) { if (string.IsNullOrEmpty(pm.partCrew[seatIndex])) { pm.AddCrewToSeat(crewMember, seatIndex); return(true); } } } return(false); } if (!AddCrewToManifest(pcm)) { SafeHouse.Logger.LogError(string.Format("failed to add {0} to a seat", pcm.name)); } } } } return(manifest); }
public List <string> MeetsFacilityRequirements(bool highestFacility = true) { List <string> failedReasons = new List <string>(); if (!Utilities.CurrentGameIsCareer()) { return(failedReasons); } ShipTemplate template = new ShipTemplate(); template.LoadShip(ShipNode); if (Type == ListType.VAB) { KCT_LaunchPad selectedPad = highestFacility ? KCTGameStates.ActiveKSC.GetHighestLevelLaunchPad() : KCTGameStates.ActiveKSC.ActiveLPInstance; float launchpadNormalizedLevel = 1f * selectedPad.level / KCTGameStates.BuildingMaxLevelCache["LaunchPad"]; double totalMass = GetTotalMass(); if (totalMass > GameVariables.Instance.GetCraftMassLimit(launchpadNormalizedLevel, true)) { failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons"); } if (ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true)) { failedReasons.Add("Part Count limit exceeded"); } CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(launchpadNormalizedLevel, true)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } else if (Type == ListType.SPH) { double totalMass = GetTotalMass(); if (totalMass > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)) { failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons"); } if (ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false)) { failedReasons.Add("Part Count limit exceeded"); } CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } return(failedReasons); }
public static Mission CreateDeployment(string shipName, ShipTemplate template, Orbit orbit, MissionProfile profile, List <string> crew, string flagURL) { var mission = new Mission { missionType = MissionType.DEPLOY, shipTemplateFilename = SanitizePath(template.filename), orbit = orbit, shipName = shipName, profileName = profile.profileName, eta = Planetarium.GetUniversalTime() + profile.missionDuration, crewToDeliver = crew, flagURL = flagURL, }; Log.Info("CreateDeployment, current time: " + Planetarium.GetUniversalTime().ToString("F0") + ", eta: " + mission.eta.ToString("F0")); if (KACWrapper.APIReady && MissionController.useKACifAvailable) { Log.Info("Setting KAC Alarm"); var KACalarmID = KACWrapper.KAC.CreateAlarm( KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Deployment: " + shipName, mission.eta ); var a = KACWrapper.KAC.Alarms.FirstOrDefault(z => z.ID == KACalarmID); if (a != null) { a.AlarmAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarp; a.AlarmMargin = 0; //a.VesselID = FlightGlobals.ActiveVessel.id.ToString(); a.Notes = "Vessel deployment of " + shipName + " by Kerbal Space Transport System"; } } if (MissionController.useStockAlarmClock) { Log.Info("Setting stock alarm"); AlarmTypeRaw alarmToSet = new AlarmTypeRaw { title = "KSTS Vessel Deployment", description = "Vessel deployment of " + shipName + " by Kerbal Space Transport System", actions = { warp = AlarmActions.WarpEnum.KillWarp, message = AlarmActions.MessageEnum.Yes }, ut = mission.eta }; AlarmClockScenario.AddAlarm(alarmToSet); } // The filename contains silly portions like "KSP_x64_Data/..//saves", which break savegames because "//" starts a comment in the savegame ... // The crew we want the new vessel to start with. return(mission); }
public void DeselectTile() { targetToBuild = null; upgradePanel.SetActive(false); Tile.iSActive = false; if (selectedTile) { selectedTile.TileIsSelected = false; selectedTile.GetComponent <Renderer>().material.color = selectedTile.GetStartColor(); } }
private Ship createShipAtCommNode(User user, CommunicationNode node) { SpacegameServer.Core.ShipBuild builder = new ShipBuild(instance); int newShipId = (int)instance.identities.shipLock.getNext(); ShipTemplate template = instance.shipTemplate.Where(e => e.Value.hullid == 1).First().Value; var targetRegionId = GeometryIndex.calcRegionId(node.positionX, node.positionY); Field field = GeometryIndex.regions[targetRegionId].findOrCreateField(node.positionX, node.positionY); Colony colony = Mock.mockColony(ColonyUserId: user.id); Ship newShip = builder.buildShip(newShipId, template, field, user.id, colony, false); return(newShip); }
public Vector3 GetShipSize() { if (ShipSize.sqrMagnitude > 0) { return(ShipSize); } ShipTemplate template = new ShipTemplate(); template.LoadShip(ShipNode); ShipSize = template.GetShipSize(); return(ShipSize); }
private static string ShipInfo(ShipTemplate ship) { string _shipinfo = string.Empty; if (ship.shipName != null) { _shipinfo += ship.shipName + " "; } if (ship.shipDescription != null) { _shipinfo += ship.shipDescription + " "; } return _shipinfo; }
internal static bool FindSubassembly(ShipTemplate ship) { if (ship == null) { return false; } if (Text == string.Empty) { return true; } string _shipinfo = ShipInfo (ship); if (_shipinfo == string.Empty) { return false; } string _Text = Regex.Replace (Text, @"^/([^/]+)/$", "$1"); if (_Text != Text) { try { return Regex.IsMatch (_shipinfo, _Text); } catch { return FindStandard (_shipinfo, _Text); } } else { return FindStandard (_shipinfo, Text); } }
public List<string> MeetsFacilityRequirements() { List<string> failedReasons = new List<string>(); if (!KCT_Utilities.CurrentGameIsCareer()) return failedReasons; ShipTemplate template = new ShipTemplate(); template.LoadShip(shipNode); if (this.type == KCT_BuildListVessel.ListType.VAB) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level/2.0F, true)) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true)) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level/2.0F, true)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } else if (this.type == KCT_BuildListVessel.ListType.SPH) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false)) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } return failedReasons; }
public void OnGUILaunchScreenVesselSelected(ShipTemplate t) { StartCoroutine(CallbackUtil.DelayedCallback(1, BuildCrewAssignmentDialogue)); }
/// <summary> /// Fix the default vessel crew listing when a vessel is selected. (Callback) /// </summary> /// This is called after the list has been entirely rewritten, and /// kerbals have already been (temporarily) assigned to the ship. /// <param name="ship">The vessel selected</param> protected void VesselSelect(ShipTemplate ship) { try { Utilities.FixDefaultVesselCrew(vesselCrew, availableCrew, sortBar); } catch( Exception e ) { Debug.LogError("KerbalSorter: Unexpected error in LaunchWindowHook: " + e); } }