Exemple #1
0
        public override void OnLoad(ConfigNode node)
        {
            print("========ModuleFuelTanks.OnLoad called. Node is:=======");
            print(node.ToString());
            if (node.HasValue("type") && node.HasValue("volume"))
            {
                //ConfigNode config = ConfigNode.Load (appPath + "tanktypes.cfg");

                string volume    = node.GetValue("volume");
                string tank_type = node.GetValue("type");
                if (TankDefinition(tank_type) != null)
                {
                    node = new ConfigNode();
                    TankDefinition(tank_type).CopyTo(node);
                    node.AddValue("volume", volume);
                }
            }
            base.OnLoad(node);
            if (node.HasValue("basemass"))
            {
                if (node.GetValue("basemass").Contains("*") && node.GetValue("basemass").Contains("volume"))
                {
                    float.TryParse(node.GetValue("basemass").Replace("volume", "").Replace("*", "").Trim(), out basemass);
                    basemass = RoundTo4SigFigs(basemass * volume);
                }
            }

            if (fuelList == null)
            {
                fuelList = new List <FuelTank> ();
            }
            else
            {
                fuelList.Clear();
            }

            foreach (ConfigNode tankNode in node.nodes)
            {
                if (tankNode.name.Equals("TANK"))
                {
#if DEBUG
                    print("loading FuelTank from node " + tankNode.ToString());
#endif
                    FuelTank tank = new FuelTank();
                    tank.module = this;
                    tank.Load(tankNode);
                    fuelList.Add(tank);
                }
            }
#if DEBUG
            print("ModuleFuelTanks.onLoad loaded " + fuelList.Count + " fuels");

            print("ModuleFuelTanks loaded. ");
#endif
            part.mass = basemass + tank_mass;
        }