Exemplo n.º 1
0
        public override void OnLoad(ConfigNode node)
        {
            if (!GameSceneFilter.AnyInitializing.IsLoaded())
            {
                return;
            }

            tankTypeOptions = new List <TankTypeOption>();
            foreach (ConfigNode optNode in node.GetNodes("TANK_TYPE_OPTION"))
            {
                TankTypeOption option = new TankTypeOption();
                option.Load(optNode);
                tankTypeOptions.Add(option);
            }

            // Unity for some daft reason, and not as according to it's own documentation, won't clone
            // serializable member fields. Lets DIY.
            tankTypeOptionsSerialized = ObjectSerializer.Serialize(tankTypeOptions);


            try
            {
                if (bool.Parse(node.GetValue("useVolume")))
                {
                    tankVolumeName = PartVolumes.Tankage.ToString();
                }
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch { }
        }
Exemplo n.º 2
0
        private void UpdateTankType(bool init = false)
        {
            if (tankTypeOptions == null || (selectedTankType != null && selectedTankType.name == tankType))
            {
                return;
            }

            TankTypeOption oldTankType = selectedTankType;

            selectedTankType = tankTypeOptions.Find(opt => opt.name == tankType);

            if (selectedTankType == null)
            {
                if (oldTankType == null)
                {
                    Debug.LogWarning("*TCS* Initially selected part type '" + tankType + "' does not exist, reverting to default");
                    selectedTankType = tankTypeOptions[0];
                    tankType         = selectedTankType.name;
                }
                else
                {
                    Debug.LogWarning("*TCS* Selected part type '" + tankType + "' does not exist, reverting to previous");
                    selectedTankType = oldTankType;
                    tankType         = selectedTankType.name;
                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
                    }
                    return;
                }
            }

            if (selectedTankType.isStructural)
            {
                Fields["volumeDisplay"].guiActiveEditor = false;
            }
            else
            {
                Fields["volumeDisplay"].guiActiveEditor = tankVolumeName != null;
            }

            UpdateMassAndResources(true, init);
            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
            }
        }
Exemplo n.º 3
0
        public override void OnLoad(ConfigNode node)
        {
            if (!GameSceneFilter.AnyInitializing.IsLoaded())
            {
                return;
            }

            tankTypeOptions = new List <TankTypeOption>();
            foreach (ConfigNode optNode in node.GetNodes("TANK_TYPE_OPTION"))
            {
                TankTypeOption option = new TankTypeOption();
                option.Load(optNode);
                tankTypeOptions.Add(option);
            }

            // Unity for some daft reason, and not as according to it's own documentation, won't clone
            // serializable member fields. Lets DIY.
            tankTypeOptionsSerialized = ObjectSerializer.Serialize(tankTypeOptions);
        }
Exemplo n.º 4
0
        private void UpdateTankType()
        {
            if (tankTypeOptions == null || (selectedTankType != null && selectedTankType.name == tankType))
            {
                return;
            }

            TankTypeOption oldTankType = selectedTankType;

            selectedTankType = tankTypeOptions.Find(opt => opt.name == tankType);

            if (selectedTankType == null)
            {
                if (oldTankType == null)
                {
                    Debug.LogWarning("*TCS* Initially selected part type '" + tankType + "' does not exist, reverting to default");
                    selectedTankType = tankTypeOptions[0];
                    tankType         = selectedTankType.name;
                }
                else
                {
                    Debug.LogWarning("*TCS* Selected part type '" + tankType + "' does not exist, reverting to previous");
                    selectedTankType = oldTankType;
                    tankType         = selectedTankType.name;
                    return;
                }
            }

            if (selectedTankType.isStructural)
            {
                Fields["tankVolume"].guiActiveEditor = false;
            }
            else
            {
                Fields["tankVolume"].guiActiveEditor = tankVolumeName != null;
            }

            UpdateMassAndResources(true);
        }
Exemplo n.º 5
0
        public override void OnLoad(ConfigNode node)
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
            {
                foreach (ConfigNode optNode in node.GetNodes("TANK_TYPE_OPTION"))
                {
                    TankTypeOption option = new TankTypeOption();
                    option.Load(optNode);
                    tankTypeOptions.Add(option.name, option);
                }
                if (string.IsNullOrEmpty(tankType) || !tankTypeOptions.Keys.Contains(tankType))
                {
                    tankType = tankTypeOptions.Keys.First();
                }
            }
            bool useV = false;

            if (node.TryGetValue("useVolume", ref useV) && useV)
            {
                tankVolumeName = PartVolumes.Tankage.ToString();
            }
        }