💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
3.4 KiB

  1. /*
  2. * Copyright (C) 2021 Christopher J. Howard
  3. *
  4. * This file is part of Antkeeper source code.
  5. *
  6. * Antkeeper source code is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Antkeeper source code is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "game/states/brood.hpp"
  20. #include "entity/archetype.hpp"
  21. #include "entity/commands.hpp"
  22. #include "entity/components/observer.hpp"
  23. #include "entity/components/camera-follow.hpp"
  24. #include "entity/components/terrain.hpp"
  25. #include "entity/components/transform.hpp"
  26. #include "entity/systems/control.hpp"
  27. #include "entity/systems/camera.hpp"
  28. #include "entity/systems/tool.hpp"
  29. #include "animation/screen-transition.hpp"
  30. #include "animation/ease.hpp"
  31. #include "resources/resource-manager.hpp"
  32. #include "renderer/passes/sky-pass.hpp"
  33. namespace game {
  34. namespace state {
  35. namespace brood {
  36. void enter(game::context* ctx)
  37. {
  38. // Switch to underground camera
  39. ctx->surface_camera->set_active(false);
  40. ctx->underground_camera->set_active(true);
  41. ctx->underground_ambient_light->set_intensity(1.0f);
  42. // Create camera focal point
  43. {
  44. entity::component::transform focal_point_transform;
  45. focal_point_transform.local = math::identity_transform<float>;
  46. focal_point_transform.warp = true;
  47. ctx->entity_registry->assign_or_replace<entity::component::transform>(ctx->focal_point_entity, focal_point_transform);
  48. entity::component::camera_follow focal_point_follow;
  49. ctx->entity_registry->assign_or_replace<entity::component::camera_follow>(ctx->focal_point_entity, focal_point_follow);
  50. }
  51. // Setup camera
  52. ctx->underground_camera->look_at({0, 0, 1}, {0, 0, 0}, {0, 1, 0});
  53. ctx->underground_camera->set_exposure(0.0f);
  54. ctx->camera_system->set_camera(ctx->underground_camera);
  55. ctx->tool_system->set_camera(ctx->underground_camera);
  56. ctx->tool_system->set_orbit_cam(ctx->camera_system->get_orbit_cam());
  57. entity::system::control* control_system = ctx->control_system;
  58. control_system->update(0.0, 0.0);
  59. control_system->set_nest(nullptr);
  60. // Create larva
  61. {
  62. entity::archetype* larva_archetype = ctx->resource_manager->load<entity::archetype>("ant-larva.ent");
  63. auto larva_eid = larva_archetype->create(*ctx->entity_registry);
  64. entity::command::warp_to(*ctx->entity_registry, larva_eid, {0.0f, 0.0f, 0.0f});
  65. entity::command::assign_render_layers(*ctx->entity_registry, larva_eid, 0b1);
  66. }
  67. // Create cocoon
  68. {
  69. entity::archetype* cocoon_archetype = ctx->resource_manager->load<entity::archetype>("ant-cocoon.ent");
  70. auto cocoon_eid = cocoon_archetype->create(*ctx->entity_registry);
  71. entity::command::warp_to(*ctx->entity_registry, cocoon_eid, {-50, 0.1935f, 0});
  72. entity::command::assign_render_layers(*ctx->entity_registry, cocoon_eid, 0b1);
  73. }
  74. ctx->underground_scene->update_tweens();
  75. // Start fade in
  76. ctx->fade_transition->transition(1.0f, true, ease<float>::in_quad);
  77. }
  78. void exit(game::context* ctx)
  79. {}
  80. } // namespace brood
  81. } // namespace state
  82. } // namespace game