public MessageStructure(Message message, SharedObjects shared) { Message = message; this.shared = shared; InitializeSuffixes(); }
public override void Execute(SharedObjects shared) { object arg3 = PopValueAssert(shared, true); object arg2 = PopValueAssert(shared, true); object arg1 = PopValueAssert(shared, true); AssertArgBottomAndConsume(shared); string fromName, toName; if (arg2.ToString() == "from") { fromName = arg3.ToString() + ":/" + arg1.ToString(); toName = ""; } else { fromName = arg1.ToString(); toName = arg3.ToString() + ":/" + fromName; } shared.Logger.LogWarningAndScreen( string.Format( "WARNING: COPY {0} {1} {2} is deprecated as of kOS v1.0.0. Use COPYPATH(\"{3}\", \"{4}\") instead.", arg1.ToString(), arg2.ToString(), arg3.ToString(), fromName, toName)); // Redirect into a call to the copypath function, so as to keep all // the copy file logic there in one unified location. This is slightly slow, // but we don't care because this is just to support deprecation: shared.Cpu.PushStack(new kOS.Safe.Execution.KOSArgMarkerType()); shared.Cpu.PushStack(fromName); shared.Cpu.PushStack(toName); shared.Cpu.CallBuiltinFunction("copypath"); }
public override void Execute(SharedObjects shared) { AssertArgBottomAndConsume(shared); // no args // ReSharper disable SuggestUseVarKeywordEvident ListValue<WaypointValue> returnList = new ListValue<WaypointValue>(); // ReSharper enable SuggestUseVarKeywordEvident WaypointManager wpm = WaypointManager.Instance(); if (wpm == null) { ReturnValue = returnList; // When no waypoints exist, there isn't even a waypoint manager at all. return; } List<Waypoint> points = wpm.Waypoints; // If the code below gets used in more places it may be worth moving into a factory method // akin to how PartValueFactory makes a ListValue<PartValue> from a List<Part>. // But for now, this is the only place it's done: foreach (Waypoint point in points) returnList.Add(new WaypointValue(point, shared)); ReturnValue = returnList; }
public OrbitInfo( Orbit orb, SharedObjects sharedObj) : this() { Shared = sharedObj; orbit = orb; name = "<unnamed>"; }
public override void Execute(SharedObjects shared) { int remaining = CountRemainingArgs(shared); VolumeDirectory directory; if (remaining == 0) { directory = shared.VolumeMgr.CurrentVolume.Root; } else { object pathObject = PopValueAssert(shared, true); GlobalPath path = shared.VolumeMgr.GlobalPathFromObject(pathObject); Volume volume = shared.VolumeMgr.GetVolumeFromPath(path); directory = volume.Open(path) as VolumeDirectory; if (directory == null) { throw new KOSException("Invalid directory: " + pathObject); } } AssertArgBottomAndConsume(shared); shared.VolumeMgr.CurrentDirectory = directory; }
public OrbitInfo(Orbitable orb, SharedObjects sharedObj) : this() { orbit = orb.Orbit; Shared = sharedObj; name = orb.GetName(); }
public override void Execute(SharedObjects shared) { string bodyName = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); var result = new BodyTarget(bodyName, shared); ReturnValue = result; }
/// <summary> /// Build a GeoCoordinates from any arbitrary lat/long pair of floats. /// </summary> /// <param name="body">A different celestial body to select a lat/long for that might not be the current one</param> /// <param name="sharedObj">to know the current CPU's running vessel</param> /// <param name="latitude">latitude</param> /// <param name="longitude">longitude</param> public GeoCoordinates(CelestialBody body, SharedObjects sharedObj, double latitude, double longitude) : this() { Latitude = latitude; Longitude = longitude; Shared = sharedObj; Body = body; }
/// <summary> /// Build a GeoCoordinates from the current lat/long of the orbitable /// object passed in. The object being checked for should be in the same /// SOI as the vessel running the CPU or the results are meaningless. /// </summary> /// <param name="orb">object to take current coords of</param> /// <param name="sharedObj">to know the current CPU's running vessel</param> public GeoCoordinates(Orbitable orb, SharedObjects sharedObj) : this() { Shared = sharedObj; Vector p = orb.GetPosition(); Latitude = orb.PositionToLatitude(p); Longitude = orb.PositionToLongitude(p); Body = orb.GetParentBody(); }
public override void Execute(SharedObjects shared) { Vector axisVector = GetVector(PopValueAssert(shared)); double degrees = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = Direction.AngleAxis(degrees, axisVector); ReturnValue = result; }
public MessageQueueStructure GetQueue(Vessel vessel, SharedObjects sharedObjects) { string vesselId = vessel.id.ToString(); if (!vesselQueues.ContainsKey(vesselId)) { vesselQueues.Add(vesselId, new MessageQueue()); } return new MessageQueueStructure(vesselQueues[vesselId], sharedObjects); }
public VectorRenderer( UpdateHandler updateHand, SharedObjects shared ) { Vector = new Vector3d(0,0,0); Color = new RgbaColor(1,1,1); Start = new Vector3d(0,0,0); Scale = 1.0; Width = 0; updateHandler = updateHand; this.shared = shared; InitializeSuffixes(); }
public override void Execute(SharedObjects shared) { bool echo = Convert.ToBoolean(PopValueAssert(shared)); RgbaColor rgba = GetRgba(PopValueAssert(shared)); int size = Convert.ToInt32(PopValueAssert(shared)); int style = Convert.ToInt32(PopValueAssert(shared)); int delay = Convert.ToInt32(PopValueAssert(shared)); string textToHud = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); string htmlColour = rgba.ToHexNotation(); switch (style) { case 1: ScreenMessages.PostScreenMessage("<color=" + htmlColour + "><size=" + size + ">" + textToHud + "</size></color>", delay, ScreenMessageStyle.UPPER_LEFT); break; case 2: ScreenMessages.PostScreenMessage("<color=" + htmlColour + "><size=" + size + ">" + textToHud + "</size></color>", delay, ScreenMessageStyle.UPPER_CENTER); break; case 3: ScreenMessages.PostScreenMessage("<color=" + htmlColour + "><size=" + size + ">" + textToHud + "</size></color>", delay, ScreenMessageStyle.UPPER_RIGHT); break; case 4: ScreenMessages.PostScreenMessage("<color=" + htmlColour + "><size=" + size + ">" + textToHud + "</size></color>", delay, ScreenMessageStyle.LOWER_CENTER); break; default: ScreenMessages.PostScreenMessage("*" + textToHud, 3f, ScreenMessageStyle.UPPER_CENTER); break; } if (echo) { shared.Screen.Print("HUD: " + textToHud); } }
public override void Execute(SharedObjects shared) { var transferTo = PopValueAssert(shared); var transferFrom = PopValueAssert(shared); var resourceName = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); var resourceInfo = TransferManager.ParseResource(resourceName); if (resourceInfo == null) { throw new KOSInvalidArgumentException("TransferAll", "Resource", resourceName + " was not found in the resource list"); } object toPush = shared.TransferManager.CreateTransfer(resourceInfo, transferTo, transferFrom); ReturnValue = toPush; }
public override void Execute(SharedObjects shared) { Vector topVector = GetVector(PopValueAssert(shared)); Vector lookVector = GetVector(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = Direction.LookRotation(lookVector, topVector); ReturnValue = result; }
public override void Execute(SharedObjects shared) { double roll = GetDouble(PopValueAssert(shared)); double yaw = GetDouble(PopValueAssert(shared)); double pitch = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = new Direction(new Vector3d(pitch, yaw, roll), true); ReturnValue = result; }
public override void Execute(SharedObjects shared) { Structure[] argArray = new Structure[CountRemainingArgs(shared)]; for (int i = argArray.Length - 1 ; i >= 0 ; --i) argArray[i] = PopStructureAssertEncapsulated(shared); // fill array in reverse order because .. stack args. AssertArgBottomAndConsume(shared); var stackValue = new StackValue(argArray.ToList()); ReturnValue = stackValue; }
public override void Execute(SharedObjects shared) { Vector toVector = GetVector(PopValueAssert(shared)); Vector fromVector = GetVector(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = Direction.FromVectorToVector(fromVector, toVector); ReturnValue = result; }
public override void Execute(SharedObjects shared) { var a = (float) GetDouble(PopValueAssert(shared)); var b = (float) GetDouble(PopValueAssert(shared)); var g = (float) GetDouble(PopValueAssert(shared)); var r = (float) GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); ReturnValue = new RgbaColor(r,g,b,a); }
public void DoExecuteWork(SharedObjects shared, Vector start, Vector vec, RgbaColor rgba, string str, double scale, bool show, double width) { var vRend = new VectorRenderer( shared.UpdateHandler, shared ) { Vector = vec, Start = start, Color = rgba, Scale = scale, Width = width }; vRend.SetLabel( str ); vRend.SetShow( show ); ReturnValue = vRend; }
public override void Execute(SharedObjects shared) { double z = GetDouble(PopValueAssert(shared)); double y = GetDouble(PopValueAssert(shared)); double x = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = new Vector(x, y, z); ReturnValue = result; }
public override void Execute(SharedObjects shared) { string vesselName = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); var result = new VesselTarget(VesselUtils.GetVesselByName(vesselName, shared.Vessel), shared); ReturnValue = result; }
public override void Execute(SharedObjects shared) { int argc = CountRemainingArgs(shared); // Handle the var args that might be passed in, or give defaults if fewer args: double width = (argc >= 7) ? GetDouble(PopValueAssert(shared)) : 0.2; bool show = (argc >= 6) ? Convert.ToBoolean(PopValueAssert(shared)) : false; double scale = (argc >= 5) ? GetDouble(PopValueAssert(shared)) : 1.0; string str = (argc >= 4) ? PopValueAssert(shared).ToString() : ""; RgbaColor rgba = (argc >= 3) ? GetRgba(PopValueAssert(shared)) : new RgbaColor(1.0f, 1.0f, 1.0f); Vector vec = (argc >= 2) ? GetVector(PopValueAssert(shared)) : new Vector(1.0, 0.0, 0.0); Vector start = (argc >= 1) ? GetVector(PopValueAssert(shared)) : new Vector(0.0, 0.0, 0.0); AssertArgBottomAndConsume(shared); DoExecuteWork(shared, start, vec, rgba, str, scale, show, width); }
public override void Execute(SharedObjects shared) { double prograde = GetDouble(PopValueAssert(shared)); double normal = GetDouble(PopValueAssert(shared)); double radial = GetDouble(PopValueAssert(shared)); double time = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = new Node(time, radial, normal, prograde, shared); ReturnValue = result; }
public override void Execute(SharedObjects shared) { var when = GetTimeSpan(PopValueAssert(shared)); var what = GetOrbitable(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); ReturnValue = what.GetVelocitiesAtUT(when); }
public override void Execute(SharedObjects shared) { var when = GetTimeSpan(PopValueAssert(shared)); var what = GetOrbitable(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); ReturnValue = new OrbitInfo( what.GetOrbitAtUT(when.ToUnixStyleTime()), shared ); }
public override void Execute(SharedObjects shared) { string pointName = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); WaypointManager wpm = WaypointManager.Instance(); // If no contracts have been generated with waypoints in them, // then sometimes the stock game's waypoint manager doesn't even // exist yet either. (The base game seems not to instance one until the // first time a contract with a waypoint is created). if (wpm == null) throw new KOSInvalidArgumentException("waypoint", "\""+pointName+"\"", "no waypoints exist"); string baseName; int index; bool hasGreek = WaypointValue.GreekToInteger(pointName, out index, out baseName); if (hasGreek) pointName = baseName; Waypoint point = wpm.Waypoints.FirstOrDefault( p => string.Equals(p.name, pointName,StringComparison.CurrentCultureIgnoreCase) && (!hasGreek || p.index == index)); // We can't communicate the concept of a lookup fail to the script in a way it can catch (can't do // nulls), so bomb out here: if (point ==null) throw new KOSInvalidArgumentException("waypoint", "\""+pointName+"\"", "no such waypoint"); ReturnValue = new WaypointValue(point, shared); }
public override void Execute(SharedObjects shared) { double angle = GetDouble(PopValueAssert(shared)); double roll = GetDouble(PopValueAssert(shared)); double yaw = GetDouble(PopValueAssert(shared)); double pitch = GetDouble(PopValueAssert(shared)); AssertArgBottomAndConsume(shared); var result = new Direction(new UnityEngine.Quaternion((float)pitch, (float)yaw, (float)roll, (float)angle)); ReturnValue = result; }
public override void Execute(SharedObjects shared) { string bodyName = PopValueAssert(shared).ToString(); AssertArgBottomAndConsume(shared); var result = new BodyAtmosphere(VesselUtils.GetBodyByName(bodyName)); ReturnValue = result; }
public override void Execute(SharedObjects shared) { // Default values for parameters int from = RangeValue.DEFAULT_START; int to = RangeValue.DEFAULT_STOP; int step = RangeValue.DEFAULT_STEP; int argCount = CountRemainingArgs(shared); // assign parameter values from the stack, pop them in reverse order switch (argCount) { case 1: to = GetInt(PopStructureAssertEncapsulated(shared)); break; case 2: to = GetInt(PopStructureAssertEncapsulated(shared)); from = GetInt(PopStructureAssertEncapsulated(shared)); break; case 3: step = GetInt(PopStructureAssertEncapsulated(shared)); to = GetInt(PopStructureAssertEncapsulated(shared)); from = GetInt(PopStructureAssertEncapsulated(shared)); break; default: throw new KOSArgumentMismatchException(new int[] { 1, 2, 3 }, argCount, "Thrown from function RANGE()"); } AssertArgBottomAndConsume(shared); ReturnValue = new RangeValue(from, to, step); }