Inheritance: kOS.SpecialValue
コード例 #1
0
        private ElementValue GetEelement()
        {
            var elList = shared.KSPPart.vessel.PartList("elements", shared);
            var part   = VesselTarget.CreateOrGetExisting(shared)[shared.KSPPart];

            return(elList.Cast <ElementValue>().FirstOrDefault(el => el.Parts.Contains(part)));
        }
コード例 #2
0
 private void InitializeSuffixes()
 {
     AddSuffix("VERSION", new Suffix <VersionInfo>(() => VersionInfo));
     AddSuffix("VESSEL", new Suffix <VesselTarget>(() => VesselTarget.CreateOrGetExisting(shared.KSPPart.vessel, shared)));
     AddSuffix("ELEMENT", new Suffix <ElementValue>(GetEelement));
     AddSuffix("CURRENTVOLUME", new Suffix <Volume>(GetCurrentVolume, "The currently selected volume"));
     AddSuffix("MESSAGES", new NoArgsSuffix <MessageQueueStructure>(() => new MessageQueueStructure(processor.Messages, shared),
                                                                    "This processor's message queue"));
 }
コード例 #3
0
ファイル: FunctionList.cs プロジェクト: erendrake/kRISC
        private kList GetTargetList(SharedObjects shared)
        {
            kList list = new kList();

            list.AddColumn("Vessel Name", 25, ColumnAlignment.Left);
            list.AddColumn("Distance", 12, ColumnAlignment.Right, "0.0");

            double commRange = VesselUtils.GetCommRange(shared.Vessel);

            foreach (Vessel vessel in FlightGlobals.Vessels)
            {
                if (vessel != shared.Vessel)
                {
                    var vT = new VesselTarget(vessel, shared.Vessel);
                    if (vT.IsInRange(commRange))
                    {
                        list.AddItem(vT.target.vesselName, vT.GetDistance());
                    }
                }
            }

            return(list);
        }
コード例 #4
0
        private bool TryParseVessel(string text)
        {
            Match match = Regex.Match(text, "^VESSEL\\(([ @A-Za-z0-9\"]+)\\)$");
            if (match.Success)
            {
                var input = ParseSubExpressionAsString(match.Groups[1].Value.Trim());

                Value = new VesselTarget(VesselUtils.GetVesselByName(input, executionContext.Vessel), executionContext); // Will throw if not found
                return true;
            }

            return false;
        }
コード例 #5
0
ファイル: Function.cs プロジェクト: erendrake/kRISC
 public override void Execute(SharedObjects shared)
 {
     string vesselName = shared.Cpu.PopValue().ToString();            
     VesselTarget result = new VesselTarget(VesselUtils.GetVesselByName(vesselName, shared.Vessel), null);
     shared.Cpu.PushStack(result);
 }
コード例 #6
0
        public override void Evaluate()
        {
            switch (RegexMatch.Groups[1].Value.ToUpper())
            {

                case "BODIES":
                    StdOut("");
                    StdOut("Name           Distance");
                    StdOut("-------------------------------------");
                    foreach (var body in FlightGlobals.fetch.bodies)
                    {
                        StdOut(body.bodyName.PadLeft(14) + " " + Vector3d.Distance(body.position, Vessel.GetWorldPos3D()));
                    }
                    StdOut("");

                    break;

                case "TARGETS":
                    StdOut("");
                    StdOut("Vessel Name              Distance");
                    StdOut("-------------------------------------");

                    float commRange = VesselUtils.GetCommRange(Vessel);

                    foreach (Vessel vessel in FlightGlobals.Vessels)
                    {
                        if (vessel != Vessel)
                        {
                            var vT = new VesselTarget(vessel, this);
                            if (vT.IsInRange(commRange))
                            {
                                StdOut(vT.target.vesselName.PadRight(24) + " " + vT.GetDistance().ToString("0.0").PadLeft(8));
                            }
                        }
                    }

                    StdOut("");

                    break;

                case "RESOURCES":
                    StdOut("");
                    StdOut("Stage      Resource Name               Amount");
                    StdOut("------------------------------------------------");

                    foreach (Part part in Vessel.Parts)
                    {
                        String stageStr = part.inverseStage.ToString();

                        foreach (PartResource resource in part.Resources)
                        {
                            StdOut(part.inverseStage.ToString() + " " + resource.resourceName.PadRight(20) + " " + resource.amount.ToString("0.00").PadLeft(8));
                        }
                    }
                    break;

                case "PARTS":
                    StdOut("------------------------------------------------");

                    foreach (Part part in Vessel.Parts)
                    {
                        StdOut(part.ConstructID + " " + part.partInfo.name);
                    }

                    break;

                case "ENGINES":
                    StdOut("------------------------------------------------");

                    foreach (Part part in VesselUtils.GetListOfActivatedEngines(Vessel))
                    {
                        foreach (PartModule module in part.Modules)
                        {
                            if (module is ModuleEngines)
                            {
                                var engineMod = (ModuleEngines)module;

                                StdOut(part.uid + "  " + part.inverseStage.ToString() + " " + engineMod.moduleName);
                            }
                        }
                    }

                    break;
            }

            State = ExecutionState.DONE;
        }
コード例 #7
0
ファイル: CommandVessel.cs プロジェクト: civilwargeeky/KOS
        public override void Evaluate()
        {
            switch (RegexMatch.Groups[1].Value.ToUpper())
            {
            case "BODIES":
                StdOut("");
                StdOut("Name           Distance");
                StdOut("-------------------------------------");
                foreach (var body in FlightGlobals.fetch.bodies)
                {
                    StdOut(body.bodyName.PadLeft(14) + " " + Vector3d.Distance(body.position, Vessel.GetWorldPos3D()));
                }
                StdOut("");

                break;


            case "TARGETS":
                StdOut("");
                StdOut("Vessel Name              Distance");
                StdOut("-------------------------------------");

                float commRange = VesselUtils.GetCommRange(Vessel);

                foreach (Vessel vessel in FlightGlobals.Vessels)
                {
                    if (vessel != Vessel)
                    {
                        var vT = new VesselTarget(vessel, this);
                        if (vT.IsInRange(commRange))
                        {
                            StdOut(vT.target.vesselName.PadRight(24) + " " + vT.GetDistance().ToString("0.0").PadLeft(8));
                        }
                    }
                }

                StdOut("");

                break;

            case "RESOURCES":
                StdOut("");
                StdOut("Stage      Resource Name               Amount");
                StdOut("------------------------------------------------");

                foreach (Part part in Vessel.Parts)
                {
                    String stageStr = part.inverseStage.ToString();

                    foreach (PartResource resource in part.Resources)
                    {
                        StdOut(part.inverseStage.ToString() + " " + resource.resourceName.PadRight(20) + " " + resource.amount.ToString("0.00").PadLeft(8));
                    }
                }
                break;

            case "PARTS":
                StdOut("------------------------------------------------");

                foreach (Part part in Vessel.Parts)
                {
                    StdOut(part.ConstructID + " " + part.partInfo.name);
                }

                break;

            case "ENGINES":
                StdOut("------------------------------------------------");

                foreach (Part part in VesselUtils.GetListOfActivatedEngines(Vessel))
                {
                    foreach (PartModule module in part.Modules)
                    {
                        if (module is ModuleEngines)
                        {
                            var engineMod = (ModuleEngines)module;

                            StdOut(part.uid + "  " + part.inverseStage.ToString() + " " + engineMod.moduleName);
                        }
                    }
                }

                break;
            }

            State = ExecutionState.DONE;
        }