Example #1
0
        public static void Initialize()
        {
            ignoreFuelsForFill = new HashSet <string> ();
            tankDefinitions    = new Tanks.TankDefinitionList();
            managedResources   = new Dictionary <string, HashSet <string> > ();

            ConfigNode node = GameDatabase.Instance.GetConfigNodes("MFSSETTINGS").Last();

            Debug.Log("[MFS] Loading global settings");

            bool  tb;
            float tf;

            if (bool.TryParse(node.GetValue("useRealisticMass"), out tb))
            {
                useRealisticMass = tb;
            }
            if (float.TryParse(node.GetValue("tankMassMultiplier"), out tf))
            {
                tankMassMultiplier = tf;
            }
            if (float.TryParse(node.GetValue("baseCostPV"), out tf))
            {
                baseCostPV = tf;
            }
            if (float.TryParse(node.GetValue("partUtilizationDefault"), out tf))
            {
                partUtilizationDefault = tf;
            }
            if (bool.TryParse(node.GetValue("partUtilizationTweakable"), out tb))
            {
                partUtilizationTweakable = tb;
            }
            if (node.HasValue("unitLabel"))
            {
                unitLabel = node.GetValue("unitLabel");
            }

            ConfigNode ignoreNode = node.GetNode("IgnoreFuelsForFill");

            if (ignoreNode != null)
            {
                foreach (ConfigNode.Value v in ignoreNode.values)
                {
                    ignoreFuelsForFill.Add(v.name);
                }
            }

            foreach (ConfigNode defNode in GameDatabase.Instance.GetConfigNodes("TANK_DEFINITION"))
            {
                if (tankDefinitions.Contains(defNode.GetValue("name")))
                {
                    Debug.LogWarning("[MFS] Ignored duplicate definition of tank type " + defNode.GetValue("name"));
                }
                else
                {
                    tankDefinitions.Add(new Tanks.TankDefinition(defNode));
                }
            }
        }
Example #2
0
        public static void Initialize()
        {
            ignoreFuelsForFill = new HashSet <string> ();
            tankDefinitions    = new Tanks.TankDefinitionList();
            managedResources   = new Dictionary <string, HashSet <string> > ();
            overrides          = new Dictionary <string, ConfigNode[]>();

            // fill vsps & conductivities
            resourceVsps           = new Dictionary <string, double>();
            resourceConductivities = new Dictionary <string, double>();
            foreach (ConfigNode n in GameDatabase.Instance.GetConfigNodes("RESOURCE_DEFINITION"))
            {
                if (n.HasValue("vsp"))
                {
                    double dtmp;
                    if (double.TryParse(n.GetValue("vsp"), out dtmp))
                    {
                        resourceVsps[n.GetValue("name")] = dtmp;
                    }
                }
                if (n.HasValue("conductivity"))
                {
                    double dtmp;
                    if (double.TryParse(n.GetValue("conductivity"), out dtmp))
                    {
                        resourceConductivities[n.GetValue("name")] = dtmp;
                    }
                }
            }


            ConfigNode node = GameDatabase.Instance.GetConfigNodes("MFSSETTINGS").LastOrDefault();

            Debug.Log("[MFS] Loading global settings");

            if (node != null)
            {
                bool   tb;
                float  tf;
                double td;

                if (bool.TryParse(node.GetValue("useRealisticMass"), out tb))
                {
                    useRealisticMass = tb;
                }
                if (float.TryParse(node.GetValue("tankMassMultiplier"), out tf))
                {
                    tankMassMultiplier = tf;
                }
                if (float.TryParse(node.GetValue("baseCostPV"), out tf))
                {
                    baseCostPV = tf;
                }
                if (float.TryParse(node.GetValue("partUtilizationDefault"), out tf))
                {
                    partUtilizationDefault = tf;
                }
                if (bool.TryParse(node.GetValue("partUtilizationTweakable"), out tb))
                {
                    partUtilizationTweakable = tb;
                }
                if (node.HasValue("unitLabel"))
                {
                    unitLabel = node.GetValue("unitLabel");
                }
                if (bool.TryParse(node.GetValue("basemassUseTotalVolume"), out tb))
                {
                    basemassUseTotalVolume = tb;
                }
                if (node.HasValue("radiatorMinTempMult"))
                {
                    if (double.TryParse(node.GetValue("radiatorMinTempMult"), out td))
                    {
                        radiatorMinTempMult = td;
                    }
                }

                ConfigNode ignoreNode = node.GetNode("IgnoreFuelsForFill");
                if (ignoreNode != null)
                {
                    foreach (ConfigNode.Value v in ignoreNode.values)
                    {
                        ignoreFuelsForFill.Add(v.name);
                    }
                }
            }

            foreach (ConfigNode defNode in GameDatabase.Instance.GetConfigNodes("TANK_DEFINITION"))
            {
                if (tankDefinitions.Contains(defNode.GetValue("name")))
                {
                    Debug.LogWarning("[MFS] Ignored duplicate definition of tank type " + defNode.GetValue("name"));
                }
                else
                {
                    tankDefinitions.Add(new Tanks.TankDefinition(defNode));
                }
            }
        }