Beispiel #1
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);
         }
     }
 }
Beispiel #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);
        }