Ejemplo n.º 1
0
 public void setResourceRatio(ContainerDefinition def, string resourceName, int newRatio, bool updateSymmetry = false)
 {
     def.setResourceRatio(resourceName, newRatio);
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             SSTUVolumeContainer mod  = p.GetComponent <SSTUVolumeContainer>();
             ContainerDefinition def2 = mod.getContainer(def.name);
             mod.setResourceRatio(def2, resourceName, newRatio, false);
         }
     }
 }
Ejemplo n.º 2
0
        public bool draw()
        {
            bool  update             = false;
            int   currentUnitRatio   = container.getResourceUnitRatio(resourceName);
            float currentVolumeRatio = container.getResourceVolumeRatio(resourceName);
            float totalVolumeRatio   = container.totalVolumeRatio;

            if (currentUnitRatio != prevRatio)//was updated externally...
            {
                prevRatio = currentUnitRatio;
                textRatio = prevRatio.ToString();
                update    = true;
            }
            GUILayout.Label(resourceName, GUILayout.Width(150));
            string textVal = GUILayout.TextField(textRatio, GUILayout.Width(100));

            if (textVal != textRatio)
            {
                textRatio = textVal;
                int parsedTextVal;
                if (int.TryParse(textRatio, out parsedTextVal))
                {
                    prevRatio = parsedTextVal;
                    container.setResourceRatio(resourceName, parsedTextVal);
                    update = true;
                }
            }

            GUILayout.Label(units.ToString(), GUILayout.Width(80));
            GUILayout.Label(volume.ToString(), GUILayout.Width(80));
            GUILayout.Label(resourceMass.ToString(), GUILayout.Width(80));
            GUILayout.Label(cost.ToString(), GUILayout.Width(80));
            GUILayout.Label(percent.ToString(), GUILayout.Width(80));
            float val = GUILayout.HorizontalSlider(fillPercent, 0, 1, GUILayout.Width(80));

            if (val != fillPercent)
            {
                fillPercent = val;
                container.setResourceFillPercent(resourceName, fillPercent);
                update = true;
            }
            return(update);
        }