Пример #1
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            ConfigNode[] containerNodes = node.GetNodes("CONTAINER");
            int          len            = containerNodes.Length;

            containers = new ContainerDefinition[len];
            for (int i = 0; i < len; i++)
            {
                containers[i] = new ContainerDefinition(this, containerNodes[i]);
            }
            if (!string.IsNullOrEmpty(persistentData))
            {
                string[] splits = persistentData.Split(':');
                len = containers.Length;
                for (int i = 0; i < len && i < splits.Length; i++)
                {
                    containers[i].loadPersistenData(splits[i]);
                }
            }
            prevFuelType = getBaseContainer().fuelPreset;
            ConfigNode[] blacklistNodes = node.GetNodes("BLACKLIST");
            len = blacklistNodes.Length;
            blacklistedResources = new string[len];
            for (int i = 0; i < len; i++)
            {
                blacklistedResources[i] = blacklistNodes[i].GetStringValue("name");
            }
        }
Пример #2
0
        private static void addWindowFuelTypeControls(ContainerDefinition container)
        {
            GUILayout.Label("Fuel Types -- Click to add ratio, CTRL click to set ratio, SHIFT click to subtract ratio");
            ContainerFuelPreset[] presets = container.fuelPresets;
            ContainerFuelPreset   preset;

            GUILayout.BeginHorizontal();
            for (int i = 0; i < presets.Length; i++)
            {
                preset = presets[i];
                if (i > 0 && i % 4 == 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                if (GUILayout.Button(preset.name, GUILayout.Width(175)))
                {
                    if (ctrlPressed())//ctrl == set fuel type
                    {
                        container.module.setFuelPreset(container, presets[i], true);
                    }
                    else if (shiftPressed())
                    {
                        container.module.subtractPresetRatios(container, presets[i], true);
                    }
                    else
                    {
                        container.module.addPresetRatios(container, presets[i], true);
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
Пример #3
0
        /// <summary>
        /// Update the available GUI fuel type selection values for the current container setup
        /// </summary>
        private void updateFuelSelections()
        {
            ContainerDefinition container = getBaseContainer();
            string currentType            = container.fuelPreset;

            guiFuelType = prevFuelType = currentType;
            string[] presetNames;
            if (currentType == "custom")
            {
                presetNames    = new string[container.fuelPresets.Length + 1];
                presetNames[0] = "custom";
                for (int i = 1; i < presetNames.Length; i++)
                {
                    presetNames[i] = container.fuelPresets[i - 1].name;
                }
            }
            else
            {
                presetNames = new string[container.fuelPresets.Length];
                for (int i = 0; i < presetNames.Length; i++)
                {
                    presetNames[i] = container.fuelPresets[i].name;
                }
            }
            this.updateUIChooseOptionControl("guiFuelType", presetNames, presetNames, true, currentType);
            Fields["guiFuelType"].guiActiveEditor = enableFuelTypeChange && container.rawVolume > 0;
        }
Пример #4
0
        private static void addWindowContainerTypeControls(ContainerDefinition container)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Select a container type:");
            GUILayout.Label("Current Type: " + container.currentModifier.name);
            GUILayout.EndHorizontal();
            ContainerModifier[] mods = container.modifiers;
            ContainerModifier   mod;
            int len   = mods.Length;
            int index = 0;

            GUILayout.BeginHorizontal();
            for (int i = 0; i < len; i++)
            {
                mod = mods[i];
                if (!mod.isAvailable(module))
                {
                    continue;
                }
                if (index > 0 && index % 4 == 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                if (GUILayout.Button(mod.title, GUILayout.Width(175)))
                {
                    module.containerTypeUpdated(container, mod, true);
                }
                index++;
            }
            GUILayout.EndHorizontal();
        }
Пример #5
0
        private static void addWindowContainerRatioControls(ContainerDefinition container)
        {
            GUILayout.Label("Adjust ratio through input box to change resource ratios");
            VolumeRatioEntry[] ratioData = resourceEntries[containerIndex];
            scrollPos = GUILayout.BeginScrollView(scrollPos);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Resource", GUILayout.Width(150));
            GUILayout.Label("Unit Ratio", GUILayout.Width(100));
            GUILayout.Label("Units", GUILayout.Width(80));
            GUILayout.Label("Volume", GUILayout.Width(80));
            GUILayout.Label("Mass", GUILayout.Width(80));
            GUILayout.Label("Cost", GUILayout.Width(80));
            GUILayout.Label("% of Tank", GUILayout.Width(80));
            GUILayout.Label("Fill %", GUILayout.Width(80));
            GUILayout.EndHorizontal();
            int len = ratioData.Length;

            for (int i = 0; i < len; i++)
            {
                GUILayout.BeginHorizontal();
                ratioData[i].draw();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
        }
Пример #6
0
 public VolumeRatioEntry(ContainerDefinition container, string resourceName, int startRatio)
 {
     this.container    = container;
     this.resourceName = resourceName;
     this.prevRatio    = startRatio;
     this.textRatio    = prevRatio.ToString();
     this.fillPercent  = container.getResourceFillPercent(resourceName);
     updateCachedValues();
 }
Пример #7
0
        private float fillPercent = 1f;              //the amount of the resource compared to max to fill the part with

        public SubContainerDefinition(ContainerDefinition container, String name)
        {
            this.container = container;
            this.name      = name;
            def            = PartResourceLibrary.Instance.resourceDefinitions[name];
            if (def == null)
            {
                throw new NullReferenceException("Resource definition was null for name: " + name + " while loading resources for part: " + container.module.part);
            }
        }
Пример #8
0
        public void setFromContainer(SSTUVolumeContainer container)
        {
            ContainerDefinition highestVolume = container.highestVolumeContainer(data.name);

            if (container == null)
            {
                MonoBehaviour.print("ERROR: Could not locate volume container definition for resource: " + data.name);
            }
            setFromContainer(highestVolume.currentModifier);
        }
Пример #9
0
 public void setResourceFillPercent(ContainerDefinition def, string resourceName, float newPercent, bool updateSymmetry = false)
 {
     def.setResourceFillPercent(resourceName, newPercent);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             SSTUVolumeContainer mod  = p.GetComponent <SSTUVolumeContainer>();
             ContainerDefinition def2 = mod.getContainer(def.name);
             mod.setResourceFillPercent(def2, resourceName, newPercent, false);
         }
     }
 }
Пример #10
0
 public void addPresetRatios(ContainerDefinition container, ContainerFuelPreset preset, bool updateSymmetry)
 {
     container.addPresetRatios(preset);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             SSTUVolumeContainer symmetryModule          = p.GetComponent <SSTUVolumeContainer>();
             ContainerDefinition symmetryModuleContainer = symmetryModule.getContainer(container.name);
             ContainerFuelPreset symmetryModulePreset    = symmetryModuleContainer.internalGetFuelPreset(preset.name);
             symmetryModule.addPresetRatios(symmetryModuleContainer, symmetryModulePreset, false);
         }
     }
 }
Пример #11
0
 public void subtractPresetRatios(ContainerDefinition container, ContainerFuelPreset preset, bool updateSymmetry)
 {
     container.subtractPresetRatios(preset);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             SSTUVolumeContainer mod     = p.GetComponent <SSTUVolumeContainer>();
             ContainerDefinition def2    = mod.getContainer(container.name);
             ContainerFuelPreset preset2 = def2.internalGetFuelPreset(preset.name);
             mod.subtractPresetRatios(def2, preset2, false);
         }
     }
 }
