public static bool AddPreset(string name, ThermalGenerator generator)
 {
     if (presets.ContainsKey(name))
     {
         return(false);
     }
     else
     {
         presets.Add(name, generator);
         return(true);
     }
 }
        private void OnGeneratorToggle(Toggle t, bool isOn)
        {
            if (isOn)
            {
                foreach (var kvp in generatorToggles)
                {
                    if (kvp.Key != t)
                    {
                        kvp.Key.isOn = false;
                    }
                }

                selectedGeneratorName = generatorToggles[t].Item1;
                selectedGenerator     = generatorToggles[t].Item2;
            }
        }
Exemplo n.º 3
0
        public void SetEntry(string name, ThermalGenerator generator, int quantity)
        {
            this.generatorName = name;
            this.generator     = generator;
            this.quantity      = quantity;

            nameLabel.text = generatorName;
            quantityInputField.SetTextWithoutNotify(quantity.ToString());

            tooltip.header.text = generatorName + " Specifications";
            tooltip.body.text   = $"" +
                                  $"Rated Power: {generator.ratedPower.ToString("F2")} MW\n" +
                                  $"Min. Downtime: {generator.minDTime.ToString("F2")} minutes\n" +
                                  $"Min. Uptime: {generator.minUTime.ToString("F2")} minutes\n" +
                                  $"Cost Coefficient A: {generator.a} €/MW^2\n" +
                                  $"Cost Coefficient B: {generator.b} €/MW\n" +
                                  $"Cost Coefficient C: {generator.c} €\n" +
                                  $"Cost at Max Power: {((generator.a * generator.ratedPower * generator.ratedPower + generator.b * generator.ratedPower + generator.c) / generator.ratedPower).ToString("F2")} €/MWh\n";
        }
        private void AddGeneratorEntry(string generatorName, ThermalGenerator generator)
        {
            bool generatorExists = false;

            foreach (var ge in generatorEntries)
            {
                if (string.Equals(ge.generatorName, generatorName))
                {
                    generatorExists = true;
                    break;
                }
            }

            if (!generatorExists)
            {
                var obj = Instantiate(generatorEntryPrototype, generatorContainer);
                obj.OnDeleteButton   += DeleteGeneratorEntry;
                obj.OnQuantityChange += (s, e) => GetThermalMaxPower();
                obj.SetEntry(generatorName, generator, 0);
                generatorEntries.Add(obj);
            }
        }
 public static bool TryGetPreset(string name, out ThermalGenerator generator)
 => presets.TryGetValue(name, out generator);