FromVessel() public static method

public static FromVessel ( Vessel vessel, SharedObjects shared ) : ListValue
vessel Vessel
shared SharedObjects
return ListValue
示例#1
0
        private void InitializeSuffixes()
        {
            AddSuffix("PARTSNAMED", new OneArgsSuffix <ListValue, StringValue>(GetPartsNamed));
            AddSuffix("PARTSNAMEDPATTERN", new OneArgsSuffix <ListValue, StringValue>(GetPartsNamedPattern));
            AddSuffix("PARTSTITLED", new OneArgsSuffix <ListValue, StringValue>(GetPartsTitled));
            AddSuffix("PARTSTITLEDPATTERN", new OneArgsSuffix <ListValue, StringValue>(GetPartsTitledPattern));
            AddSuffix("PARTSDUBBED", new OneArgsSuffix <ListValue, StringValue>(GetPartsDubbed));
            AddSuffix("PARTSDUBBEDPATTERN", new OneArgsSuffix <ListValue, StringValue>(GetPartsDubbedPattern));
            AddSuffix("MODULESNAMED", new OneArgsSuffix <ListValue, StringValue>(GetModulesNamed));
            AddSuffix("PARTSINGROUP", new OneArgsSuffix <ListValue, StringValue>(GetPartsInGroup));
            AddSuffix("MODULESINGROUP", new OneArgsSuffix <ListValue, StringValue>(GetModulesInGroup));
            AddSuffix("PARTSTAGGED", new OneArgsSuffix <ListValue, StringValue>(GetPartsTagged));
            AddSuffix("PARTSTAGGEDPATTERN", new OneArgsSuffix <ListValue, StringValue>(GetPartsTaggedPattern));
            AddSuffix("ALLTAGGEDPARTS", new NoArgsSuffix <ListValue>(GetAllTaggedParts));
            AddSuffix("PARTS", new NoArgsSuffix <ListValue <PartValue> >(() => Parts));
            AddSuffix("DOCKINGPORTS", new NoArgsSuffix <ListValue <DockingPortValue> >(() => DockingPorts));
            AddSuffix(new string[] { "DECOUPLERS", "SEPARATORS" }, new NoArgsSuffix <ListValue <DecouplerValue> >(() => Decouplers));
            AddSuffix("ELEMENTS", new NoArgsSuffix <ListValue>(() => Vessel.PartList("elements", Shared)));

            AddSuffix("CONTROL", new Suffix <FlightControl>(GetFlightControl));
            AddSuffix("BEARING", new Suffix <ScalarValue>(() => VesselUtils.GetTargetBearing(CurrentVessel, Vessel)));
            AddSuffix("HEADING", new Suffix <ScalarValue>(() => VesselUtils.GetTargetHeading(CurrentVessel, Vessel)));
            AddSuffix("AVAILABLETHRUST", new Suffix <ScalarValue>(() => VesselUtils.GetAvailableThrust(Vessel)));
            AddSuffix("AVAILABLETHRUSTAT", new OneArgsSuffix <ScalarValue, ScalarValue>(GetAvailableThrustAt));
            AddSuffix("MAXTHRUST", new Suffix <ScalarValue>(() => VesselUtils.GetMaxThrust(Vessel)));
            AddSuffix("MAXTHRUSTAT", new OneArgsSuffix <ScalarValue, ScalarValue>(GetMaxThrustAt));
            AddSuffix("FACING", new Suffix <Direction>(() => VesselUtils.GetFacing(Vessel)));
            AddSuffix("BOUNDS", new Suffix <BoundsValue>(() => GetBoundsValue()));
            AddSuffix("ANGULARMOMENTUM", new Suffix <Vector>(() => new Vector(Vessel.angularMomentum)));
            AddSuffix("ANGULARVEL", new Suffix <Vector>(() => RawAngularVelFromRelative(Vessel.angularVelocity)));
            AddSuffix("MASS", new Suffix <ScalarValue>(() => Vessel.GetTotalMass()));
            AddSuffix("VERTICALSPEED", new Suffix <ScalarValue>(() => Vessel.verticalSpeed));
            AddSuffix("GROUNDSPEED", new Suffix <ScalarValue>(GetHorizontalSrfSpeed));
            AddSuffix("SURFACESPEED", new Suffix <ScalarValue>(() => { throw new KOSObsoletionException("0.18.0", "SURFACESPEED", "GROUNDSPEED", ""); }));
            AddSuffix("AIRSPEED", new Suffix <ScalarValue>(() => (Vessel.orbit.GetVel() - FlightGlobals.currentMainBody.getRFrmVel(Vessel.CoMD)).magnitude, "the velocity of the vessel relative to the air"));
            AddSuffix(new[] { "SHIPNAME", "NAME" }, new SetSuffix <StringValue>(() => Vessel.vesselName, RenameVessel, "The KSP name for a craft, cannot be empty"));
            AddSuffix("TYPE", new SetSuffix <StringValue>(() => Vessel.vesselType.ToString(), RetypeVessel, "The Ship's KSP type (e.g. rover, base, probe)"));
            AddSuffix("SENSORS", new Suffix <VesselSensors>(() => new VesselSensors(Vessel)));
            AddSuffix("TERMVELOCITY", new Suffix <ScalarValue>(() => { throw new KOSAtmosphereObsoletionException("17.2", "TERMVELOCITY", "<None>", string.Empty); }));
            AddSuffix(new[] { "DYNAMICPRESSURE", "Q" }, new Suffix <ScalarValue>(() => Vessel.dynamicPressurekPa * ConstantValue.KpaToAtm, "Dynamic Pressure in Atmospheres"));
            AddSuffix("LOADED", new Suffix <BooleanValue>(() => Vessel.loaded));
            AddSuffix("UNPACKED", new Suffix <BooleanValue>(() => !Vessel.packed));
            AddSuffix("ROOTPART", new Suffix <PartValue>(() => Root));
            AddSuffix("CONTROLPART", new Suffix <PartValue>(() => PartValueFactory.Construct(GetControlPart(), Shared)));
            AddSuffix("DRYMASS", new Suffix <ScalarValue>(() => Vessel.GetDryMass(), "The Ship's mass when empty"));
            AddSuffix("WETMASS", new Suffix <ScalarValue>(() => Vessel.GetWetMass(), "The Ship's mass when full"));
            AddSuffix("RESOURCES", new Suffix <ListValue <AggregateResourceValue> >(() => AggregateResourceValue.FromVessel(Vessel, Shared), "The Aggregate resources from every part on the craft"));
            AddSuffix("LOADDISTANCE", new Suffix <LoadDistanceValue>(() => new LoadDistanceValue(Vessel)));
            AddSuffix("ISDEAD", new NoArgsSuffix <BooleanValue>(() => (Vessel == null || Vessel.state == Vessel.State.DEAD)));
            AddSuffix("STATUS", new Suffix <StringValue>(() => Vessel.situation.ToString()));

            //// Although there is an implementation of lat/long/alt in Orbitible,
            //// it's better to use the methods for vessels that are faster if they're
            //// available:
            AddSuffix("LATITUDE", new Suffix <ScalarValue>(() => VesselUtils.GetVesselLatitude(Vessel)));
            AddSuffix("LONGITUDE", new Suffix <ScalarValue>(() => VesselUtils.GetVesselLongitude(Vessel)));
            AddSuffix("ALTITUDE", new Suffix <ScalarValue>(() => Vessel.altitude));
            AddSuffix("CREW", new NoArgsSuffix <ListValue>(GetCrew));
            AddSuffix("CREWCAPACITY", new NoArgsSuffix <ScalarValue>(GetCrewCapacity));
            AddSuffix("CONNECTION", new NoArgsSuffix <VesselConnection>(() => new VesselConnection(Vessel, Shared)));
            AddSuffix("MESSAGES", new NoArgsSuffix <MessageQueueStructure>(() => GetMessages()));

            AddSuffix("STARTTRACKING", new NoArgsVoidSuffix(StartTracking));

            AddSuffix("SOICHANGEWATCHERS", new NoArgsSuffix <UniqueSetValue <UserDelegate> >(() => Shared.DispatchManager.CurrentDispatcher.GetSOIChangeNotifyees(Vessel)));
        }