Пример #12
0
        public void containerTypeUpdated(ContainerDefinition container, ContainerModifier newType, bool updateSymmetry = false)
        {
            container.setModifier(newType);
            updatePartStats();

            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    SSTUVolumeContainer mod  = p.GetComponent <SSTUVolumeContainer>();
                    ContainerDefinition def2 = mod.getContainer(container.name);
                    ContainerModifier   mod2 = def2.internalGetModifier(newType.name);
                    mod.containerTypeUpdated(def2, mod2, false);
                }
            }
        }
Пример #13
0
        public ContainerDefinition highestVolumeContainer(string resourceName)
        {
            ContainerDefinition high = null;
            ContainerDefinition def;
            float highVal = -1, val;
            int   len = containers.Length;

            for (int i = 0; i < len; i++)
            {
                def = containers[i];
                if (def.contains(resourceName))
                {
                    val = def.getResourceVolume(resourceName);
                    if (highVal < 0 || val > highVal)
                    {
                        high    = def;
                        highVal = val;
                    }
                }
            }
            return(high);
        }
Пример #14
0
        private void loadConfigData()
        {
            ConfigNode node = SSTUStockInterop.getPartModuleConfig(this);

            ConfigNode[] containerNodes = node.GetNodes("CONTAINER");
            int          len            = containerNodes.Length;

            containers = new ContainerDefinition[len];
            for (int i = 0; i < len; i++)
            {
                containers[i] = new ContainerDefinition(containerNodes[i], volume);
            }
            if (!string.IsNullOrEmpty(persistentData))
            {
                string[] splits = persistentData.Split(':');
                len = containers.Length;
                for (int i = 0; i < len && i < splits.Length; i++)
                {
                    containers[i].loadPersistenData(splits[i]);
                }
            }
            prevFuelType = getBaseContainer().fuelPreset;
        }
Пример #15
0
 public void containerFuelTypeAdded(ContainerDefinition container, ContainerFuelPreset fuelType)
 {
     container.addPresetRatios(fuelType);
     updateFuelSelections();
 }
Пример #16
0
 public void containerFuelTypeSet(ContainerDefinition container, ContainerFuelPreset fuelType)
 {
     updateFuelSelections();
 }
Пример #17
0
 public void containerTypeUpdated(ContainerDefinition container, ContainerModifier newType)
 {
     container.setModifier(newType);
     updatePartStats();
 }