LCOV - code coverage report
Current view: top level - src - entity.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 6 8 75.0 %
Date: 2020-10-15 20:26:03 Functions: 4 7 57.1 %

          Line data    Source code
       1             : #ifndef entity_hpp
       2             : #define entity_hpp
       3             : 
       4             : #include "util.h"
       5             : 
       6             : #include <array>
       7             : 
       8             : enum class ComponentType {
       9             :     Mob,
      10             :     Sprite,
      11             :     Physics,
      12             : 
      13             :     Count
      14             : };
      15             : 
      16         712 : class Component {
      17             : public:
      18             :     ident entity{invalid_id};
      19             :     ident id{invalid_id};
      20             : 
      21           0 :     operator bool() const { return id != invalid_id; }
      22             : };
      23             : 
      24             : // buffered_container<Entity>
      25        2490 : class Entity {
      26             : public:
      27             :     ident id{invalid_id};
      28             : 
      29           0 :     operator bool() const { return id != invalid_id; }
      30             : 
      31             :     // hierarchy
      32             :     ident parent{invalid_id};
      33             :     std::vector<ident> children;
      34             : 
      35         202 :     void addChild(Entity& child) {
      36         202 :         child.parent = id;
      37         202 :         children.push_back(child.id);
      38         202 :     }
      39             : 
      40             :     // common
      41             :     int age = 0;
      42             :     int life = -1; // if >= 0 determines a finite life
      43             : 
      44             :     // components
      45             :     ident sprite{invalid_id};
      46             :     ident mob{invalid_id};
      47             :     ident physics{invalid_id};
      48             : 
      49             :     // private:
      50             :     //  static buffered_container<Entity>* container_ {nullptr};
      51             : };
      52             : 
      53             : #endif /* entity_hpp */

Generated by: LCOV version 1.13