gai-ca2/project/scripts/global/GameManager.gd

51 lines
1.6 KiB
GDScript

class_name GameManager
extends Node
@onready var world: World = $Tileset
@onready var player: PlayerManager = $PlayerManager
@onready var camera: CameraController = $Camera2D as CameraController
@onready var game_ticker: Timer = $GameTick
var tilemap_navigation: TilemapNavigation = TilemapNavigation.new()
func _ready() -> void:
tilemap_navigation.world = world
tilemap_navigation.player = player
player.game_manager = self
world.camp_manager.game_manager = self
world.step_visualizer.game_manager = self
world.step_visualizer.world = world
# game_ticker.start()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("key_1"):
camera.go_to_zooming(Vector2(517.469787597656, 289.846008300781), 1.771561)
if Input.is_action_just_pressed("key_2"):
camera.go_to_zooming(Vector2(789.883972167969, 450.102813720703), 0.56015348434448)
if Input.is_action_just_pressed("key_9"):
world.camp_manager.campfire_light()
world.camp_manager.sleep_effect()
world.camp_manager.campfire_extinguish()
if Input.is_action_just_pressed("force_game_tick"):
_on_game_tick_timeout()
func player_health_depleted():
# TODO
pass
func _on_game_tick_timeout() -> void:
var timer_on_game_tick_timeout: PerformanceTimer = PerformanceTimer.new()
timer_on_game_tick_timeout.display_name = "game tick duration"
tilemap_navigation.game_tick_start()
world.step_visualizer.game_tick_start()
player.game_tick()
tilemap_navigation.game_tick_end()
world.step_visualizer.game_tick_end()
timer_on_game_tick_timeout.stop()