system.gd 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. extends Node
  2. enum PhysicsEngine {
  3. GODOT_PHYSICS,
  4. JOLT_PHYSICS,
  5. OTHER,
  6. }
  7. var _engine := PhysicsEngine.OTHER
  8. func _enter_tree() -> void:
  9. process_mode = Node.PROCESS_MODE_ALWAYS
  10. # Always enable visible collision shapes on startup
  11. # (same as the Debug > Visible Collision Shapes option).
  12. get_tree().debug_collisions_hint = true
  13. var engine_string: String = ProjectSettings.get_setting("physics/3d/physics_engine")
  14. match engine_string:
  15. "DEFAULT":
  16. _engine = PhysicsEngine.GODOT_PHYSICS
  17. "GodotPhysics3D":
  18. _engine = PhysicsEngine.GODOT_PHYSICS
  19. "Jolt Physics":
  20. _engine = PhysicsEngine.JOLT_PHYSICS
  21. _:
  22. _engine = PhysicsEngine.OTHER
  23. func _process(_delta: float) -> void:
  24. if Input.is_action_just_pressed(&"toggle_full_screen"):
  25. if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
  26. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
  27. else:
  28. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
  29. if Input.is_action_just_pressed(&"toggle_debug_collision"):
  30. var debug_collision_enabled := not _is_debug_collision_enabled()
  31. _set_debug_collision_enabled(debug_collision_enabled)
  32. if debug_collision_enabled:
  33. Log.print_log("Debug Collision ON")
  34. else:
  35. Log.print_log("Debug Collision OFF")
  36. if Input.is_action_just_pressed(&"toggle_pause"):
  37. get_tree().paused = not get_tree().paused
  38. if Input.is_action_just_pressed(&"exit"):
  39. get_tree().quit()
  40. func get_physics_engine() -> PhysicsEngine:
  41. return _engine
  42. func _set_debug_collision_enabled(enabled: bool) -> void:
  43. get_tree().debug_collisions_hint = enabled
  44. func _is_debug_collision_enabled() -> bool:
  45. return get_tree().debug_collisions_hint