#include <NDK/EntityOwner.hpp>
#include <NDK/World.hpp>
#include <Catch/catch.hpp>

SCENARIO("EntityOwner", "[NDK][ENTITYOWNER]")
{
	GIVEN("A world & an entity")
	{
		Ndk::World world(false);
		Ndk::EntityHandle entity = world.CreateEntity();

		WHEN("We set the ownership of the entity to our owner")
		{
			THEN("Entity is still valid")
			{
				REQUIRE(entity.IsValid());

				Ndk::EntityOwner entityOwner(entity);

				world.Refresh();
				CHECK(entity.IsValid());
			}

			THEN("Moving an entity owner by constructor works")
			{
				REQUIRE(entity.IsValid());

				Ndk::EntityOwner entityOwner(entity);
				Ndk::EntityOwner entityOwner2(std::move(entityOwner));
				entityOwner.Reset();
Exemple #2
0
			}
	};

	Ndk::SystemIndex UpdateSystem::systemIndex;
}

SCENARIO("World", "[NDK][WORLD]")
{
	GIVEN("A brave new world and the update system")
	{
		Ndk::World world(false);
		Ndk::BaseSystem& system = world.AddSystem<UpdateSystem>();

		WHEN("We had a new entity with an updatable component and a system")
		{
			const Ndk::EntityHandle& entity = world.CreateEntity();
			UpdatableComponent& component = entity->AddComponent<UpdatableComponent>();

			THEN("We can get our entity and our system")
			{
				const Ndk::EntityHandle& fetchedEntity = world.GetEntity(entity->GetId());
				REQUIRE(fetchedEntity->GetWorld() == &world);
			}

			THEN("We can clone it")
			{
				const Ndk::EntityHandle& clone = world.CloneEntity(entity->GetId());
				REQUIRE(world.IsEntityValid(clone));
			}
		}