Compare commits
	
		
			No commits in common. "c9a4e276309ec176746eb9d35a5966999ee5b07c" and "f27b99f9292fbab03d8c2caa877fddd8a2a16dce" have entirely different histories.
		
	
	
		
			c9a4e27630
			...
			f27b99f929
		
	
		
					 2 changed files with 4 additions and 69 deletions
				
			
		| 
						 | 
					@ -1,23 +1,7 @@
 | 
				
			||||||
#include <catch2/catch_test_macros.hpp>
 | 
					 | 
				
			||||||
#define CATCH_CONFIG_MAIN
 | 
					#define CATCH_CONFIG_MAIN
 | 
				
			||||||
#include <catch2/catch_all.hpp>
 | 
					#include <catch2/catch_all.hpp>
 | 
				
			||||||
#include "../zecsy.hpp"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace zecsy;
 | 
					TEST_CASE("dumb")
 | 
				
			||||||
 | 
					 | 
				
			||||||
TEST_CASE("Create a single entity and verify its existence")
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    world w;
 | 
					    REQUIRE(true);
 | 
				
			||||||
 
 | 
					 | 
				
			||||||
    auto e = w.make_entity();
 | 
					 | 
				
			||||||
    REQUIRE(w.is_alive(e));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TEST_CASE("Destroy an entity and ensure it no longer exists in the world")
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    world w;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    auto e = w.make_entity();
 | 
					 | 
				
			||||||
    w.destroy_entity(e);
 | 
					 | 
				
			||||||
    REQUIRE_FALSE(w.is_alive(e));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										53
									
								
								zecsy.hpp
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								zecsy.hpp
									
									
									
									
									
								
							| 
						 | 
					@ -1,51 +1,2 @@
 | 
				
			||||||
#pragma once
 | 
					//oh hi
 | 
				
			||||||
#include <cstdint>
 | 
					int foo() {}
 | 
				
			||||||
#include <bitset>
 | 
					 | 
				
			||||||
#include <numeric>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifndef MAX_ZECSY_ENTITIES
 | 
					 | 
				
			||||||
    #define MAX_ZECSY_ENTITIES 65536
 | 
					 | 
				
			||||||
#endif // !MAX_ZECSY_ENTITIES
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace zecsy 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    using entity_id = uint64_t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    class world final
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
    public:
 | 
					 | 
				
			||||||
        world() = default;
 | 
					 | 
				
			||||||
        world(const world &) = default;
 | 
					 | 
				
			||||||
        world(world &&) = default;
 | 
					 | 
				
			||||||
        world &operator=(const world &) = default;
 | 
					 | 
				
			||||||
        world &operator=(world &&) = default;
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
        entity_id make_entity();
 | 
					 | 
				
			||||||
        void destroy_entity(entity_id e);
 | 
					 | 
				
			||||||
        bool is_alive(entity_id e) const; 
 | 
					 | 
				
			||||||
    private:
 | 
					 | 
				
			||||||
        std::bitset<MAX_ZECSY_ENTITIES> entities_bitset;
 | 
					 | 
				
			||||||
        entity_id entity_counter = 0;
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    inline entity_id world::make_entity()
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        auto id = entity_counter;
 | 
					 | 
				
			||||||
        entities_bitset.set(id);
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        entity_counter++;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        return id;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    inline void world::destroy_entity(entity_id e)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        entities_bitset.reset(e);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    inline bool world::is_alive(entity_id e) const
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return entities_bitset.test(e);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue