public override void OnAwake() { if (!HighLogic.LoadedSceneIsFlight) { return; } _maxDelta = ResourceUtilities.GetMaxDeltaTime(); }
public override void OnAwake() { if (!HighLogic.LoadedSceneIsFlight) { return; } _conMods = part.FindModulesImplementing <ModuleResourceConverter>(); _maxDelta = ResourceUtilities.GetMaxDeltaTime(); }
bool CatchUpBacklog() { //if (Time.timeSinceLevelLoad < 1 // || ResourceScenario.Instance == null) { if (ResourceScenario.Instance == null) { return(true); } double currentTime = Planetarium.GetUniversalTime(); double delta = currentTime - lastUpdate; delta = Math.Min(delta, ResourceUtilities.GetMaxDeltaTime()); lastUpdate += delta; int num_sinks = 0; for (int i = 0; i < protoSinks.Count; i++) { if (protoSinks[i].isActive) { num_sinks++; } } double hours = Productivity * delta / 3600.0; if (num_sinks > 0) { double work = hours / num_sinks; for (int i = 0; i < protoSinks.Count; i++) { var ps = protoSinks[i]; if (ps.isActive) { ps.CatchUpBacklog(sinks[i], work); } } return(true); } else { protoSinks = null; return(false); } }
double GetDeltaTime() { double delta = -1; if (Time.timeSinceLevelLoad >= 1 && FlightGlobals.ready) { if (lastUpdate < 1e-9) { lastUpdate = Planetarium.GetUniversalTime(); } else { var currentTime = Planetarium.GetUniversalTime(); delta = currentTime - lastUpdate; delta = Math.Min(delta, ResourceUtilities.GetMaxDeltaTime()); lastUpdate += delta; } } return(delta); }
protected double GetDeltaTime() { if (Time.timeSinceLevelLoad < 1.0f || !FlightGlobals.ready) { return(-1); } if (Math.Abs(LastUpdateTime) < ResourceUtilities.FLOAT_TOLERANCE) { // Just started running LastUpdateTime = Planetarium.GetUniversalTime(); return(-1); } double maxDeltaTime = ResourceUtilities.GetMaxDeltaTime(); double deltaTime = Math.Min(Planetarium.GetUniversalTime() - LastUpdateTime, maxDeltaTime); LastUpdateTime += deltaTime; return(deltaTime); }
protected double GetDeltaTimex() { try { if (Time.timeSinceLevelLoad < 1.0f || !FlightGlobals.ready) { return(-1); } if (Math.Abs(lastUpdateTime) < float.Epsilon) { // Just started running // lastUpdateTime = Planetarium.GetUniversalTime(); return(-1); } var deltaTime = Math.Min(Planetarium.GetUniversalTime() - lastUpdateTime, ResourceUtilities.GetMaxDeltaTime()); //lastUpdateTime += deltaTime; return(deltaTime); } catch (Exception e) { print("[REGO] - Error in - BaseConverter_GetDeltaTime - " + e.Message); return(0); } }
/// <summary> /// Gets the delta time of the physics (?) update. First it confirms the game is in a valid state. Then it calculats /// the time between physics update by comparing with Planetarium.GetUniversalTime() and GetMaxDeltaTime(). /// </summary> /// <returns>The delta time.</returns> protected double GetDeltaTimex() { if (Time.timeSinceLevelLoad < 1.0f || !FlightGlobals.ready) { //Error: Not sure what this error is for...maybe not enough time since load? Debug.Log(debuggingClass.modName + "WARNING: check timeSinceLevelLoad/FlightGlobals"); Debug.Log(debuggingClass.modName + "timeSinceLevelLoad = " + Time.timeSinceLevelLoad); Debug.Log(debuggingClass.modName + "FlightGlobals.ready = " + !FlightGlobals.ready); return(-1); } if (Math.Abs(lastUpdateTime) < float.Epsilon) { //Error: Just started running Debug.Log(debuggingClass.modName + "ERROR: check lastUpdateTime"); Debug.Log(debuggingClass.modName + "lastUpdateTime = " + lastUpdateTime); lastUpdateTime = Planetarium.GetUniversalTime(); return(-1); } var deltaTime = Math.Min(Planetarium.GetUniversalTime() - lastUpdateTime, ResourceUtilities.GetMaxDeltaTime()); return(deltaTime); //why is deltaTime == 0? //return deltaTime; }