refactor(mirror): adjusted to new changes
This commit is contained in:
		
							parent
							
								
									53dd008df5
								
							
						
					
					
						commit
						e77a42cf7f
					
				
					 1 changed files with 16 additions and 6 deletions
				
			
		| 
						 | 
					@ -33,13 +33,11 @@ public:
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto tick() -> bool override
 | 
						void tick(app::TickInfo tick) override
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		using Surface = lt::surface::SurfaceComponent;
 | 
							using Surface = lt::surface::SurfaceComponent;
 | 
				
			||||||
		using Input = lt::input::InputComponent;
 | 
							using Input = lt::input::InputComponent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static lt::Timer timer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		std::this_thread::sleep_for(std::chrono::milliseconds { 10 });
 | 
							std::this_thread::sleep_for(std::chrono::milliseconds { 10 });
 | 
				
			||||||
		auto should_quit = false;
 | 
							auto should_quit = false;
 | 
				
			||||||
		for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
 | 
							for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
 | 
				
			||||||
| 
						 | 
					@ -78,8 +76,12 @@ public:
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		timer.reset();
 | 
							const auto now = std::chrono::steady_clock::now();
 | 
				
			||||||
		return should_quit;
 | 
							m_last_tick_result = app::TickResult {
 | 
				
			||||||
 | 
								.info = tick,
 | 
				
			||||||
 | 
								.duration = now - tick.start_time,
 | 
				
			||||||
 | 
								.end_time = now,
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void on_register() override
 | 
						void on_register() override
 | 
				
			||||||
| 
						 | 
					@ -90,11 +92,19 @@ public:
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						[[nodiscard]] auto get_last_tick_result() const -> const app::TickResult & override
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return m_last_tick_result;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	Ref<ecs::Registry> m_registry;
 | 
						Ref<ecs::Registry> m_registry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lt::input::InputAction::Key m_quit_action_key;
 | 
						lt::input::InputAction::Key m_quit_action_key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	std::array<lt::input::InputAction::Key, 4> m_debug_action_keys {};
 | 
						std::array<lt::input::InputAction::Key, 4> m_debug_action_keys {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						app::TickResult m_last_tick_result {};
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Mirror: public app::Application
 | 
					class Mirror: public app::Application
 | 
				
			||||||
| 
						 | 
					@ -201,7 +211,7 @@ private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Ref<MirrorSystem> m_mirror_system;
 | 
						Ref<MirrorSystem> m_mirror_system;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lt::ecs::Entity m_window = lt::ecs::null_entity;
 | 
						lt::ecs::EntityId m_window = lt::ecs::null_entity;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
auto app::create_application() -> Scope<app::Application>
 | 
					auto app::create_application() -> Scope<app::Application>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue