def isSettled(): if not own['settled']: logic.setTimeScale(0.001) if(utils.getMode()!=utils.MODE_MULTIPLAYER): logic.isSettled = False fps = logic.getAverageFrameRate() avgFPSList = own['settleFrameRates'] avgFPSList.append(fps) deviation = 100 if(len(avgFPSList)>1): deviation = statistics.stdev(avgFPSList) if len(avgFPSList)>100: if deviation < 300: settle() else: own.setLinearVelocity([0,0,0],True) own.position = own['launchPosition'] if len(avgFPSList)>1000: del avgFPSList[0] settle() utils.log("WARNING!!!: FPS did not become stable after 2000 frames. Expect physics instability...") utils.log("standard deviation: "+str(deviation)) else: #we are in multiplayer and should wait a fixed time if ((time.perf_counter()-own['settleStartTime'])>3): settle() utils.log("settling due to time expiration in multiplayer") else: if(logic.finishedLastLap): logic.setTimeScale(0.001)
def update(cont): own = cont.owner if "lastHit" not in own: own["lastHit"] = None if getEventStatus("charmenu") and core.player: if core.GUI.currScreen == "": newScreen = "menus_char" setTimeScale(0.01) core.GUI.bkgn["active"] = True core.GUI.bkgn.state = 1 else: newScreen = "" core.GUI.active_widget = None core.GUI.resetMousePos() core.cont["lookAngle"] = [0,0] setTimeScale(1.0) core.GUI.bkgn["active"] = False core.GUI.bkgn.state = 1 core.GUI.onTextChange("", "prompter") core.GUI.drawScreen(newScreen) core.GUI.mouseLook = not core.GUI.mouseLook if not core.GUI.mouseLook: core.GUI.updateMouse() if core.GUI.mouseRay.positive: hitObj = core.GUI.mouseRay.hitObject if "op1" in hitObj: hitObj.onHover() core.GUI.active_widget = hitObj elif "doMe" in hitObj: hitObj.parent.onHover() core.GUI.active_widget = hitObj.parent else: actColor = ([1,1,0] if not core.GUI.mouse["frame"] else [1,0.25,0]) isChild = own["lastHit"] in hitObj.childrenRecursive forget = own["lastHit"] != hitObj and not isChild check = own["lastHit"] == hitObj or isChild if (check and not forget) or (not own["lastHit"]): own["lastHit"] = hitObj if not hitObj.hasText else hitObj.hasText[0] if own["lastHit"].color[0:3] != actColor: own["lastHit"].color[0:3] = actColor elif forget and own["lastHit"]: if not own["lastHit"].invalid: own["lastHit"].color[0:3] = [1,1,1] own["lastHit"] = None if core.GUI.mouse["frame"]: if hasattr(hitObj, "clicked"): core.GUI.active_widget = hitObj core.GUI.active_widget.clicked = True elif own["lastHit"]: if not own["lastHit"].invalid: own["lastHit"].color[0:3] = [1,1,1] own["lastHit"] = None if core.GUI.active_widget: if not core.GUI.active_widget.invalid: if not core.GUI.mouse["frame"] and core.GUI.mouseRay.positive: if "op1" in core.GUI.active_widget: pass else: core.GUI.active_widget.onClick() core.GUI.active_widget = None elif core.GUI.mouseRay.hitObject != core.GUI.active_widget: if "op1" in core.GUI.active_widget: if not core.GUI.active_widget.onHover(): core.GUI.active_widget = None else: core.GUI.active_widget = None core.GUI.mouse.visible = not core.GUI.mouseLook core.GUI.crosshair.visible = core.GUI.mouseLook
def settle(): logic.setTimeScale(1) own['settled'] = True logic.isSettled = True utils.log("SETTLING!!!!!!!")
def settle(): logic.setTimeScale(droneSettings.timeScale / 100.0) own['settled'] = True logic.isSettled = True flowState.log("SETTLING!!!!!!!")