示例#2
0
        private void InitializeSuffixes()
        {
            AddSuffix("PARTSNAMED", new OneArgsSuffix <ListValue, string>(GetPartsNamed));
            AddSuffix("PARTSTITLED", new OneArgsSuffix <ListValue, string>(GetPartsTitled));
            AddSuffix("PARTSDUBBED", new OneArgsSuffix <ListValue, string>(GetPartsDubbed));
            AddSuffix("MODULESNAMED", new OneArgsSuffix <ListValue, string>(GetModulesNamed));
            AddSuffix("PARTSINGROUP", new OneArgsSuffix <ListValue, string>(GetPartsInGroup));
            AddSuffix("MODULESINGROUP", new OneArgsSuffix <ListValue, string>(GetModulesInGroup));
            AddSuffix("PARTSTAGGED", new OneArgsSuffix <ListValue, string>(GetPartsTagged));
            AddSuffix("ALLTAGGEDPARTS", new NoArgsSuffix <ListValue>(GetAllTaggedParts));
            AddSuffix("PARTS", new NoArgsSuffix <ListValue>(GetAllParts));

            AddSuffix("CONTROL", new Suffix <FlightControl>(() => FlightControlManager.GetControllerByVessel(Vessel)));
            AddSuffix("BEARING", new Suffix <float>(() => VesselUtils.GetTargetBearing(CurrentVessel, Vessel)));
            AddSuffix("HEADING", new Suffix <float>(() => VesselUtils.GetTargetHeading(CurrentVessel, Vessel)));
            AddSuffix("AVAILABLETHRUST", new Suffix <double>(() => VesselUtils.GetAvailableThrust(Vessel)));
            AddSuffix("MAXTHRUST", new Suffix <double>(() => VesselUtils.GetMaxThrust(Vessel)));
            AddSuffix("FACING", new Suffix <Direction>(() => VesselUtils.GetFacing(Vessel)));
            AddSuffix("ANGULARMOMENTUM", new Suffix <Vector>(() => new Vector(Vessel.angularMomentum)));
            AddSuffix("ANGULARVEL", new Suffix <Vector>(() => RawAngularVelFromRelative(Vessel.angularVelocity)));
            AddSuffix("MASS", new Suffix <float>(() => Vessel.GetTotalMass()));
            AddSuffix("VERTICALSPEED", new Suffix <double>(() => Vessel.verticalSpeed));
            AddSuffix("SURFACESPEED", new Suffix <double>(() => Vessel.horizontalSrfSpeed));
            AddSuffix("AIRSPEED", new Suffix <double>(() => (Vessel.orbit.GetVel() - FlightGlobals.currentMainBody.getRFrmVel(Vessel.findWorldCenterOfMass())).magnitude, "the velocity of the vessel relative to the air"));
            AddSuffix(new[] { "SHIPNAME", "NAME" }, new SetSuffix <string>(() => Vessel.vesselName, RenameVessel, "The KSP name for a craft, cannot be empty"));
            AddSuffix("TYPE", new SetSuffix <string>(() => Vessel.vesselType.ToString(), RetypeVessel, "The Ship's KSP type (e.g. rover, base, probe)"));
            AddSuffix("SENSORS", new Suffix <VesselSensors>(() => new VesselSensors(Vessel)));
            AddSuffix("TERMVELOCITY", new Suffix <double>(() => VesselUtils.GetTerminalVelocity(Vessel)));
            AddSuffix("LOADED", new Suffix <bool>(() => Vessel.loaded));
            AddSuffix("ROOTPART", new Suffix <PartValue>(() => PartValueFactory.Construct(Vessel.rootPart, Shared)));
            AddSuffix("DRYMASS", new Suffix <float>(() => Vessel.GetDryMass(), "The Ship's mass when empty"));
            AddSuffix("WETMASS", new Suffix <float>(Vessel.GetWetMass, "The Ship's mass when full"));
            AddSuffix("RESOURCES", new Suffix <ListValue <AggregateResourceValue> >(() => AggregateResourceValue.FromVessel(Vessel, Shared), "The Aggregate resources from every part on the craft"));
            AddSuffix("PACKDISTANCE", new SetSuffix <float>(
                          () => System.Math.Min(Vessel.distanceLandedPackThreshold, Vessel.distancePackThreshold),
                          value => { Vessel.distanceLandedPackThreshold = Vessel.distancePackThreshold = value; }));

            //// Although there is an implementation of lat/long/alt in Orbitible,
            //// it's better to use the methods for vessels that are faster if they're
            //// available:
            AddSuffix("LATITUDE", new Suffix <float>(() => VesselUtils.GetVesselLattitude(Vessel)));
            AddSuffix("LONGITUDE", new Suffix <double>(() => VesselUtils.GetVesselLongitude(Vessel)));
            AddSuffix("ALTITUDE", new Suffix <double>(() => Vessel.altitude));
        }