// Update is called once per frame void Update() { currentMap.Update(); if (Input.GetKeyDown(KeyCode.I)) { test(); } if (eventQueue.Count > 0) { Main.controlsLocked = true; eventQueue[0].Update(); if (eventQueue[0].finished) { eventQueue.RemoveAt(0); Main.controlsLocked = false; } return; } if (loadingScreen.transitionOn && loadingScreen.finishedTransition) { loadMap(wpToLoad.mapName); player.SetPosition(wpToLoad.warpTileX * 16 + 8, -wpToLoad.warpTileY * 16 + 8); loadingScreen.startTransitionOff(); } else if (!loadingScreen.active) { WarpPoint destWarpPoint = currentMap.isWarpPointColliding(player); if (destWarpPoint != null) { Main.controlsLocked = true; wpToLoad = destWarpPoint; loadingScreen.startTransitionOn(); } } }
public void SetWarpPoint(String name, WarpPoint warpPoint, Boolean defaultWarpPoint = false) { Map.SetWarpPoint(name, warpPoint, defaultWarpPoint); WarpPointWidget warpPointWidget = new WarpPointWidget(warpPoint); SetWidget(WarpPoints[name], warpPointWidget); WarpPoints[name] = warpPointWidget; }
public override string ToString() { if (WarpPoint == null) { return("Invalid Warp Order"); } return("Warp via " + WarpPoint.Name + " in " + WarpPoint.FindStarSystem()); }
public void AddWarpPoint(int id, WarpPoint warpPoint) { if (!warpPoints.ContainsKey(id)) { warpPoints.Add(id, warpPoint); AddWarpButton(warpPoint); } }
public void Execute(IOrderable ord) { var errors = GetErrors(ord); foreach (var error in errors) { Owner.Log.Add(error); } var sobj = (IMobileSpaceObject)ord; if (!errors.Any()) { var here = sobj.Sector; if (here == WarpPoint.Sector) { // warp now!!! here.Remove(sobj); // warp point turbulence damage? if (WarpPoint.HasAbility("Warp Point - Turbulence")) { var dmg = WarpPoint.GetAbilityValue("Warp Point - Turbulence").ToInt(); sobj.TakeNormalDamage(dmg); if (sobj.IsDestroyed) { sobj.Owner.Log.Add(sobj.CreateLogMessage(sobj + " was destroyed by turbulence when traversing " + WarpPoint + ".", LogMessageType.Generic)); return; } else { sobj.Owner.Log.Add(sobj.CreateLogMessage(sobj + " took " + dmg + " points of damage from turbulence when traversing " + WarpPoint + ".", LogMessageType.Generic)); } } sobj.Sector = WarpPoint.Target; sobj.RefreshDijkstraMap(); // mark system explored WarpPoint.TargetStarSystemLocation.Item.MarkAsExploredBy(((ISpaceObject)sobj).Owner); // done warping IsComplete = true; } else { // can'IMobileSpaceObject warp here, maybe the GUI should have issued a move order? ((ISpaceObject)sobj).Owner.Log.Add(sobj.CreateLogMessage(sobj + " cannot warp via " + WarpPoint + " because it is not currently located at the warp point.", LogMessageType.Warning)); } } // spend time sobj.SpendTime(sobj.TimePerMove); }
public void AddWarpPoint(WarpPoint warpPoint, Boolean addToMap = true, Boolean defaultWarpPoint = false) { if (addToMap) Map.AddWarpPoint(warpPoint, defaultWarpPoint); if (WarpPoints.ContainsKey(warpPoint.Name)) return; WarpPointWidget warpPointWidget = new WarpPointWidget(warpPoint); AddWidget(warpPointWidget); WarpPoints.Add(warpPointWidget.WarpPoint.Name, warpPointWidget); }
public static void SavePoint(User user, string warpName) { // Bei jedem erstellen eines Warppunkt wird eine Rolle benötigt. WarpPunktRolleItem warpPunktItem = new WarpPunktRolleItem(); ItemStack istack = new ItemStack(warpPunktItem, 1, null); List <ItemStack> itemStacks = new List <ItemStack>(); itemStacks.Add(istack); using (var db = new LiteDatabase(@"GB.db")) { var warps = db.GetCollection <WarpPoint>("warps"); WarpPoint warpPoint = new WarpPoint { Creator = user.Name, WarpName = warpName, WarpPosX = user.Position.x, WarpPosY = user.Position.y + 1f, WarpPosZ = user.Position.z, TimeAndDate = DateTime.Now, }; var existName = warps.FindOne(x => x.WarpName.Contains(warpName)); if (existName == null) { if (user.Inventory.Contains(itemStacks)) { try { user.Inventory.TryRemoveItem(warpPunktItem.GetType(), user); warps.Insert(warpPoint); ChatManager.ServerMessageToAll("<color=green>" + warpPoint.Creator + " hat den Warppunkt " + warpPoint.WarpName + " erstellt!", true, DefaultChatTags.Notifications, ChatCategory.Info, null); } catch (Exception) { AdvertError(user, warpPoint.WarpName); throw; } AdvertSuccess(user, warpPoint.WarpName); } else { ChatManager.ServerMessageToPlayer(new LocString("<color=red>Du benötigst eine Warp Punkt Rolle um einen Warppunkt zu erstellen, diese kannst du bei einem Magier kaufen!"), user, false, DefaultChatTags.Notifications, ChatCategory.Info); } } else { ChatManager.ServerMessageToPlayer(new LocString("<color=red>Der Warp mit dem Namen " + warpName + " existiert bereits!"), user, false, DefaultChatTags.Notifications, ChatCategory.Info); } } }
private void SpawnPlayerAtWarpPoint() { hasLeftWarp = false; List <WarpPoint> points = new List <WarpPoint>(FindObjectsOfType <WarpPoint>()); WarpPoint result = GetPoint(points); if (result != null) { transform.position = new Vector3(result.transform.position.x, result.transform.position.y, 0); if (result.spawnDialogue != null) { StartCoroutine(ShowDialogue(result.spawnDialogue)); } } }
internal WarpPoint isWarpPointColliding(Player player) { WarpPoint destWarpPoint = null; foreach (WarpPoint wp in warpPoints) { float distSquared = (player.GetPosition() - wp.GetPosition()).sqrMagnitude; if (distSquared <= 10) { destWarpPoint = wp; break; } } return(destWarpPoint); }
public static bool ToWarpPoint(WarpPointDTO input, WarpPoint output) { if (input == null) { return(false); } output.WarpPointID = input.WarpPointID; output.Name = input.Name; output.MapId = input.MapId; output.MapX = input.MapX; output.MapY = input.MapY; output.Authority = input.Authority; return(true); }
public IEnumerator GenerateSystem(Vector2Int location) { var jumpPoint = new Vector3(Random.Range(-100, 100), Random.Range(-100, 100), -1); string name = ""; for (int idx = 0; idx < 6; idx++) { name += Characters.RandomElement(); } var Starsystem = new StarSystem() { JumpPoint = jumpPoint, Location = location, Name = name, Objects = new List <SurveyObject>(), WarpPoints = new List <WarpPoint>() }; yield return(null); var objects = Random.Range(MinObjects, MaxObjects); for (int idx = 0; idx < objects; idx++) { var obj = GenerateObject(Starsystem); obj.StarSystem = Starsystem.Name; Starsystem.Objects.Add(obj); yield return(null); } for (int idx = 0; idx < Random.Range(2, 10); idx++) { var locationwp = new Vector3(); do { locationwp.x = Random.Range(-PlayingArea, PlayingArea); locationwp.y = Random.Range(-PlayingArea, PlayingArea); } while (isTooClose(30, locationwp, Starsystem.Objects) && isTooClose(30, locationwp, Starsystem.WarpPoints)); var warp = new WarpPoint() { Position = locationwp, ToSystem = new Vector2Int(Random.Range(-2, 2), Random.Range(-2, 2)) }; Starsystem.WarpPoints.Add(warp); } Galaxy.StarSystems.Add(location, Starsystem); }
public void AddWarpButton(WarpPoint warpPoint) { GameObject clone = GameObject.Instantiate<GameObject>(warpButtonPrefab); Text cloneText = clone.GetComponentInChildren<Text>(); if (cloneText != null) { cloneText.text = warpPoint.warpName; } WarpButton warpButton = clone.GetComponentInChildren<WarpButton>(); if (warpButton != null) { warpButton.player = player; warpButton.warpPoint = warpPoint; } clone.transform.SetParent(warpMenuPanel.transform); clone.transform.localScale = Vector3.one; }
private WarpPoint GetPoint(List <WarpPoint> points) { WarpPoint defaultPoint = null; foreach (WarpPoint p in points) { if (p.gameObject.name == targetWarp) { return(p); } if (p.isDefaultWarp) { defaultPoint = p; } } if (defaultPoint != null) { return(defaultPoint); } return(null); }
public WarpPointDTO Insert(WarpPointDTO warppoint) { try { using (OpenNosContext context = DataAccessHelper.CreateContext()) { WarpPoint entity = new WarpPoint(); Mapper.Mappers.WarpPointMapper.ToWarpPoint(warppoint, entity); context.WarpPoint.Add(entity); context.SaveChanges(); if (Mapper.Mappers.WarpPointMapper.ToWarpPointDTO(entity, warppoint)) { return(warppoint); } return(null); } } catch (Exception e) { Logger.Error(e); return(null); } }
internal void loadMap(string mapName) { this.clearMap(); this.LoadTMX("Maps/" + mapName); tilemap = (FTilemap)(getLayerNamed("Tilemap")); for (int x = 0; x < 3; x++) { otherTilemaps[x] = new FTilemap(tilemap.BaseElementName + "_" + (x + 1), 1); otherTilemaps[x].LoadText(tilemap.dataString, false); } tilemapCollision = (FTilemap)(getLayerNamed("Meta")); objectGroup = (FContainer)(getLayerNamed("Objects")); foreach (XMLNode xml in this.objects) { switch (xml.attributes["type"]) { case "Spawn": FNode spawnPoint = new FNode(); spawnPoint.SetPosition(int.Parse(xml.attributes["x"]) + 8, -int.Parse(xml.attributes["y"]) + 8); spawnPoints.Add(spawnPoint); player.SetPosition(spawnPoint.GetPosition()); break; case "Warp": int warpX = 0; int warpY = 0; XMLNode propertiesNode = (XMLNode)xml.children[0]; foreach (XMLNode property in propertiesNode.children) { switch (property.attributes["name"]) { case "warpTileX": warpX = int.Parse(property.attributes["value"]); break; case "warpTileY": warpY = int.Parse(property.attributes["value"]); break; } } WarpPoint warpPoint = new WarpPoint(warpX, warpY, xml.attributes["name"], int.Parse(xml.attributes["x"]) + 8, -int.Parse(xml.attributes["y"]) + 8); warpPoints.Add(warpPoint); break; } } for (int x = 0; x < 100; x++) { Scientist s = new Scientist(tilemap.width * RXRandom.Float(), -tilemap.height * RXRandom.Float()); while (BaseGameObject.isWalkable(tilemap, s.x, s.y)) { s.SetPosition(tilemap.width * RXRandom.Float(), -tilemap.height * RXRandom.Float()); } addEnemy(s); } backgroundLayer.AddChild(tilemap); foreach (FTilemap f in otherTilemaps) { backgroundLayer.AddChild(f); } backgroundLayer.AddChild(tilemapCollision); backgroundLayer.AddChild(objectGroup); player.setMap(this); playerLayer.AddChild(player); }
void warpPointbutton_Clicked(object sender, SFML.Window.MouseButtonEventArgs e) { CurrentWarpPointButton = (Button)sender; CurrentWarpPoint = WarpPoints[CurrentWarpPointButton]; // clique droit --> suppression if (e.Button == Mouse.Button.Right) { WarpPointToRemove = CurrentWarpPoint; if (WarpPoints.Count > 1) CallConfirmationDialogBox(new String[] { ConfirmationDialogBox.Instance.GetDeletionStr("WarpPoint", CurrentWarpPointButton.Text) }, RemoveWarpPoint); else CallInformationDialogBox(InformationDialogBox.EType.Error, new String[] { InformationDialogBox.Instance.GetDeletionErrorStr("WarpPoint", CurrentWarpPointButton.Text) }); return; } // clique gauche --> edit SetFocusedWindow(WarpPointCreator.Instance, new OpeningInfo( true, new Dictionary<String, Object> { { "Name", CurrentWarpPoint.Name }, { "Point", CurrentWarpPoint.Point }, { "Direction", CurrentWarpPoint.Direction }, { "Default", CurrentMap.DefaultWarpPoint == CurrentWarpPoint } }), CurrentWarpPointPointCreator_Validated); }
protected override Dictionary<String, Object> OnValidate() { if (!NameTextBox.TextBox.TextIsValid()) { CallInformationDialogBox(InformationDialogBox.EType.Error, new String[] { InformationDialogBox.Instance.GetTypeErrorStr() }); return base.OnValidate(); } WarpPoint warpPoint = new WarpPoint(NameTextBox.TextBox.Text, CurrentPoint, (Direction)Enum.Parse(typeof(Direction), DirectionDownList.GetCurrent())); return new Dictionary<String, Object> { { "WarpPoint", warpPoint }, { "Default", DefaultCheckBox.IsChecked } }; }
void AddWarpPoint(WarpPoint warpPoint, Boolean addToMap = true, Boolean defaultWarpPoint = false) { // ajout a la TextList Button button = new Button(WarpPointCreator.Instance.WarpPointToString(warpPoint), Button.EMode.LabelEffect); button.Clicked += new ClickEventHandler(warpPointbutton_Clicked); WarpPointList.AddText(button); // ajout au dico button/warpPoint WarpPoints.Add(button, warpPoint); // ajout a la map Maps[CurrentMap.Type].AddWarpPoint(warpPoint, addToMap, defaultWarpPoint); }
void CurrentWarpPointPointCreator_Validated(WindowedWidget sender, ValidateEventArgs e) { WarpPoint newWarpPoint = e.GetArg<WarpPoint>("WarpPoint"); WarpPoints[CurrentWarpPointButton] = newWarpPoint; Maps[CurrentMap.Type].SetWarpPoint(CurrentWarpPoint.Name, newWarpPoint, e.GetArg<Boolean>("Default")); CurrentWarpPoint = newWarpPoint; CurrentWarpPointButton.Text = WarpPointCreator.Instance.WarpPointToString(CurrentWarpPoint); }
public StructureInfo(WarpPoint coordinates) { this.pointOfInteraction = coordinates; isBuilding = false; }
public LuaValue proxyWarpToEvent(LuaValue[] args) { if (args.Count() == 0 || args.Count() > 2) throw new Exception("warpToEvent usage: warpToEvent(event) or warpToEvent(event, lead time)"); try { if (args[0].ToString().ToLower().Contains("pe")) warpPoint = WarpPoint.PERIAPSIS; else if (args[0].ToString().ToLower().Contains("ap")) warpPoint = WarpPoint.APOAPSIS; else if (args[0].ToString().ToLower().Contains("soi")) warpPoint = WarpPoint.SOI_CHANGE; else throw new Exception("warpToEvent: event must be one of \"pe\", \"ap\", \"soi\""); } catch (Exception) { throw new Exception("warpToEvent: invalid event"); } if (args.Count() == 2) { try { warpTimeOffset = ((LuaNumber)args[1]).Number; } catch (Exception) { throw new Exception("warpToEvent: invalid lead time"); } } else { warpTimeOffset = 0; } warpTimeOffsetString = warpTimeOffset.ToString(); this.enabled = true; core.controlClaim(this); currentOperation = Operation.WARP; guiTab = Operation.WARP; return LuaNil.Nil; }
public StructureInfo(Placement coordinates, WarpPoint pointOfInteraction, bool useCustomMapPoints) { this.coordinates = coordinates; this.pointOfInteraction = pointOfInteraction; this.useCustomMapPoints = useCustomMapPoints; }
public StructureInfo(Placement coordinates, WarpPoint pointOfInteraction) { this.coordinates = coordinates; this.pointOfInteraction = pointOfInteraction; isBuilding = true; }
public String WarpPointToString(WarpPoint warpPoint) { return warpPoint.Name + " ( " + warpPoint.Point.X.ToString() + ", " + warpPoint.Point.Y.ToString() + " )"; }
protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); GUIStyle normal = new GUIStyle(GUI.skin.label); GUIStyle yellow = new GUIStyle(GUI.skin.label); yellow.normal.textColor = Color.yellow; if (part.vessel.orbit.eccentricity < 1.0) { GUILayout.Label(String.Format("Current orbit: {0:0}km x {1:0}km, inclined {2:0.0}°", part.vessel.orbit.PeA / 1000.0, part.vessel.orbit.ApA / 1000.0, part.vessel.orbit.inclination)); } else { GUILayout.Label(String.Format("Current orbit: hyperbolic, Pe = {0:0}km, inclined {1:0.0}°", part.vessel.orbit.PeA / 1000.0, part.vessel.orbit.inclination)); } guiTab = (Operation)GUILayout.Toolbar((int)guiTab, guiTabStrings); switch (guiTab) { case Operation.PERIAPSIS: newPeA = ARUtils.doGUITextInput("New periapsis: ", 250.0F, newPeAString, 50.0F, "km", 30.0F, out newPeAString, newPeA, 1000.0); if (newPeA > vesselState.altitudeASL) { GUILayout.Label("Periapsis cannot be above current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", deltaVToChangePeriapsis(newPeA)))) { core.controlClaim(this); currentOperation = Operation.PERIAPSIS; raisingApsis = (part.vessel.orbit.PeA < newPeA); } break; case Operation.APOAPSIS: newApA = ARUtils.doGUITextInput("New apoapsis: ", 250.0F, newApAString, 50.0F, "km", 30.0F, out newApAString, newApA, 1000.0); if (newApA < vesselState.altitudeASL) { GUILayout.Label("Apoapsis cannot be below current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", deltaVToChangeApoapsis(newApA)))) { core.controlClaim(this); currentOperation = Operation.APOAPSIS; raisingApsis = (part.vessel.orbit.ApR > 0 && part.vessel.orbit.ApA < newApA); } break; case Operation.ELLIPTICIZE: newPeA = ARUtils.doGUITextInput("New periapsis: ", 250.0F, newPeAString, 50.0F, "km", 30.0F, out newPeAString, newPeA, 1000.0); newApA = ARUtils.doGUITextInput("New apoapsis: ", 250.0F, newApAString, 50.0F, "km", 30.0F, out newApAString, newApA, 1000.0); if (newPeA > vesselState.altitudeASL) { GUILayout.Label("Periapsis cannot be above current altitude.", yellow); } else if (newApA < vesselState.altitudeASL) { GUILayout.Label("Apoapsis cannot be below current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", ellipticizationVelocityCorrection(newPeA, newApA).magnitude))) { core.controlClaim(this); currentOperation = Operation.ELLIPTICIZE; } break; case Operation.CIRCULARIZE: if (GUILayout.Button(String.Format("Circularize at {0:0} km (Δv = {1:0} m/s)", vesselState.altitudeASL / 1000.0, circularizationVelocityCorrection().magnitude))) { core.controlClaim(this); currentOperation = Operation.CIRCULARIZE; } break; case Operation.TRANSFER_INJECTION: if (part.vessel.mainBody.orbitingBodies.Count > 0) { desiredPostTransferPeA = ARUtils.doGUITextInput("Desired final periapsis:", 250.0F, desiredPostTransferPeAString, 50.0F, "km", 30.0F, out desiredPostTransferPeAString, desiredPostTransferPeA, 1000.0); double postTransferPeR = getPredictedPostTransferPeR(); if (transferTarget != null && postTransferPeR != -1) { GUILayout.Label(String.Format("Predicted periapsis after transfer to " + transferTarget.name + ": {0:0} km", (postTransferPeR - transferTarget.Radius) / 1000.0)); } foreach (CelestialBody body in part.vessel.mainBody.orbitingBodies) { double deltaV = deltaVToChangeApoapsis(body.orbit.PeA); Orbit transferOrbit = ARUtils.computeOrbit(part.vessel, deltaV * vesselState.velocityVesselOrbitUnit, vesselState.time); double arrivalTime = vesselState.time + transferOrbit.timeToAp; Vector3d vesselArrivalPosition = transferOrbit.getAbsolutePositionAtUT(arrivalTime); Orbit targetOrbit = ARUtils.computeOrbit(body.position, (FlightGlobals.RefFrameIsRotating ? -1 : 1) * body.orbit.GetVel(), part.vessel.mainBody, vesselState.time); Vector3d targetArrivalPosition = targetOrbit.getAbsolutePositionAtUT(arrivalTime); Vector3d targetPlaneNormal = Vector3d.Cross(body.position - part.vessel.mainBody.position, body.orbit.GetVel()); Vector3d vesselArrivalPositionTargetPlane = part.vessel.mainBody.position + Vector3d.Exclude(targetPlaneNormal, vesselArrivalPosition - part.vessel.mainBody.position); double angleOffset = Math.Abs(Vector3d.Angle(targetArrivalPosition - part.vessel.mainBody.position, vesselArrivalPositionTargetPlane - part.vessel.mainBody.position)); if ( Math.Abs(Vector3d.Angle(vesselState.velocityVesselOrbitUnit, targetArrivalPosition - part.vessel.mainBody.position)) < Math.Abs(Vector3d.Angle(vesselState.velocityVesselOrbitUnit * -1, targetArrivalPosition - part.vessel.mainBody.position)) ) { angleOffset = 360.0 - angleOffset; //if we have passed the transfer point then give the user the time to loop back around the long way } angleOffset = Math.Max(angleOffset - 1.0, 0.0); //give us a 1 degree window double timeOffset = Math.Abs(angleOffset) / 360 * part.vessel.orbit.period; if (GUILayout.Button(String.Format("Transfer point to " + body.name + " in {1:0} s (Δv ≈ {0:0} m/s)", deltaV, MuUtils.ToSI(timeOffset, 1)))) { core.controlClaim(this); currentOperation = Operation.TRANSFER_INJECTION; transState = TRANSState.WAITING_FOR_INJECTION; transferTarget = body; } } if (part.vessel.orbit.eccentricity > 1.0) { GUILayout.Label("Transfer injection failed. Did you start from a circular equatorial orbit?", ARUtils.labelStyle(Color.yellow)); } } else { GUILayout.Label("No bodies orbit " + part.vessel.mainBody.name); } break; case Operation.WARP: GUILayout.BeginHorizontal(); GUILayout.Label("Warp to:"); warpPoint = (WarpPoint)GUILayout.Toolbar((int)warpPoint, warpPointStrings); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (warpPoint == WarpPoint.APOAPSIS || warpPoint == WarpPoint.PERIAPSIS) { warpTimeOffset = ARUtils.doGUITextInput("Lead time:", 150.0F, warpTimeOffsetString, 50.0F, "s", 30.0F, out warpTimeOffsetString, warpTimeOffset); } if (GUILayout.Button("Warp")) { core.controlClaim(this); FlightInputHandler.SetNeutralControls(); currentOperation = Operation.WARP; } GUILayout.EndHorizontal(); break; } GUILayout.BeginHorizontal(); String statusString = "Idle"; switch (currentOperation) { case Operation.PERIAPSIS: statusString = String.Format((raisingApsis ? "Raising" : "Lowering") + " periapsis to {0:0} km", newPeA / 1000.0); break; case Operation.APOAPSIS: statusString = String.Format((raisingApsis ? "Raising" : "Lowering") + " apoapsis to {0:0} km", newApA / 1000.0); break; case Operation.ELLIPTICIZE: statusString = String.Format("Changing orbit to {0:0}km x {1:0}km", newPeA / 1000.0, newApA / 1000.0); break; case Operation.CIRCULARIZE: statusString = String.Format("Circularizing at {0:0} km", vesselState.altitudeASL / 1000.0); break; case Operation.TRANSFER_INJECTION: statusString = "Transferring to " + transferTarget.name + "\n" + transStateStrings[(int)transState]; break; case Operation.WARP: String offsetString = ""; if (warpPoint != WarpPoint.SOI_CHANGE) { if (warpTimeOffset > 0) offsetString = "" + warpTimeOffset + "s before "; else if (warpTimeOffset < 0) offsetString = "" + Math.Abs(warpTimeOffset) + "s after "; } statusString = "Warping to " + offsetString + warpPointStrings2[(int)warpPoint]; break; } GUILayout.Label("Status: " + statusString, GUILayout.Width(200.0F)); GUIStyle abortStyle = (currentOperation == Operation.NONE ? ARUtils.buttonStyle(Color.gray) : ARUtils.buttonStyle(Color.red)); if (GUILayout.Button("Abort", abortStyle)) { endOperation(); } showHelpWindow = GUILayout.Toggle(showHelpWindow, "?", new GUIStyle(GUI.skin.button)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(); }
public WarpOrder(WarpPoint warpPoint) { Owner = Empire.Current; WarpPoint = warpPoint; }
public override void SetMap(Map map, float x, float y, int z = BaseDrawable.DEFAULT_Z) { base.SetMap(map, x, y, z); // to do WarpPoint = new WarpPoint(Id, Position + new SFML.Window.Vector2f(10F, 35F), Direction.S, Z); map.AddWarpPoint(WarpPoint); InitLockedMessage(); }
public void WarpTo(GameObject go, WarpPoint warpPoint) { if (warpPoint != null) { go.transform.position = warpPoint.transform.position; } }
public override IEnumerable <IModObject> Load(Mod mod) { foreach (var rec in DataFile.Records) { StellarObject sobj; string temp, type; int index = -1; rec.TryFindFieldValue("Physical Type", out type, ref index, Mod.Errors, 0, true); if (type == "Star" || type == "Destroyed Star") { var star = new Star(); sobj = star; rec.TryFindFieldValue(new string[] { "Size", "Star Size" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Size field for star.", Mod.CurrentFileName, rec)); continue; } StellarSize size; if (Enum.TryParse <StellarSize>(temp, out size)) { star.StellarSize = size; } else { Mod.Errors.Add(new DataParsingException("Invalid star size. Must be Tiny, Small, Medium, Large, or Huge.", Mod.CurrentFileName, rec)); } rec.TryFindFieldValue(new string[] { "Age", "Star Age" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Age field for star.", Mod.CurrentFileName, rec)); continue; } star.Age = temp; rec.TryFindFieldValue(new string[] { "Color", "Star Color" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Color field for star.", Mod.CurrentFileName, rec)); continue; } star.Color = temp; rec.TryFindFieldValue(new string[] { "Luminosity", "Star Luminosity" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Luminosity field for star.", Mod.CurrentFileName, rec)); continue; } star.Brightness = temp; if (type == "Destroyed Star") { star.IsDestroyed = true; } } else if (type == "Planet") { var planet = new Planet(); sobj = planet; rec.TryFindFieldValue(new string[] { "Size", "Planet Size" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Size field for planet.", Mod.CurrentFileName, rec)); continue; } StellarSize ss; StellarObjectSize sos = Mod.Current.StellarObjectSizes.Where(s => s.StellarObjectType == "Planet" && s.Name == temp).FirstOrDefault(); if (sos == null) { if (!Enum.TryParse <StellarSize>(temp, out ss)) { Mod.Errors.Add(new DataParsingException("Invalid planet size. Must be Tiny, Small, Medium, Large, or Huge, or a planet size entry from PlanetSize.txt.", Mod.CurrentFileName, rec)); } } else { ss = sos.StellarSize; } planet.StellarSize = ss; planet.Size = sos; rec.TryFindFieldValue(new string[] { "Physical Type", "Planet Physical Type" }, out temp, ref index, Mod.Errors, 1, true); // skip the original Physical Type field which just says it's a planet if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Physical Type field for planet.", Mod.CurrentFileName, rec)); continue; } planet.Surface = temp; rec.TryFindFieldValue(new string[] { "Atmosphere", "Planet Atmosphere" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Atmosphere field for planet.", Mod.CurrentFileName, rec)); continue; } planet.Atmosphere = temp; } else if (type == "Asteroids") { var ast = new AsteroidField(); sobj = ast; rec.TryFindFieldValue(new string[] { "Size", "Planet Size" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Size field for asteroids.", Mod.CurrentFileName, rec)); continue; } StellarSize ss; StellarObjectSize sos = Mod.Current.StellarObjectSizes.Where(s => s.StellarObjectType == "Planet" && s.Name == temp).FirstOrDefault(); if (sos == null) { if (!Enum.TryParse <StellarSize>(temp, out ss)) { Mod.Errors.Add(new DataParsingException("Invalid asteroid field size. Must be Tiny, Small, Medium, Large, or Huge, or an asteroids size entry from PlanetSize.txt.", Mod.CurrentFileName, rec)); } } else { ss = sos.StellarSize; } ast.StellarSize = ss; ast.Size = sos; rec.TryFindFieldValue(new string[] { "Physical Type", "Planet Physical Type" }, out temp, ref index, Mod.Errors, 1, true); // skip the original Physical Type field which just says it's asteroids if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Physical Type field for asteroids.", Mod.CurrentFileName, rec)); continue; } ast.Surface = temp; rec.TryFindFieldValue(new string[] { "Atmosphere", "Planet Atmosphere" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Atmosphere field for asteroids.", Mod.CurrentFileName, rec)); continue; } ast.Atmosphere = temp; rec.TryFindFieldValue(new string[] { "Combat Tile" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Combat Tile field for asteroids.", Mod.CurrentFileName, rec)); continue; } ast.CombatTile = temp; } else if (type == "Storm") { var storm = new Storm(); sobj = storm; rec.TryFindFieldValue(new string[] { "Size", "Storm Size" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Size field for storm.", Mod.CurrentFileName, rec)); continue; } StellarSize size; if (Enum.TryParse <StellarSize>(temp, out size)) { storm.StellarSize = size; } else { Mod.Errors.Add(new DataParsingException("Invalid storm size. Must be Tiny, Small, Medium, Large, or Huge.", Mod.CurrentFileName, rec)); } rec.TryFindFieldValue(new string[] { "Combat Tile" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Combat Tile field for storm.", Mod.CurrentFileName, rec)); continue; } storm.CombatTile = temp; } else if (type == "Warp Point") { var wp = new WarpPoint(); sobj = wp; rec.TryFindFieldValue(new string[] { "Size", "Warp Point Size" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Size field for warp point.", Mod.CurrentFileName, rec)); continue; } StellarSize size; if (Enum.TryParse <StellarSize>(temp, out size)) { wp.StellarSize = size; } else { Mod.Errors.Add(new DataParsingException("Invalid warp point size. Must be Tiny, Small, Medium, Large, or Huge.", Mod.CurrentFileName, rec)); } rec.TryFindFieldValue(new string[] { "One-Way", "Warp Point One-Way" }, out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find One-Way field for warp point.", Mod.CurrentFileName, rec)); continue; } bool oneway; if (bool.TryParse(temp, out oneway)) { wp.IsOneWay = oneway; } else { Mod.Errors.Add(new DataParsingException("Invalid value " + temp + " for warp point One-Way field. Must be true or false.", Mod.CurrentFileName, rec)); } rec.TryFindFieldValue("Unusual", out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Unusual field for warp point.", Mod.CurrentFileName, rec)); continue; } bool unusual; if (bool.TryParse(temp, out unusual)) { wp.IsUnusual = unusual; } else { Mod.Errors.Add(new DataParsingException("Invalid value " + temp + " for warp point Unusual field. Must be true or false.", Mod.CurrentFileName, rec)); } } else { Mod.Errors.Add(new DataParsingException("Invalid stellar object type: " + type + ".", Mod.CurrentFileName, rec)); continue; } rec.TryFindFieldValue("Picture", out temp, ref index, null, 0, true); // ignore error for now, might use Picture Num if (temp == null) { rec.TryFindFieldValue("Picture Num", out temp, ref index, Mod.Errors, 0, true); if (temp == null) { Mod.Errors.Add(new DataParsingException("Could not find Picture field or Picture Num field.", Mod.CurrentFileName, rec)); continue; } int pnum; if (!int.TryParse(temp, out pnum)) { Mod.Errors.Add(new DataParsingException("Picture Num field was not an integer.", Mod.CurrentFileName, rec)); continue; } sobj.PictureName = "p" + (pnum + 1).ToString("0000"); // to match SE4 } else { sobj.PictureName = temp; } rec.TryFindFieldValue("Description", out temp, ref index, Mod.Errors, 0, true); sobj.TemplateParameters = rec.Parameters; sobj.Description = temp; sobj.ModID = rec.Get <string>("ID", sobj); mod.StellarObjectTemplates.Add(sobj); yield return(sobj); } }
public void LoadWarpPoint(WarpPoint warpPoint) { WarpPoint = warpPoint; }
/// <summary> /// Creates a new WarpPoint with values copied from another. /// </summary> public WarpPoint(WarpPoint clone) : base(clone) { }
protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); GUIStyle normal = new GUIStyle(GUI.skin.label); GUIStyle yellow = new GUIStyle(GUI.skin.label); yellow.normal.textColor = Color.yellow; if (part.vessel.orbit.eccentricity < 1.0) { GUILayout.Label(String.Format("Current orbit: {0:0}km x {1:0}km, inclined {2:0.0}°", part.vessel.orbit.PeA / 1000.0, part.vessel.orbit.ApA / 1000.0, part.vessel.orbit.inclination)); } else { GUILayout.Label(String.Format("Current orbit: hyperbolic, Pe = {0:0}km, inclined {1:0.0}°", part.vessel.orbit.PeA / 1000.0, part.vessel.orbit.inclination)); } guiTab = (Operation)GUILayout.Toolbar((int)guiTab, guiTabStrings); switch (guiTab) { case Operation.PERIAPSIS: newPeA = ARUtils.doGUITextInput("New periapsis: ", 250.0F, newPeAString, 50.0F, "km", 30.0F, out newPeAString, newPeA, 1000.0); if (newPeA > vesselState.altitudeASL) { GUILayout.Label("Periapsis cannot be above current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", deltaVToChangePeriapsis(newPeA)))) { core.controlClaim(this); currentOperation = Operation.PERIAPSIS; raisingApsis = (part.vessel.orbit.PeA < newPeA); } break; case Operation.APOAPSIS: newApA = ARUtils.doGUITextInput("New apoapsis: ", 250.0F, newApAString, 50.0F, "km", 30.0F, out newApAString, newApA, 1000.0); if (newApA < vesselState.altitudeASL) { GUILayout.Label("Apoapsis cannot be below current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", deltaVToChangeApoapsis(newApA)))) { core.controlClaim(this); currentOperation = Operation.APOAPSIS; raisingApsis = (part.vessel.orbit.ApR > 0 && part.vessel.orbit.ApA < newApA); } break; case Operation.ELLIPTICIZE: newPeA = ARUtils.doGUITextInput("New periapsis: ", 250.0F, newPeAString, 50.0F, "km", 30.0F, out newPeAString, newPeA, 1000.0); newApA = ARUtils.doGUITextInput("New apoapsis: ", 250.0F, newApAString, 50.0F, "km", 30.0F, out newApAString, newApA, 1000.0); if (newPeA > vesselState.altitudeASL) { GUILayout.Label("Periapsis cannot be above current altitude.", yellow); } else if (newApA < vesselState.altitudeASL) { GUILayout.Label("Apoapsis cannot be below current altitude.", yellow); } else if (GUILayout.Button(String.Format("Burn (Δv = {0:0} m/s)", ellipticizationVelocityCorrection(newPeA, newApA).magnitude))) { core.controlClaim(this); currentOperation = Operation.ELLIPTICIZE; } break; case Operation.CIRCULARIZE: if (GUILayout.Button(String.Format("Circularize at {0:0} km (Δv = {1:0} m/s)", vesselState.altitudeASL / 1000.0, circularizationVelocityCorrection().magnitude))) { core.controlClaim(this); currentOperation = Operation.CIRCULARIZE; } break; case Operation.TRANSFER_INJECTION: if (part.vessel.mainBody.orbitingBodies.Count > 0) { desiredPostTransferPeA = ARUtils.doGUITextInput("Desired final periapsis:", 250.0F, desiredPostTransferPeAString, 50.0F, "km", 30.0F, out desiredPostTransferPeAString, desiredPostTransferPeA, 1000.0); if (transferTarget != null && postTransferPeR != -1) { GUILayout.Label(String.Format("Predicted periapsis after transfer to " + transferTarget.name + ": {0:0} km", (postTransferPeR - transferTarget.Radius) / 1000.0)); } foreach (CelestialBody body in part.vessel.mainBody.orbitingBodies) { if (GUILayout.Button(String.Format("Transfer to " + body.name + " (Δv ≈ {0:0} m/s)", deltaVToChangeApoapsis(body.orbit.PeA)))) { core.controlClaim(this); currentOperation = Operation.TRANSFER_INJECTION; startedTransferInjectionBurn = false; transferTarget = body; } } } else { GUILayout.Label("No bodies orbit " + part.vessel.mainBody.name); } break; case Operation.WARP: GUILayout.BeginHorizontal(); GUILayout.Label("Warp to:"); warpPoint = (WarpPoint)GUILayout.Toolbar((int)warpPoint, warpPointStrings); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (warpPoint == WarpPoint.APOAPSIS || warpPoint == WarpPoint.PERIAPSIS) { warpTimeOffset = ARUtils.doGUITextInput("Lead time:", 150.0F, warpTimeOffsetString, 50.0F, "s", 30.0F, out warpTimeOffsetString, warpTimeOffset); } if (GUILayout.Button("Warp")) { core.controlClaim(this); FlightInputHandler.SetNeutralControls(); currentOperation = Operation.WARP; } GUILayout.EndHorizontal(); break; } GUILayout.BeginHorizontal(); String statusString = "Idle"; switch (currentOperation) { case Operation.PERIAPSIS: statusString = String.Format((raisingApsis ? "Raising" : "Lowering") + " periapsis to {0:0} km", newPeA / 1000.0); break; case Operation.APOAPSIS: statusString = String.Format((raisingApsis ? "Raising" : "Lowering") + " apoapsis to {0:0} km", newApA / 1000.0); break; case Operation.ELLIPTICIZE: statusString = String.Format("Changing orbit to {0:0}km x {1:0}km", newPeA / 1000.0, newApA / 1000.0); break; case Operation.CIRCULARIZE: statusString = String.Format("Circularizing at {0:0} km", vesselState.altitudeASL / 1000.0); break; case Operation.TRANSFER_INJECTION: if (startedTransferInjectionBurn) statusString = "Injecting into transfer orbit to " + transferTarget.name; else statusString = "Waiting for injection burn point for transfer to " + transferTarget.name; break; case Operation.WARP: String offsetString = ""; if (warpPoint != WarpPoint.SOI_CHANGE) { if (warpTimeOffset > 0) offsetString = "" + warpTimeOffset + "s before "; else if (warpTimeOffset < 0) offsetString = "" + Math.Abs(warpTimeOffset) + "s after "; } statusString = "Warping to " + offsetString + warpPointStrings2[(int)warpPoint]; break; } GUILayout.Label("Status: " + statusString, GUILayout.Width(200.0F)); GUIStyle abortStyle = (currentOperation == Operation.NONE ? ARUtils.buttonStyle(Color.gray) : ARUtils.buttonStyle(Color.red)); if (GUILayout.Button("Abort", abortStyle)) { endOperation(); } showHelpWindow = GUILayout.Toggle(showHelpWindow, "?", new GUIStyle(GUI.skin.button)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(); }