Exemplo n.º 1
0
        private IEnumerator WaitAndRebuildList(ShipConstruct ship)
        {
            while (--rebuild_list_wait_frames > 0)
            {
                yield return(null);
            }

            buildCost   = null;
            cashed_cost = null;
            parts_count = 0;

            if (ship == null || ship.parts == null || ship.parts.Count < 1 ||
                ship.parts[0] == null)
            {
                yield break;
            }

            if (ship.parts.Count > 0)
            {
                Part root = ship.parts[0].localRoot;

                buildCost = new BuildCost();
                addPart(root);
                foreach (Part p in root.GetComponentsInChildren <Part>())
                {
                    if (p != root)
                    {
                        addPart(p);
                    }
                }
            }
            cashed_cost = buildCost.cost;
        }
Exemplo n.º 2
0
        List <BuildResource> PartResources(Part p)
        {
            Debug.Log(String.Format("[EL RSM] PartResources: {0} {1}", p.name, p.CrewCapacity));
            var bc = new BuildCost();

            bc.addPart(p);
            var  rd   = new BuildResourceSet();
            bool xfer = true;

            VesselResources.ResourceProcessor process = delegate(VesselResources vr, string res) {
                ProcessResource(vr, res, rd, xfer);
            };
            bc.resources.Process(process);
            var reslist = rd.Values;

            rd.Clear();
            bc.container.Process(process);
            reslist.AddRange(rd.Values);
            rd.Clear();
            xfer = false;
            bc.hullResoures.Process(process);
            reslist.AddRange(rd.Values);
            if (p.CrewCapacity > 0 && !p.name.Contains("kerbalEVA"))
            {
                rd.Clear();
                for (int i = 0; i < p.protoModuleCrew.Count; i++)
                {
                    var crew = p.protoModuleCrew[i];
                    ProcessKerbal(crew, rd);
                }
                reslist.AddRange(rd.Values);
            }
            return(reslist);
        }
        public CostReport getBuildCost(ConfigNode craft)
        {
            lockedParts = false;
            ShipConstruct ship = new ShipConstruct();

            if (!ship.LoadShip(craft))
            {
                return(null);
            }
            if (!ship.shipPartsUnlocked)
            {
                lockedParts = true;
            }
            GameObject ro          = ship.parts[0].localRoot.gameObject;
            Vessel     craftVessel = ro.AddComponent <Vessel>();

            craftVessel.vesselName = "EL craftVessel - " + craft.GetValue("ship");
            craftVessel.Initialize(true);
            foreach (Part part in craftVessel.parts)
            {
                part.ModulesOnStart();
            }
            if (ELSettings.B9Wings_Present)
            {
                if (!InitializeB9Wings(craftVessel) &&
                    ELSettings.FAR_Present)
                {
                    InitializeFARSurfaces(craftVessel);
                }
            }
            else if (ELSettings.FAR_Present)
            {
                InitializeFARSurfaces(craftVessel);
            }

            // needed for displaying optional resources during the planning
            // stage.
            craftResources = new RMResourceSet(craftVessel);

            BuildCost resources = new BuildCost();

            foreach (Part p in craftVessel.parts)
            {
                resources.addPart(p);
            }
            craftVessel.Die();

            return(resources.cost);
        }
		private IEnumerator WaitAndRebuildList (ShipConstruct ship)
		{
			yield return null;

			buildCost = null;
			parts_count = 0;

			if (ship == null || ship.parts == null || ship.parts.Count < 1
				|| ship.parts[0] == null) {
				yield break;
			}

			if (ship.parts.Count > 0) {
				Part root = ship.parts[0].localRoot;

				buildCost = new BuildCost ();
				addPart (root);
				foreach (Part p in root.GetComponentsInChildren<Part>()) {
					if (p != root) {
						addPart (p);
					}
				}
			}
		}
		public CostReport getBuildCost (ConfigNode craft)
		{
			lockedParts = false;
			ShipConstruct ship = new ShipConstruct ();
			if (!ship.LoadShip (craft)) {
				return null;
			}
			if (!ship.shipPartsUnlocked) {
				lockedParts = true;
			}
			GameObject ro = ship.parts[0].localRoot.gameObject;
			Vessel craftVessel = ro.AddComponent<Vessel>();
			craftVessel.Initialize (true);
			if (ExSettings.B9Wings_Present) {
				if (!InitializeB9Wings (craftVessel)
					&& ExSettings.FAR_Present) {
					InitializeFARSurfaces (craftVessel);
				}
			} else if (ExSettings.FAR_Present) {
				InitializeFARSurfaces (craftVessel);
			}

			// needed for displaying optional resources during the planning
			// stage.
			craftResources = new VesselResources (craftVessel);

			BuildCost resources = new BuildCost ();

			foreach (Part p in craftVessel.parts) {
				resources.addPart (p);
			}
			craftVessel.Die ();

			return resources.cost;
		}
