private void AddWayPoint(WaypointData wpData) { if (wpData.isAdded) { return; } Waypoint waypoint = wpData.waypoint; // No contract, no waypoint if (waypoint.contractReference == null) { return; } // Always surface and navigatable waypoint.isOnSurface = true; waypoint.isNavigatable = true; // Show only active waypoints in flight, but show offered as well in the tracking station if (HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.FLIGHT) { ContractConfiguratorParameters parms = HighLogic.CurrentGame.Parameters.CustomParams <ContractConfiguratorParameters>(); if (contract.ContractState == Contract.State.Active && (parms.DisplayActiveWaypoints || HighLogic.LoadedScene != GameScenes.TRACKSTATION) || contract.ContractState == Contract.State.Offered && parms.DisplayOfferedWaypoints && HighLogic.LoadedScene == GameScenes.TRACKSTATION) { WaypointManager.AddWaypoint(waypoint); wpData.isAdded = true; } } }
private Waypoint setupNewWaypoint(Vessel v) { if (!useWaypoints) { return(null); } waypointsOn = true; Waypoint wp = new Waypoint(); wp.celestialName = TargetBody.GetName(); wp.latitude = 0; wp.longitude = 0; wp.altitude = 0; wp.index = 0; wp.id = "dmVessel"; wp.iconSize = 32; wp.blocksInput = false; wp.seed = SystemUtilities.SuperSeed(this.Root); wp.isOnSurface = false; wp.isNavigatable = false; wp.enableMarker = false; wp.enableTooltip = false; wp.landLocked = false; wp.name = v.vesselName; wp.contractReference = this.Root; WaypointManager.AddWaypoint(wp); return(wp); }
protected override void OnLoad(ConfigNode node) { Util.LoadNode(node, "RoverWaypointParameter", "targetBody", ref targetBody, Planetarium.fetch.Home); Util.LoadNode(node, "RoverWaypointParameter", "isSecret", ref isSecret, false); Util.LoadNode(node, "RoverWaypointParameter", "waypointID", ref waypointID, 0); Util.LoadNode(node, "RoverWaypointParameter", "centerLatitude", ref centerLatitude, 0.0); Util.LoadNode(node, "RoverWaypointParameter", "centerLongitude", ref centerLongitude, 0.0); Util.LoadNode(node, "RoverWaypointParameter", "range", ref range, 10000); if (HighLogic.LoadedSceneIsFlight && this.Root.ContractState == Contract.State.Active && this.State == ParameterState.Incomplete) { wp.celestialName = targetBody.GetName(); wp.seed = Root.MissionSeed; wp.id = waypointID; wp.RandomizeNear(centerLatitude, centerLongitude, targetBody.GetName(), range, false); wp.setName(false); wp.waypointType = WaypointType.ROVER; wp.altitude = 0.0; wp.isClustered = true; wp.isOnSurface = true; wp.isNavigatable = true; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { if (this.Root.ContractState != Contract.State.Completed) { wp.celestialName = targetBody.GetName(); wp.seed = Root.MissionSeed; wp.id = waypointID; wp.RandomizeNear(centerLatitude, centerLongitude, targetBody.GetName(), range, false); wp.setName(false); wp.waypointType = WaypointType.ROVER; wp.altitude = 0.0; wp.isClustered = true; wp.isOnSurface = true; wp.isNavigatable = false; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } } }
protected override void OnLoad(ConfigNode node) { Util.LoadNode(node, "FlightWaypointParameter", "targetBody", ref targetBody, Planetarium.fetch.Home); Util.LoadNode(node, "FlightWaypointParameter", "minAltitude", ref minAltitude, 0.0); Util.LoadNode(node, "FlightWaypointParameter", "maxAltitude", ref maxAltitude, 10000); Util.LoadNode(node, "FlightWaypointParameter", "waypointID", ref waypointID, 0); Util.LoadNode(node, "FlightWaypointParameter", "centerLatitude", ref centerLatitude, 0.0); Util.LoadNode(node, "FlightWaypointParameter", "centerLongitude", ref centerLongitude, 0.0); Util.LoadNode(node, "FlightWaypointParameter", "range", ref range, 10000); if (HighLogic.LoadedSceneIsFlight && this.Root.ContractState == Contract.State.Active && this.State == ParameterState.Incomplete) { wp.celestialName = targetBody.GetName(); wp.seed = Root.MissionSeed; wp.id = waypointID; wp.RandomizeNear(centerLatitude, centerLongitude, targetBody.GetName(), range, true); wp.setName(); wp.waypointType = WaypointType.PLANE; wp.altitude = calculateMidAltitude(); wp.isOnSurface = true; wp.isNavigatable = true; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } // Load all current missions in the tracking station. if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { if (this.Root.ContractState != Contract.State.Completed) { wp.celestialName = targetBody.GetName(); wp.seed = Root.MissionSeed; wp.id = waypointID; wp.RandomizeNear(centerLatitude, centerLongitude, targetBody.GetName(), range, true); wp.setName(); wp.waypointType = WaypointType.PLANE; wp.altitude = calculateMidAltitude(); wp.isOnSurface = true; wp.isNavigatable = false; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } } }
protected override void OnKeyDown(OpenTK.Input.KeyboardKeyEventArgs e) { base.OnKeyDown(e); if (e.Key == OpenTK.Input.Key.Q) { mode++; if (mode > 3) { mode = 0; } } if (e.Key == OpenTK.Input.Key.Tab) { wm.AddWaypoint(cameraLocation + (rtLocation * 6)); } if (e.Key == OpenTK.Input.Key.Tilde) { //Add a box to the scene physics_world.AddDynamicGeometry( Box.AttachedObject, Matrix4.CreateTranslation(cameraLocation), Box); } if (e.Key == OpenTK.Input.Key.Escape) { this.Exit(); Application.Exit(); } if (e.Alt && e.Key == OpenTK.Input.Key.Enter) { if (!(this.WindowState == WindowState.Fullscreen)) { this.WindowBorder = WindowBorder.Hidden; this.WindowState = WindowState.Fullscreen; } else { this.WindowBorder = WindowBorder.Resizable; this.WindowState = WindowState.Normal; } } }
public void UpdateWaypoint() { // Get the vessel to use Vessel vessel = ContractVesselTracker.Instance.GetAssociatedVessel(vesselKey); if (vessel == null) { if (waypoint != null) { WaypointManager.RemoveWaypoint(waypoint); waypoint = null; } return; } if (waypoint == null) { waypoint = new Waypoint(); waypoint.seed = contract.MissionSeed; waypoint.index = 0; waypoint.landLocked = false; waypoint.id = "vessel"; waypoint.isNavigatable = false; waypoint.enableTooltip = false; waypoint.enableMarker = false; waypoint.contractReference = contract; WaypointManager.AddWaypoint(waypoint); } waypoint.name = vessel.loaded ? vessel.vesselName : vessel.protoVessel.vesselName; waypoint.celestialName = vessel.mainBody.GetName(); waypoint.latitude = vessel.loaded ? vessel.latitude : vessel.protoVessel.latitude; waypoint.longitude = vessel.loaded ? vessel.longitude : vessel.protoVessel.longitude; waypoint.altitude = vessel.loaded ? vessel.altitude : vessel.protoVessel.altitude; Orbit orbit = vessel.loaded ? vessel.orbit : vessel.protoVessel.orbitSnapShot.Load(); waypoint.SetFadeRange(orbit.ApR); waypoint.orbitPosition = orbit.getPositionAtUT(Planetarium.GetUniversalTime()); waypoint.isOnSurface = vessel.LandedOrSplashed; }
private void AddWayPoint(Waypoint waypoint) { // No contract, no waypoint if (waypoint.contractReference == null) { return; } // Always surface and navigatable waypoint.isOnSurface = true; waypoint.isNavigatable = true; // Show only active waypoints in flight, but show offered as well in the tracking station if (HighLogic.LoadedScene == GameScenes.FLIGHT && contract.ContractState == Contract.State.Active || HighLogic.LoadedScene == GameScenes.TRACKSTATION && (contract.ContractState == Contract.State.Offered || contract.ContractState == Contract.State.Active)) { WaypointManager.AddWaypoint(waypoint); } }
protected override void OnLoad(ConfigNode node) { Util.LoadNode(node, "FlightWaypointParameter", "targetBody", ref targetBody, Planetarium.fetch.Home); Util.LoadNode(node, "FlightWaypointParameter", "longitude", ref longitude, 0.0); if (HighLogic.LoadedSceneIsFlight && this.Root.ContractState == Contract.State.Active) { wp.celestialName = targetBody.GetName(); wp.latitude = 0.0; wp.longitude = longitude; wp.seed = Root.MissionSeed; wp.id = 0; wp.setName(); wp.waypointType = WaypointType.DISH; wp.altitude = 0; wp.isOnSurface = true; wp.isNavigatable = true; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } // Load all current missions in the tracking station. if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { if (this.Root.ContractState != Contract.State.Completed) { wp.celestialName = targetBody.GetName(); wp.latitude = 0.0; wp.longitude = longitude; wp.seed = Root.MissionSeed; wp.id = 0; wp.setName(); wp.waypointType = WaypointType.DISH; wp.altitude = 0; wp.isOnSurface = true; wp.isNavigatable = true; WaypointManager.AddWaypoint(wp); submittedWaypoint = true; } } }
protected string setWaypoint(string resourceName, GoldStrikeLode lode) { if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH) { debugLog("Trying to set waypoint"); string location = string.Format("Lon: {0:f2} Lat: {1:f2} Alt: {2:f2}", this.part.vessel.longitude, this.part.vessel.latitude, this.part.vessel.altitude); Waypoint waypoint = new Waypoint(); waypoint.name = resourceName + " Lode"; waypoint.isExplored = true; waypoint.isNavigatable = true; waypoint.isOnSurface = true; waypoint.celestialName = this.part.vessel.mainBody.name; waypoint.longitude = this.part.vessel.longitude; waypoint.latitude = this.part.vessel.latitude; waypoint.altitude = this.part.vessel.altitude; waypoint.seed = UnityEngine.Random.Range(0, int.MaxValue); waypoint.navigationId = Guid.NewGuid(); //Add the waypoint to the custom waypoint scenario ScenarioCustomWaypoints.AddWaypoint(waypoint); //Our icon is not correct, do a quick remove, reset the icon, and add WaypointManager.RemoveWaypoint(waypoint); waypoint.id = WBIGoldStrikeScenario.kLodeIcon; waypoint.nodeCaption1 = location; WaypointManager.AddWaypoint(waypoint); //Record the waypoint info lode.navigationID = waypoint.navigationId.ToString(); //Save the game GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP); //Done return(waypoint.navigationId.ToString()); } return(string.Empty); }
public void SetupLodeIcons() { try { Dictionary <string, Dictionary <string, GoldStrikeLode> > goldStrikeLodes = WBIPathfinderScenario.Instance.goldStrikeLodes; Dictionary <string, GoldStrikeLode>[] lodeMaps = null; Dictionary <string, GoldStrikeLode> lodeMap = null; GoldStrikeLode[] lodes = null; GoldStrikeLode lode = null; Waypoint waypoint = null; string location = string.Empty; lodeMaps = goldStrikeLodes.Values.ToArray(); for (int index = 0; index < lodeMaps.Length; index++) { lodeMap = lodeMaps[index]; lodes = lodeMap.Values.ToArray(); for (int lodeIndex = 0; lodeIndex < lodes.Length; lodeIndex++) { lode = lodes[lodeIndex]; if (string.IsNullOrEmpty(lode.navigationID)) { continue; } waypoint = WaypointManager.FindWaypoint(new Guid(lode.navigationID)); location = string.Format("Lon: {0:f2} Lat: {1:f2}", waypoint.longitude, waypoint.latitude); if (waypoint != null) { WaypointManager.RemoveWaypoint(waypoint); waypoint.id = WBIPathfinderScenario.kLodeIcon; waypoint.nodeCaption1 = location; WaypointManager.AddWaypoint(waypoint); } } } } catch { } }
private void customStartup(parameterContainer p) { Type t = p.CParam.GetType(); GameScenes s = HighLogic.LoadedScene; try { if (t == typeof(ReachDestination) && s == GameScenes.FLIGHT && FlightGlobals.ActiveVessel != null) { if (p.CParam.State == ParameterState.Incomplete && ((ReachDestination)p.CParam).checkVesselDestination(FlightGlobals.ActiveVessel)) { MethodInfo m = (typeof(ContractParameter)).GetMethod("SetComplete", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke(p.CParam, null); } else if (p.CParam.State == ParameterState.Complete && !((ReachDestination)p.CParam).checkVesselDestination(FlightGlobals.ActiveVessel)) { MethodInfo m = (typeof(ContractParameter)).GetMethod("SetIncomplete", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke(p.CParam, null); } } else if (t == typeof(ReachSituation) && s == GameScenes.FLIGHT && FlightGlobals.ActiveVessel != null) { if (p.CParam.State == ParameterState.Incomplete && ((ReachSituation)p.CParam).checkVesselSituation(FlightGlobals.ActiveVessel)) { MethodInfo m = (typeof(ContractParameter)).GetMethod("SetComplete", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke(p.CParam, null); } else if (p.CParam.State == ParameterState.Complete && !((ReachSituation)p.CParam).checkVesselSituation(FlightGlobals.ActiveVessel)) { MethodInfo m = (typeof(ContractParameter)).GetMethod("SetIncomplete", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke(p.CParam, null); } } else if (t == typeof(SpecificOrbitParameter) && s == GameScenes.FLIGHT) { ((SpecificOrbitParameter)p.CParam).SetupRenderer(); } else if (t == typeof(VesselSystemsParameter) && s == GameScenes.FLIGHT) { VesselSystemsParameter sys = (VesselSystemsParameter)p.CParam; MethodInfo m = (typeof(VesselSystemsParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke(sys, null); if (!sys.requireNew) { return; } Vessel v = FlightGlobals.ActiveVessel; if (v == null) { return; } if (v.situation != Vessel.Situations.PRELAUNCH) { return; } uint launchID = v.Parts.Min(r => r.launchID); sys.launchID = launchID; } else if (t == typeof(SurveyWaypointParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(SurveyWaypointParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((SurveyWaypointParameter)p.CParam, null); if (p.Way == null) { return; } var waypoints = WaypointManager.Instance().Waypoints; if (waypoints.Contains(p.Way)) { return; } WaypointManager.AddWaypoint(p.Way); } else if (t == typeof(StationaryPointParameter) && s == GameScenes.FLIGHT) { if (p.Way == null) { return; } var waypoints = WaypointManager.Instance().Waypoints; if (waypoints.Contains(p.Way)) { return; } WaypointManager.AddWaypoint(p.Way); } else if (t == typeof(AsteroidParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(AsteroidParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((AsteroidParameter)p.CParam, null); } else if (t == typeof(CrewCapacityParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(CrewCapacityParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((CrewCapacityParameter)p.CParam, null); } else if (t == typeof(CrewTraitParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(CrewTraitParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((CrewTraitParameter)p.CParam, null); } else if (t == typeof(KerbalDestinationParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(KerbalDestinationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((KerbalDestinationParameter)p.CParam, null); } else if (t == typeof(KerbalTourParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(KerbalTourParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((KerbalTourParameter)p.CParam, null); } else if (t == typeof(KerbalGeeAdventureParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(KerbalGeeAdventureParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((KerbalGeeAdventureParameter)p.CParam, null); } else if (t == typeof(LocationAndSituationParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(LocationAndSituationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((LocationAndSituationParameter)p.CParam, null); } else if (t == typeof(MobileBaseParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(MobileBaseParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((MobileBaseParameter)p.CParam, null); } else if (t == typeof(PartRequestParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(PartRequestParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((PartRequestParameter)p.CParam, null); } else if (t == typeof(ProgressTrackingParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(ProgressTrackingParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((ProgressTrackingParameter)p.CParam, null); } else if (t == typeof(ResourceExtractionParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(ResourceExtractionParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((ResourceExtractionParameter)p.CParam, null); } else if (t == typeof(VesselDestinationParameter) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(VesselDestinationParameter)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((VesselDestinationParameter)p.CParam, null); } else if (t == typeof(RecoverKerbal) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(RecoverKerbal)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((RecoverKerbal)p.CParam, null); } else if (t == typeof(RecoverPart) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(RecoverPart)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((RecoverPart)p.CParam, null); } else if (t == typeof(AcquirePart) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(AcquirePart)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((AcquirePart)p.CParam, null); } else if (t == typeof(AcquireCrew) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(AcquireCrew)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((AcquireCrew)p.CParam, null); } else if (t == typeof(PartTest) && s == GameScenes.FLIGHT) { MethodInfo m = (typeof(PartTest)).GetMethod("OnRegister", BindingFlags.NonPublic | BindingFlags.Instance); if (m == null) { return; } m.Invoke((PartTest)p.CParam, null); if (((PartTest)p.CParam).hauled) { return; } AvailablePart targetPart = ((PartTest)p.CParam).tgtPartInfo; if (targetPart == null) { return; } for (int i = FlightGlobals.VesselsLoaded.Count - 1; i >= 0; i--) { Vessel v = FlightGlobals.VesselsLoaded[i]; if (v == null) { continue; } for (int j = v.Parts.Count - 1; j >= 0; j--) { Part part = v.Parts[j]; if (part == null) { continue; } if (part.partInfo != targetPart) { continue; } var mods = part.FindModulesImplementing <ModuleTestSubject>(); for (int k = 0; k < mods.Count; k++) { ModuleTestSubject test = mods[k]; if (test == null) { continue; } test.Events["RunTestEvent"].active = true; } } } } } catch (Exception e) { LogFormatted("Error while forcing Contract Parameter activation:\n{0}", e); } }
private void setup() { generator = new System.Random(this.Root.MissionSeed); iconWaypoints = new List <Waypoint>(); for (int cardinals = 0; cardinals < 4; cardinals++) { bool addedWaypoint = false; switch (cardinals) { case 0: if (HighLogic.LoadedSceneIsFlight) { iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.ASCENDINGNODE; addedWaypoint = true; } break; case 1: if (HighLogic.LoadedSceneIsFlight) { iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.DESCENDINGNODE; addedWaypoint = true; } break; case 2: iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.APOAPSIS; addedWaypoint = true; break; case 3: iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.PERIAPSIS; addedWaypoint = true; break; } if (addedWaypoint) { iconWaypoints[iconWaypoints.Count - 1].celestialName = targetBody.GetName(); iconWaypoints[iconWaypoints.Count - 1].isOnSurface = false; iconWaypoints[iconWaypoints.Count - 1].isNavigatable = false; iconWaypoints[iconWaypoints.Count - 1].seed = Root.MissionSeed; WaypointManager.AddWaypoint(iconWaypoints[iconWaypoints.Count - 1]); } } for (int x = 0; x < numSpinners; x++) { iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].celestialName = targetBody.GetName(); iconWaypoints[iconWaypoints.Count - 1].waypointType = WaypointType.ORBITAL; iconWaypoints[iconWaypoints.Count - 1].isOnSurface = false; iconWaypoints[iconWaypoints.Count - 1].isNavigatable = false; iconWaypoints[iconWaypoints.Count - 1].seed = Root.MissionSeed; WaypointManager.AddWaypoint(iconWaypoints[iconWaypoints.Count - 1]); } orbitDriver = new OrbitDriver(); orbitDriver.orbit = new Orbit(); orbitDriver.orbit.referenceBody = targetBody; orbitDriver.orbit.semiMajorAxis = sma; orbitDriver.orbit.eccentricity = eccentricity; orbitDriver.orbit.argumentOfPeriapsis = argumentOfPeriapsis; orbitDriver.orbit.inclination = inclination; orbitDriver.orbit.LAN = lan; orbitDriver.orbit.meanAnomalyAtEpoch = meanAnomalyAtEpoch; orbitDriver.orbit.epoch = epoch; orbitDriver.orbit.Init(); //The orbit needs to be post processed in an appropriate scene, or it will be useless. Util.PostProcessOrbit(ref orbitDriver.orbit); orbitDriver.orbitColor = WaypointManager.RandomColor(Root.MissionSeed); orbitRenderer = MapView.MapCamera.gameObject.AddComponent <OrbitRenderer>(); orbitRenderer.driver = orbitDriver; orbitRenderer.drawIcons = OrbitRenderer.DrawIcons.NONE; orbitRenderer.drawNodes = false; orbitRenderer.orbitColor = WaypointManager.RandomColor(Root.MissionSeed); setVisible(true); orbitRenderer.celestialBody = targetBody; beenSetup = true; }
//loads game data public void LoadGame() { //Map Data MapData mapData = SaveSystem.LoadMap(WorldData.currentlyLoadedName); for (int i = 0; i < mapData.amplitude.Length; i++) { mg.terrainOctaves[i].amplitude = mapData.amplitude[i]; mg.terrainOctaves[i].frequency = mapData.frequency[i]; } mg.GenerateMap(mapData.seed); //Player Data PlayerData playerData = SaveSystem.LoadPlayer(WorldData.currentlyLoadedName); pc.speed = playerData.speed; pc.swimmingSpeed = playerData.swimSpeed; pc.sprintSpeed = playerData.sprintSpeed; pc.jumpForce = playerData.jumpForce; pc.transform.position = new Vector3(playerData.position[0], playerData.position[1], playerData.position[2]); pc.transform.rotation = Quaternion.Euler(new Vector3(0, playerData.playerRot, 0)); //Inventory InventoryData inventoryData = SaveSystem.LoadInventory(WorldData.currentlyLoadedName); for (int i = 0; i < inventoryData.itemName.Length; i++) { string path = "ItemIcons/" + inventoryData.spriteName[i]; Sprite icon = (Sprite)Resources.Load(path, typeof(Sprite)); if (icon == null) { Debug.LogError("File not found: " + path); } pi.LoadInventory(inventoryData.itemName[i], icon, inventoryData.weight[i], inventoryData.value[i]); } //Player attribute data AttributeData attributeData = SaveSystem.LoadAttributes(WorldData.currentlyLoadedName); pa.bCanRegenHealth = attributeData.canRegen[0]; pa.bCanRegenStamina = attributeData.canRegen[1]; pa.bCanRegenThirst = attributeData.canRegen[2]; pa.bCanRegenHunger = attributeData.canRegen[3]; pa.healthMeterDrainSpeed = attributeData.drainSpeeds[0]; pa.staminaMeterDrainSpeed = attributeData.drainSpeeds[1]; pa.thirstMeterDrainSpeed = attributeData.drainSpeeds[2]; pa.hungerMeterDrainSpeed = attributeData.drainSpeeds[3]; pa.healthMeterRegenSpeed = attributeData.regenSpeeds[0]; pa.staminaMeterRegenSpeed = attributeData.regenSpeeds[1]; pa.thirstMeterRegenSpeed = attributeData.regenSpeeds[2]; pa.hungerMeterRegenSpeed = attributeData.regenSpeeds[3]; pa.maxHealthMeter = attributeData.maxValues[0]; pa.maxStaminaMeter = attributeData.maxValues[1]; pa.maxThirstMeter = attributeData.maxValues[2]; pa.maxHungerMeter = attributeData.maxValues[3]; pa.ChangeHealthLevel(attributeData.currentValues[0], false); pa.ChangeStaminaLevel(attributeData.currentValues[1], false); pa.ChangeThirstLevel(attributeData.currentValues[2], false); pa.ChangeHungerLevel(attributeData.currentValues[3], false); //Currently loaded chunks ChunkData chunkData = SaveSystem.LoadLoadedChunks(WorldData.currentlyLoadedName); pcl.chunknames = chunkData.loadedChunks; pcl.LoadMap(); //Waypoint data WaypointData waypointData = SaveSystem.LoadWaypoints(WorldData.currentlyLoadedName); wm.waypoints = new Waypoint[waypointData.waypointIDs.Length]; for (int i = 0; i < wm.waypoints.Length; i++) { if (waypointData.waypointInUse[i] == true) // if waypoint is in use { string name = waypointData.waypointNames[i]; bool enabled = waypointData.waypointEnabled[i]; float r = waypointData.waypointColors[i, 0]; float g = waypointData.waypointColors[i, 1]; float b = waypointData.waypointColors[i, 2]; float x = waypointData.waypointLocations[i, 0]; float y = waypointData.waypointLocations[i, 1]; float z = waypointData.waypointLocations[i, 2]; wm.AddWaypoint(name, new Vector3(x, y, z), new Color(r, g, b), enabled); } } //Load environment data EnvironmentData envData = SaveSystem.LoadEnvironment(WorldData.currentlyLoadedName); env.timeMultiplier = envData.timeMultiplier; env.daysInMonth = envData.daysInMonth; env.monthsInYear = envData.MonthsInYear; env.Clockwork = envData.clockWork; env.tempMultiplier = envData.tempMultiplier; env.bIsTempFahrenheit = envData.tempFahrenheit; env.temperature = envData.temperature; env.tempPrecision = envData.tempPrecision; env.windStrengthMultiplier = envData.windStrengthMultiplier; env.windStrength = envData.windStrength; env.windStrengthPrecision = envData.windStrengthPrecision; env.windAnglePrecision = envData.windAnglePrecision; env.windAngle = envData.windAngle; env.seasonEnum = (EnvironmentController.ESeasonEnum)System.Enum.Parse(typeof(EnvironmentController.ESeasonEnum), envData.season); env.weatherEnum = (EnvironmentController.EWeatherEnum)System.Enum.Parse(typeof(EnvironmentController.EWeatherEnum), envData.weather); }
private void setup() { generator = new System.Random(this.Root.MissionSeed); iconWaypoints = new List <Waypoint>(); for (int x = 0; x < 4; x++) { iconWaypoints.Add(new Waypoint()); iconWaypoints[iconWaypoints.Count - 1].celestialName = targetBody.GetName(); iconWaypoints[iconWaypoints.Count - 1].textureName = "orbit"; iconWaypoints[iconWaypoints.Count - 1].isOrbital = true; iconWaypoints[iconWaypoints.Count - 1].seed = Root.MissionSeed; WaypointManager.AddWaypoint(iconWaypoints[iconWaypoints.Count - 1]); } orbitDriver = new OrbitDriver(); //Start with periapsis at a safe distance and a random eccentricity, weighted towards the bottom. //Derive SMA from eccentricity and desired periapsis. orbitDriver.orbit = new Orbit(); switch (this.orbitType) { case OrbitType.POLAR: setRandomOrbit(difficultyFactor, false, true); break; case OrbitType.EQUATORIAL: setRandomOrbit(difficultyFactor, true, false); break; case OrbitType.STATIONARY: setSynchronousOrbit(difficultyFactor, true, 0.0); break; case OrbitType.SYNCHRONOUS: setSynchronousOrbit(difficultyFactor, false, generator.NextDouble() * (difficultyFactor / 2)); break; case OrbitType.MOLNIYA: setMolniyaOrbit(); break; case OrbitType.TUNDRA: setTundraOrbit(); break; default: setRandomOrbit(difficultyFactor, false, false); break; } orbitDriver.orbitColor = WaypointManager.RandomColor(Root.MissionSeed); orbitRenderer = MapView.MapCamera.gameObject.AddComponent <OrbitRenderer>(); orbitRenderer.driver = orbitDriver; orbitRenderer.drawIcons = OrbitRenderer.DrawIcons.NONE; orbitRenderer.drawNodes = false; orbitRenderer.orbitColor = WaypointManager.RandomColor(Root.MissionSeed); setVisible(true); orbitRenderer.celestialBody = targetBody; beenSetup = true; }