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);
     }
 }
Exemplo n.º 2
0
 public override void OnLoad(ConfigNode node)
 {
     flagname = node.GetValue("flagname");
     if (node.HasValue("baseMass"))
     {
         float.TryParse(node.GetValue("baseMass"), out base_mass);
     }
     else
     {
         base_mass = part.mass;
     }
     craftConfig = node.GetNode("CraftConfig");
     if (node.HasNode("BuildCost"))
     {
         var bc = node.GetNode("BuildCost");
         buildCost = new BuildCost.CostReport();
         buildCost.Load(bc);
     }
     if (node.HasNode("BuiltStuff"))
     {
         var bs = node.GetNode("BuiltStuff");
         builtStuff = new BuildCost.CostReport();
         builtStuff.Load(bs);
     }
     if (node.HasValue("state"))
     {
         var s = node.GetValue("state");
         state = (State)Enum.Parse(typeof(State), s);
     }
     if (node.HasValue("paused"))
     {
         var  s = node.GetValue("paused");
         bool p = false;
         bool.TryParse(s, out p);
         paused = p;
     }
     if (node.HasNode("DockedVesselInfo"))
     {
         ConfigNode vi = node.GetNode("DockedVesselInfo");
         vesselInfo = new DockedVesselInfo();
         vesselInfo.Load(vi);
     }
 }
Exemplo n.º 3
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("FIXEDATTACH"))
     {
         ConfigNode FxNode = node.GetNode("FIXEDATTACH");
         KAS_Shared.DebugLog("OnLoad(Core) Loading fixed joint info from save...");
         if (FxNode.HasValue("srcPartID") && FxNode.HasValue("srcVesselID") &&
             FxNode.HasValue("tgtPartID") && FxNode.HasValue("tgtVesselID") &&
             FxNode.HasValue("breakForce"))
         {
             FixedAttach.savedSrcPartID   = FxNode.GetValue("srcPartID").ToString();
             FixedAttach.savedSrcVesselID = FxNode.GetValue("srcVesselID").ToString();
             FixedAttach.savedTgtPartID   = FxNode.GetValue("tgtPartID").ToString();
             FixedAttach.savedTgtVesselID = FxNode.GetValue("tgtVesselID").ToString();
             FixedAttach.savedBreakForce  = float.Parse(FxNode.GetValue("breakForce"));
             attachMode.FixedJoint        = true;
         }
         else
         {
             KAS_Shared.DebugWarning("OnLoad(Core) Missing node value(s)!");
         }
     }
     if (node.HasNode("DOCKEDVESSEL") && node.HasValue("dockedPartID"))
     {
         KAS_Shared.DebugLog("OnLoad(Core) Loading docked info from save...");
         vesselInfo = new DockedVesselInfo();
         vesselInfo.Load(node.GetNode("DOCKEDVESSEL"));
         dockedPartID      = node.GetValue("dockedPartID").ToString();
         attachMode.Docked = true;
     }
     if (node.HasValue("StaticJoint"))
     {
         attachMode.StaticJoint = true;
     }
 }
