public void EnergySim200ms(float dt) { KSelectable component = GetComponent <KSelectable>(); if (operational.IsActive) { generator.GenerateJoules(generator.WattageRating * dt, false); component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.Wattage, generator); } else { generator.ResetJoules(); component.SetStatusItem(Db.Get().StatusItemCategories.Power, Db.Get().BuildingStatusItems.GeneratorOffline, null); if (operational.IsOperational) { CircuitManager circuitManager = Game.Instance.circuitManager; if (circuitManager != null) { ushort circuitID = circuitManager.GetCircuitID(powerCell); bool flag = circuitManager.HasBatteries(circuitID); bool flag2 = false; if (!flag && circuitManager.HasConsumers(circuitID)) { flag2 = true; } else if (flag) { if (batteryRefillPercent <= 0f && circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) <= 0f) { flag2 = true; } else if (circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) < batteryRefillPercent) { flag2 = true; } } if (flag2) { if (chore == null && smi.GetCurrentState() == smi.sm.on) { chore = new WorkChore <ManualGenerator>(Db.Get().ChoreTypes.GeneratePower, this, null, true, null, null, null, true, null, false, true, null, false, true, true, PriorityScreen.PriorityClass.basic, 5, false, true); } } else if (chore != null) { chore.Cancel("No refill needed"); chore = null; } component.ToggleStatusItem(EnergyGenerator.BatteriesSufficientlyFull, !flag2, null); } } } }
protected override bool OnWorkTick(Worker worker, float dt) { CircuitManager circuitManager = Game.Instance.circuitManager; bool flag = false; if (circuitManager != null) { ushort circuitID = circuitManager.GetCircuitID(powerCell); bool flag2 = circuitManager.HasBatteries(circuitID); flag = ((flag2 && circuitManager.GetMinBatteryPercentFullOnCircuit(circuitID) < 1f) || (!flag2 && circuitManager.HasConsumers(circuitID))); } AttributeLevels component = worker.GetComponent <AttributeLevels>(); if ((Object)component != (Object)null) { component.AddExperience(Db.Get().Attributes.Athletics.Id, dt, DUPLICANTSTATS.ATTRIBUTE_LEVELING.ALL_DAY_EXPERIENCE); } return(!flag); }