Exemplo n.º 6
0
        public CostReport getBuildCost(ConfigNode craft, string craftText = null)
        {
            lockedParts = false;
            ShipConstruct ship = new ShipConstruct();

            if (!ship.LoadShip(craft))
            {
                lockedParts = true;
                return(null);
            }
            if (ship.vesselDeltaV != null)
            {
                // The delta-v module is not needed. It has its own gameObject
                // for ShipConstruct.
                UnityEngine.Object.Destroy(ship.vesselDeltaV.gameObject);
                ship.vesselDeltaV = null;
            }
            if (!ship.shipPartsUnlocked)
            {
                lockedParts = true;
            }
            GameObject ro          = ship.parts[0].localRoot.gameObject;
            Vessel     craftVessel = ro.AddComponent <Vessel>();

            craftVessel.vesselName = "EL craftVessel - " + craft.GetValue("ship");
            craftVessel.Initialize(true);
            SetCraftOrbit(craftVessel, OrbitDriver.UpdateMode.IDLE);
            foreach (Part part in craftVessel.parts)
            {
                SanitizePart(part);
                part.ModulesOnStart();
            }

            if (ELSettings.B9Wings_Present)
            {
                if (!InitializeB9Wings(craftVessel) &&
                    ELSettings.FAR_Present)
                {
                    InitializeFARSurfaces(craftVessel);
                }
            }
            else if (ELSettings.FAR_Present)
            {
                InitializeFARSurfaces(craftVessel);
            }

            BuildCost resources = new BuildCost();

            foreach (Part p in craftVessel.parts)
            {
                resources.addPart(p);
            }

            if (craftText != null && ELSettings.ShowCraftHull)
            {
                Quickhull.dump_points = ELSettings.DebugCraftHull;
                Quickhull.points_path = savesPath;
                DestroyCraftHull();
                craftHull = new CraftHull(craftText);
                // GetVesselBox will rotate and minimize any launchclamps,
                // which is probably a good thing.
                var rootPart = ship.parts[0].localRoot;
                var rootPos  = rootPart.transform.position;
                craftHull.SetBox(GetVesselBox(ship), rootPos);
                builder.SetShipTransform(rootPart.transform, rootPart);
                craftHull.SetTransform(rootPart.transform);
                if (ELSettings.DebugCraftHull ||
                    !craftHull.LoadHull(savesPath))
                {
                    craftHull.BuildConvexHull(craftVessel);
                    craftHull.SaveHull(savesPath);
                }
            }

            craftVessel.Die();

            return(resources.cost);
        }
 void onEditorRestart()
 {
     buildCost   = null;
     cashed_cost = null;
     parts_count = 0;
 }
        public CostReport getBuildCost(ConfigNode craft)
        {
            lockedParts = false;
            ShipConstruct ship = new ShipConstruct ();
            if (!ship.LoadShip (craft)) {
                return null;
            }
            if (!ship.shipPartsUnlocked) {
                lockedParts = true;
            }
            GameObject ro = ship.parts[0].localRoot.gameObject;
            Vessel dummy = ro.AddComponent<Vessel>();
            dummy.Initialize (true);
            if (ExSettings.B9Wings_Present) {
                if (!InitializeB9Wings (dummy) && ExSettings.FAR_Present) {
                    InitializeFARSurfaces (dummy);
                }
            } else if (ExSettings.FAR_Present) {
                InitializeFARSurfaces (dummy);
            }
            if (ExSettings.KAS_Present) {
                InitializeKASContainers (dummy);
            }

            craftResources = new VesselResources (dummy);

            BuildCost resources = new BuildCost ();

            foreach (Part p in ship.parts) {
                resources.addPart (p);
            }
            dummy.Die ();

            return resources.cost;
        }
		List<BuildResource> PartResources (Part p)
		{
			Debug.Log (String.Format ("[EL RSM] PartResources: {0} {1}", p.name, p.CrewCapacity));
			var bc = new BuildCost ();
			bc.addPart (p);
			var rd = new BuildResourceSet ();
			bool xfer = true;
			VesselResources.ResourceProcessor process = delegate (VesselResources vr, string res) {
				ProcessResource (vr, res, rd, xfer);
			};
			bc.resources.Process (process);
			var reslist = rd.Values;
			rd.Clear ();
			bc.container.Process (process);
			reslist.AddRange (rd.Values);
			rd.Clear ();
			xfer = false;
			bc.hullResoures.Process (process);
			reslist.AddRange (rd.Values);
			if (p.CrewCapacity > 0 && !p.name.Contains ("kerbalEVA")) {
				rd.Clear ();
				for (int i = 0; i < p.protoModuleCrew.Count; i++) {
					var crew = p.protoModuleCrew[i];
					ProcessKerbal (crew, rd);
				}
				reslist.AddRange (rd.Values);
			}
			return reslist;
		}
 void onEditorRestart()
 {
     buildCost = null;
     cashed_cost = null;
     parts_count = 0;
 }