Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1.     CollisionSystem &collisionSystem = ecs.getComponentSystems().registerSystem<CollisionSystem>()
  2.         .expects<PositionComponent>()
  3.         .expects<VelocityComponent>();
  4.  
  5.     // CollisionSystem inherits from System class
  6.  
  7.     // ComponentSystems class for actually registering a system
  8.     template<typename T, typename... Args>
  9.     T &registerSystem(Args&&... args)
  10.     {
  11.         // TODO: Check if any of the existing entities fit into the newly registered system
  12.         auto system = std::make_unique<T>(std::forward<Args>(args)...);
  13.         T &sys = *system;
  14.         systems.push_back(std::move(system));
  15.         updateSystems.push_back(&sys);
  16.         logger.log("System Registered: " + sys.name);
  17.  
  18.         return sys;
  19.     }
  20.  
  21.     // System base class
  22.     template<typename T>
  23.     System &expects()
  24.     {
  25.         systemMask = systemMask | T::mask;
  26.         return *this;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement