From c8059300ace55e441251d4624fcd19b007078d75 Mon Sep 17 00:00:00 2001 From: En Yi Date: Tue, 27 Aug 2024 16:02:55 +0800 Subject: [PATCH] Fix freecam bug on game restart Changelog: - Lock player if freecam is active --- scenes/editor_scene.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scenes/editor_scene.c b/scenes/editor_scene.c index 2bad01e..7dd0beb 100644 --- a/scenes/editor_scene.c +++ b/scenes/editor_scene.c @@ -119,7 +119,7 @@ static void level_scene_render_func(Scene_t* scene) selection_rec.x + current_spawn_selection * SELECTION_TILE_SIZE, selection_rec.y, SELECTION_TILE_SIZE, SELECTION_TILE_SIZE, GREEN ); - DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour\nB to toggle grid, V to set spawn point", selection_rec.x, selection_rec.y + selection_rec.height + 2, 14, BLACK); + DrawText("R to reset the map, Q/E to cycle the selection,\nF to toggle metal crates. T to toggle crate spawn behaviour\nZ to change tileset, X to toggle grid\nC to set spawn point, V to toggle free cam", selection_rec.x, selection_rec.y + selection_rec.height + 2, 14, BLACK); draw_pos.x = game_rec.x + (MAX_SPAWN_TYPE + 1) * SELECTION_TILE_SIZE; sprintf(buffer, "Selection: %s", get_spawn_selection_string(current_spawn_selection)); @@ -850,6 +850,11 @@ static void restart_editor_level(Scene_t* scene) Entity_t* p_player = create_player(&scene->ent_manager); p_player->position = data->player_spawn; + CPlayerState_t* p_pstate = get_component(p_player, CPLAYERSTATE_T); + if (data->camera.mode == CAMERA_RANGED_MOVEMENT) + { + p_pstate->locked = true; + } update_entity_manager(&scene->ent_manager); for (size_t i = 0; i < tilemap.width; ++i)