Exemplo n.º 4
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("FIXEDATTACH")) {
       ConfigNode FxNode = node.GetNode("FIXEDATTACH");
       KAS_Shared.DebugLog("OnLoad(Core) Loading fixed joint info from save...");
       if (FxNode.HasValue("srcPartID") && FxNode.HasValue("srcVesselID")
       && FxNode.HasValue("tgtPartID") && FxNode.HasValue("tgtVesselID")
       && FxNode.HasValue("breakForce")) {
     FixedAttach.savedSrcPartID = FxNode.GetValue("srcPartID").ToString();
     FixedAttach.savedSrcVesselID = FxNode.GetValue("srcVesselID").ToString();
     FixedAttach.savedTgtPartID = FxNode.GetValue("tgtPartID").ToString();
     FixedAttach.savedTgtVesselID = FxNode.GetValue("tgtVesselID").ToString();
     FixedAttach.savedBreakForce = float.Parse(FxNode.GetValue("breakForce"));
     attachMode.FixedJoint = true;
       } else {
     KAS_Shared.DebugWarning("OnLoad(Core) Missing node value(s)!");
       }
     }
     if (node.HasNode("DOCKEDVESSEL") && node.HasValue("dockedPartID")) {
       KAS_Shared.DebugLog("OnLoad(Core) Loading docked info from save...");
       vesselInfo = new DockedVesselInfo();
       vesselInfo.Load(node.GetNode("DOCKEDVESSEL"));
       dockedPartID = node.GetValue("dockedPartID").ToString();
       attachMode.Docked = true;
     }
     if (node.HasValue("StaticJoint")) {
       attachMode.StaticJoint = true;
     }
 }
		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);
			}
		}
 public override void OnLoad(ConfigNode node)
 {
     flagname = node.GetValue ("flagname");
     if (node.HasValue ("baseMass")) {
         float.TryParse (node.GetValue ("baseMass"), out base_mass);
     } else {
         base_mass = part.mass;
     }
     craftConfig = node.GetNode ("CraftConfig");
     if (node.HasNode ("BuildCost")) {
         var bc = node.GetNode ("BuildCost");
         buildCost = new BuildCost.CostReport ();
         buildCost.Load (bc);
     }
     if (node.HasNode ("BuiltStuff")) {
         var bs = node.GetNode ("BuiltStuff");
         builtStuff = new BuildCost.CostReport ();
         builtStuff.Load (bs);
     }
     if (node.HasValue ("state")) {
         var s = node.GetValue ("state");
         state = (State) Enum.Parse (typeof (State), s);
     }
     if (node.HasValue ("paused")) {
         var s = node.GetValue ("paused");
         bool p = false;
         bool.TryParse (s, out p);
         paused = p;
     }
     if (node.HasNode ("DockedVesselInfo")) {
         ConfigNode vi = node.GetNode ("DockedVesselInfo");
         vesselInfo = new DockedVesselInfo ();
         vesselInfo.Load (vi);
     }
 }
Exemplo n.º 7
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            //node and value names are compatible with ModuleGrappleNode
            //deprecated config conversion
            var vinfo = node.GetNode("THISVESSEL") ?? node.GetNode("DOCKEDVESSEL");

            if (vinfo != null)
            {
                this_vessel = new DockedVesselInfo();
                this_vessel.Load(vinfo);
            }
            //deprecated config conversion
            vinfo = node.GetNode("DOCKEDVESSEL_Other") ?? node.GetNode("DOCKEDVESSEL");
            if (vinfo != null)
            {
                docked_vessel = new DockedVesselInfo();
                docked_vessel.Load(vinfo);
            }
            if (node.HasValue("dockUId"))
            {
                dockedPartUId = uint.Parse(node.GetValue("dockUId"));
            }
            GrappleRangeSqr = GrappleRange * GrappleRange;
            DockRangeSqr    = DockRange * DockRange;
            //load grapple attach node
            if (HighLogic.LoadedSceneIsFlight)
            {
                grappleNode               = new AttachNode();
                grappleNode.size          = 1;
                grappleNode.id            = "grapple";
                grappleNode.rigid         = true;
                grappleNode.ResourceXFeed = true;
                grappleNode.attachMethod  = AttachNodeMethod.FIXED_JOINT;
                grappleNode.breakingForce = grappleNode.breakingTorque = float.PositiveInfinity;
            }
            if (node.HasValue("grapplePos"))
            {
                grapplePos = KSPUtil.ParseVector3(node.GetValue("grapplePos"));
            }
            if (node.HasValue("grappleOrt"))
            {
                grappleOrt = KSPUtil.ParseVector3(node.GetValue("grappleOrt"));
            }
            if (node.HasValue("grappleOrt2"))
            {
                grappleOrt2 = KSPUtil.ParseVector3(node.GetValue("grappleOrt2"));
            }
            //deprecated config conversion
            if (node.HasValue("Fixed"))
            {
                if (bool.Parse(node.GetValue("Fixed")))
                {
                    state = State.Fixed;
                }
                else if (dockedPartUId > 0)
                {
                    state = State.Docked;
                }
                else
                {
                    armAnimator = part.GetAnimator <MultiAnimator>(ArmAnimatorID);
                    if (armAnimator != null &&
                        armAnimator.State == AnimatorState.Opened)
                    {
                        state = State.Armed;
                    }
                    else
                    {
                        state = State.Idle;
                    }
                }
            }
        }