Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ProcessDrillsLights()
- {
- if (!ENABLE_DISTRIBUTING_ORE_IN_DRILLS)
- {
- _output.AppendLine("Setting color of drills payload indicators is disabled.");
- return;
- }
- if (_drillsPayloadLights.Count == 0)
- {
- _output.AppendLine("Setting color of drills payload indicators. Not enough lights found. Nothing to do.");
- return;
- }
- _output.AppendLine("Setting color of drills payload indicators.");
- Color color;
- if (_notConnectedDrillsFound)
- {
- _output.AppendLine("Not all drills are connected.");
- if (Storage == null || Storage.Length == 0 || Storage[0] == '0')
- {
- color = new Color(0, 128, 128);
- Storage = "1";
- }
- else
- {
- color = new Color(0, 64, 128);
- Storage = "0";
- }
- }
- else
- {
- float p;
- if (_drillsMaxVolume > 0)
- {
- p = (float)_drillsCurrentVolume * 1000.0f;
- p /= (float)_drillsMaxVolume;
- _output.Append("Drills space usage: ");
- _output.Append((p / 10.0f).ToString("F1"));
- _output.AppendLine("%");
- if ((_drillsMaxVolume - _drillsCurrentVolume) < WARNING_LEVEL_IN_CUBIC_METERS_LEFT)
- {
- if (Storage == null || Storage.Length == 0 || Storage[0] == '0')
- {
- color = new Color(128, 0, 128);
- Storage = "1";
- }
- else
- {
- color = new Color(128, 0, 64);
- Storage = "0";
- }
- }
- else
- {
- float r, g, b;
- if (p < 500.0f)
- {
- r = 255.0f;
- g = 255.0f;
- b = 255.0f * (500.0f - p) / 500.0f;
- }
- else
- {
- r = 255.0f;
- g = 255.0f * (900.0f - p) / 500.0f;
- b = 0.0f;
- }
- if (r > 255.0f) r = 255.0f;
- else if (r < 0.0f) r = 0.0f;
- if (g > 255.0f) g = 255.0f;
- else if (g < 0.0f) g = 0.0f;
- if (b > 255.0f) b = 255.0f;
- else if (b < 0.0f) b = 0.0f;
- color = new Color((int)r, (int)g, (int)b);
- Storage = "0";
- }
- }
- else
- {
- color = new Color(255, 255, 255);
- }
- }
- _output.Append("Drills payload indicators lights color: ");
- _output.Append(color);
- _output.AppendLine();
- for (int i = 0; i < _drillsPayloadLights.Count; ++i)
- {
- IMyLightingBlock light = _drillsPayloadLights[i];
- Color currentColor = light.GetValue<Color>("Color");
- if (currentColor != color)
- {
- light.SetValue<Color>("Color", color);
- }
- }
- _output.Append("Color of ");
- _output.Append(_drillsPayloadLights.Count);
- _output.AppendLine(" drills payload indicators has been set.");
- }
Advertisement
Add Comment
Please, Sign In to add comment