private IEnumerator Start()
        {
            for (;;)
            {
                yield return(new WaitForSeconds(updateInterval));

                PowerSource source = gameObject.GetComponent <PowerSource>();
                if (source != null)
                {
                    float powerProduced = source.GetPower() - previousPower;

                    int slot = (currentSlot++) % windowSize;
                    productionWindow[slot] = powerProduced;

                    previousPower = source.GetPower();
                }
            }
        }
        IEnumerator UpdateUI()
        {
            while (true)
            {
                yield return(new WaitForSeconds(2));

                if (IsEnabled)
                {
                    var power    = Mathf.RoundToInt(_powerSource.GetPower());
                    var powerMax = Mathf.RoundToInt(_powerSource.GetMaxPower());
                    lblStatus.text   = $"Power Status : <color={(IsEnabled ? "green": "red")}>{IsEnabled}</color>";
                    lblBattery.text  = $"Power {power}/{powerMax} Kw";
                    lblEmission.text = $"{Math.Round(CurrentEmitRate, 2)} w/sec";
                }
                else
                {
                    lblStatus.text   = $"Power Status : <color=yellow>N/A</color>";
                    lblBattery.text  = $"Power 0/0  Kw";
                    lblEmission.text = $"0.0 w/sec";
                }
            }
        }
Example #3
0
        public static void Postfix(WaterPark __instance)
        {
            PowerSource powerSource      = __instance.gameObject.GetComponent <PowerSource>();
            int         numberOfShockers = __instance.items.FindAll((WaterParkItem item) => item.pickupable.GetTechType() == TechType.Shocker).Count;

            if (powerSource == null)
            {
                powerSource          = __instance.gameObject.AddComponent <PowerSource>();
                powerSource.maxPower = 100 * numberOfShockers;
                powerSource.power    = PlayerPrefs.GetFloat($"PowerSource:{__instance.GetInstanceID()}", 0f);
            }
            else
            {
                powerSource.maxPower = 100 * numberOfShockers;
            }
            if (powerSource.GetPower() > powerSource.GetMaxPower())
            {
                powerSource.power = powerSource.maxPower;
            }

            Config.PowerValues[$"PowerSource:{__instance.GetInstanceID()}"] = powerSource.GetPower();
        }