Ejemplo 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;
        }
 public void Load(ConfigNode node)
 {
     if (node.HasValue("filename"))
     {
         filename = node.GetValue("filename");
     }
     if (node.HasValue("flagname"))
     {
         flagname = node.GetValue("flagname");
     }
     if (node.HasNode("CraftConfig"))
     {
         craftConfig = node.GetNode("CraftConfig");
     }
     if (node.HasNode("BuildCost"))
     {
         var bc = node.GetNode("BuildCost");
         buildCost = new CostReport();
         buildCost.Load(bc);
     }
     if (node.HasNode("BuiltStuff"))
     {
         var bs = node.GetNode("BuiltStuff");
         builtStuff = new CostReport();
         builtStuff.Load(bs);
     }
     if (node.HasValue("state"))
     {
         var s = node.GetValue("state");
         state = (State)Enum.Parse(typeof(State), s);
         if (state == State.Dewarping)
         {
             // The game got saved while the Dewarping state was still
             // active. Rather than restarting the dewarp coroutine,
             // Just jump straight to the Complete state.
             state = State.Complete;
         }
     }
     if (node.HasValue("paused"))
     {
         var  s = node.GetValue("paused");
         bool p = false;
         bool.TryParse(s, out p);
         paused = p;
     }
     if (node.HasValue("KACalarmID"))
     {
         KACalarmID = node.GetValue("KACalarmID");
     }
     if (node.HasNode("DockedVesselInfo"))
     {
         ConfigNode vi = node.GetNode("DockedVesselInfo");
         vesselInfo = new DockedVesselInfo();
         vesselInfo.Load(vi);
     }
 }
		public void Load (ConfigNode node)
		{
			filename = node.GetValue ("filename");
			flagname = node.GetValue ("flagname");
			craftConfig = node.GetNode ("CraftConfig");
			if (node.HasNode ("BuildCost")) {
				var bc = node.GetNode ("BuildCost");
				buildCost = new CostReport ();
				buildCost.Load (bc);
			}
			if (node.HasNode ("BuiltStuff")) {
				var bs = node.GetNode ("BuiltStuff");
				builtStuff = new CostReport ();
				builtStuff.Load (bs);
			}
			if (node.HasValue ("state")) {
				var s = node.GetValue ("state");
				state = (State) Enum.Parse (typeof (State), s);
				if (state == State.Dewarping) {
					// The game got saved while the Dewarping state was still
					// active. Rather than restarting the dewarp coroutine,
					// Just jump straight to the Complete state.
					state = State.Complete;
				}
			}
			if (node.HasValue ("paused")) {
				var s = node.GetValue ("paused");
				bool p = false;
				bool.TryParse (s, out p);
				paused = p;
			}
			KACalarmID = node.GetValue ("KACalarmID");
			if (node.HasNode ("DockedVesselInfo")) {
				ConfigNode vi = node.GetNode ("DockedVesselInfo");
				vesselInfo = new DockedVesselInfo ();
				vesselInfo.Load (vi);
			}
		}
 void onEditorRestart()
 {
     buildCost   = null;
     cashed_cost = null;
     parts_count = 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;
        }
 void onEditorRestart()
 {
     buildCost = null;
     cashed_cost = null;
     parts_count = 0;
 }