コード例 #1
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public double GetTotalCost()
        {
            if (cost == 0 || emptyCost == 0)
            {
                cost            = KCT_Utilities.GetTotalVesselCost(shipNode);
                emptyCost       = KCT_Utilities.GetTotalVesselCost(shipNode, false);
                integrationCost = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);
            }

            return(cost + integrationCost);
        }
コード例 #2
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public KCT_BuildListVessel NewCopy(bool RecalcTime)
        {
            KCT_BuildListVessel ret = new KCT_BuildListVessel(this.shipName, this.launchSite, this.effectiveCost, this.buildPoints, this.integrationPoints, this.flag, this.cost, this.integrationCost, (int)GetEditorFacility());

            ret.shipNode = this.shipNode.CreateCopy();

            //refresh all inventory parts to new
            for (int i = ret.ExtractedPartNodes.Count - 1; i >= 0; i--)
            {
                ConfigNode part = ret.ExtractedPartNodes[i];

                //foreach (ConfigNode part in ret.ExtractedPartNodes)
                //{
                ScrapYardWrapper.RefreshPart(part);
            }

            ret.id              = Guid.NewGuid();
            ret.TotalMass       = this.TotalMass;
            ret.emptyMass       = this.emptyMass;
            ret.cost            = this.cost;
            ret.integrationCost = this.integrationCost;
            ret.emptyCost       = this.emptyCost;
            ret.numStageParts   = this.numStageParts;
            ret.numStages       = this.numStages;
            ret.stagePartCost   = this.stagePartCost;

            if (RecalcTime)
            {
                ret.effectiveCost     = KCT_Utilities.GetEffectiveCost(ret.ExtractedPartNodes);
                ret.buildPoints       = KCT_Utilities.GetBuildTime(ret.effectiveCost);
                ret.integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(ret);
                ret.integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(ret);
            }

            return(ret);
        }
コード例 #3
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public KCT_BuildListVessel(Vessel vessel, KCT_BuildListVessel.ListType listType = ListType.None) //For recovered vessels
        {
            id       = Guid.NewGuid();
            shipName = vessel.vesselName;
            shipNode = FromInFlightVessel(vessel, listType);
            if (listType != ListType.None)
            {
                this.type = listType;
            }

            cost      = KCT_Utilities.GetTotalVesselCost(shipNode);
            emptyCost = KCT_Utilities.GetTotalVesselCost(shipNode, false);
            TotalMass = 0;
            emptyMass = 0;

            HashSet <int> stages = new HashSet <int>();

            //for (int i = vessel.protoVessel.protoPartSnapshots.Count - 1; i >= 0; i--)
            //{
            //    ProtoPartSnapshot p = vessel.protoVessel.protoPartSnapshots[i];

            foreach (ProtoPartSnapshot p in vessel.protoVessel.protoPartSnapshots)
            {
                stages.Add(p.inverseStageIndex);

                if (p.partPrefab != null && p.partPrefab.Modules.Contains <LaunchClamp>())
                {
                    continue;
                }

                TotalMass += p.mass;
                emptyMass += p.mass;
                //for (int i1 = p.resources.Count - 1; i1 >= 0; i1--)
                //{
                //    ProtoPartResourceSnapshot rsc = p.resources[i1];

                foreach (ProtoPartResourceSnapshot rsc in p.resources)
                {
                    PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(rsc.resourceName);
                    if (def != null)
                    {
                        TotalMass += def.density * (float)rsc.amount;
                    }
                }
            }
            cannotEarnScience = true;
            numStages         = stages.Count;
            // FIXME ignore stageable part count and cost - it'll be fixed when we put this back in the editor.

            effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList());
            buildPoints   = KCT_Utilities.GetBuildTime(effectiveCost);
            flag          = HighLogic.CurrentGame.flagURL;

            DistanceFromKSC = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude));

            rushBuildClicks   = 0;
            integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this);
            integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);

            progress = buildPoints + integrationPoints;
        }
コード例 #4
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public KCT_BuildListVessel(ShipConstruct s, String ls, double effCost, double bP, String flagURL)
        {
            ship     = s;
            shipNode = s.SaveShip();
            shipName = s.shipName;
            //Get total ship cost
            float fuel;

            cost      = s.GetShipCosts(out emptyCost, out fuel);
            TotalMass = s.GetShipMass(true, out emptyMass, out fuel);

            HashSet <int> stages = new HashSet <int>();

            numStageParts = 0;
            stagePartCost = 0d;
            //for (int i = s.Parts.Count - 1; i >= 0; i--)
            //{
            //    Part p = s.Parts[i];

            foreach (Part p in s.Parts)
            {
                if (p.stagingOn)
                {
                    stages.Add(p.inverseStage);
                    ++numStageParts;
                    stagePartCost += p.GetModuleCosts(p.partInfo.cost, ModifierStagingSituation.CURRENT) + p.partInfo.cost;
                }
            }
            numStages = stages.Count;

            launchSite    = ls;
            effectiveCost = effCost;
            buildPoints   = bP;
            progress      = 0;
            flag          = flagURL;
            if (s.shipFacility == EditorFacility.VAB)
            {
                type = ListType.VAB;
            }
            else if (s.shipFacility == EditorFacility.SPH)
            {
                type = ListType.SPH;
            }
            else
            {
                type = ListType.None;
            }
            id = Guid.NewGuid();
            cannotEarnScience = false;

            //get the crew from the editorlogic
            DesiredManifest = new List <string>();
            if (CrewAssignmentDialog.Instance?.GetManifest()?.CrewCount > 0)
            {
                //var pcm = CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List<ProtoCrewMember>();
                //for (int i = pcm.Count - 1; i >= 0; i--)
                //{
                //    ProtoCrewMember crew = pcm[i];
                foreach (ProtoCrewMember crew in CrewAssignmentDialog.Instance.GetManifest().GetAllCrew(true) ?? new List <ProtoCrewMember>())
                {
                    DesiredManifest.Add(crew?.name ?? string.Empty);
                }
            }

            if (effectiveCost == default(double))
            {
                // Can only happen in older saves that didn't have Effective cost persisted as a separate field
                // This code should be safe to remove after a while.
                effectiveCost = KCT_Utilities.GetEffectiveCost(shipNode.GetNodes("PART").ToList());
            }

            integrationPoints = KCT_MathParsing.ParseIntegrationTimeFormula(this);
            integrationCost   = (float)KCT_MathParsing.ParseIntegrationCostFormula(this);
        }