Shiva是一个具有模块化特性的现代跨平台C++引擎。Shiva用C++17编写,它通过在编译时使用最多的功能,同时在运行时保持可扩展性,旨在在运行时非常快。它基于可单独使用或一起使用的模块体系结构。
示例代码:
#include<shiva/world/world.hpp>namespacemy_game::systems{classbar:publicshiva::ecs::pre_update_system<bar>{public:bar(shiva::entt::dispatcher&dispatcher,shiva::entt::entity_registry®istry,constfloat&fixed_delta_time):system(dispatcher,registry,fixed_delta_time){}voidupdate()noexceptfinal{std::cout<<__FUNCTION__<<"name:"<<class_name()<<std::endl;}reflect_class(bar);staticconstexprautoreflected_functions()noexcept{returnshiva::meta::makeMap();}staticconstexprautoreflected_members()noexcept{returnshiva::meta::makeMap();}};classfoo:publicshiva::ecs::logic_update_system<foo>{public:foo(shiva::entt::dispatcher&dispatcher,shiva::entt::entity_registry®istry,constfloat&fixed_delta_time):system(dispatcher,registry,fixed_delta_time){}voidupdate()noexceptfinal{std::cout<<__FUNCTION__<<"name:"<<class_name()<<std::endl;}reflect_class(foo);staticconstexprautoreflected_functions()noexcept{returnshiva::meta::makeMap();}staticconstexprautoreflected_members()noexcept{returnshiva::meta::makeMap();}};classfolk:publicshiva::ecs::post_update_system<folk>{public:folk(shiva::entt::dispatcher&dispatcher,shiva::entt::entity_registry®istry,constfloat&fixed_delta_time):system(dispatcher,registry,fixed_delta_time){}voidupdate()noexceptfinal{if(counter==10){this->dispatcher_.trigger<shiva::event::quit_game>(0);}std::cout<<__FUNCTION__<<"system:"<<class_name()<<std::endl;counter++;}reflect_class(folk);staticconstexprautoreflected_functions()noexcept{returnshiva::meta::makeMap();}staticconstexprautoreflected_members()noexcept{returnshiva::meta::makeMap();}private:size_tcounter{0};};}namespacemy_game{classmy_world:publicshiva::world{public:my_world(){system_manager_.load_systems<my_game::systems::foo,my_game::systems::bar,my_game::systems::folk>();}};}intmain(){my_game::my_worldworld;returnworld.run();}
评论