public void KITFixedUpdate(IResourceManager resMan) { CurrentPowerReq = 0; if (!HighLogic.LoadedSceneIsFlight || !refinery_is_enabled || CurrentActivity == null) { lastActivityName = string.Empty; return; } CurrentPowerReq = PowerReqMult * CurrentActivity.PowerRequirements * BaseProduction; var powerRequest = CurrentPowerReq * (powerPercentage / 100); ConsumedPowerMw = CheatOptions.InfiniteElectricity ? powerRequest : resMan.Consume(ResourceName.ElectricCharge, ConsumedPowerMw); var powerRatio = CurrentPowerReq > 0 ? ConsumedPowerMw / CurrentPowerReq : 0; UtilisationPercentage = powerRatio * 100; var productionModifier = ProductionMult * BaseProduction; CurrentActivity.UpdateFrame(resMan, powerRatio * productionModifier, powerRatio, productionModifier, _overflowAllowed); lastPowerRatio = powerRatio; // save the current power ratio in case the vessel is unloaded lastOverflowSettings = _overflowAllowed; // save the current overflow settings in case the vessel is unloaded lastActivityName = CurrentActivity.ActivityName; // take the string with the name of the current activity, store it in persistent string lastClassName = CurrentActivity.GetType().Name; }
public void FixedUpdate() { currentPowerReq = 0; if (!HighLogic.LoadedSceneIsFlight || !refinery_is_enabled || currentActivity == null) { lastActivityName = string.Empty; return; } currentPowerReq = powerReqMult * currentActivity.PowerRequirements * baseProduction; var requestedPowerRatio = powerPercentage / 100; var powerRequest = currentPowerReq * requestedPowerRatio; consumedPowerMW = CheatOptions.InfiniteElectricity ? powerRequest : powerSupply.ConsumeMegajoulesPerSecond(powerRequest); var shortage = Math.Max(powerRequest - consumedPowerMW, 0); var fixedDeltaTime = (double)(decimal)Math.Round(TimeWarp.fixedDeltaTime, 7); var receivedElectricCharge = part.RequestResource(ResourceSettings.Config.ElectricPowerInKilowatt, shortage * GameConstants.ecPerMJ * fixedDeltaTime) / fixedDeltaTime; consumedPowerMW += receivedElectricCharge / GameConstants.ecPerMJ; var receivedPowerRatio = currentPowerReq > 0 ? consumedPowerMW / currentPowerReq : 0; utilisationPercentage = receivedPowerRatio * 100; var productionModifier = productionMult * baseProduction; currentActivity.UpdateFrame(requestedPowerRatio * receivedPowerRatio * productionModifier, requestedPowerRatio * receivedPowerRatio, requestedPowerRatio * productionModifier, _overflowAllowed, fixedDeltaTime); lastPowerRatio = receivedPowerRatio; // save the current power ratio in case the vessel is unloaded lastOverflowSettings = _overflowAllowed; // save the current overflow settings in case the vessel is unloaded lastActivityName = currentActivity.ActivityName; // take the string with the name of the current activity, store it in persistent string lastClassName = currentActivity.GetType().Name; lastActiveTime = Planetarium.GetUniversalTime(); }