예제 #1
0
				for (const Ndk::EntityHandle& entity : GetEntities())
				{
					UpdatableComponent& updatable = entity->GetComponent<UpdatableComponent>();
					updatable.SetUpdated();
				}
			}
	};

	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")
			{
#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();
예제 #3
0
#include <NDK/EntityList.hpp>
#include <NDK/World.hpp>
#include <Catch/catch.hpp>

SCENARIO("EntityList", "[NDK][ENTITYLIST]")
{
	GIVEN("A world & a set of entities")
	{
		Ndk::World world;
		const Ndk::EntityHandle& entity = world.CreateEntity();
		Ndk::EntityList entityList;
		entityList.Insert(entity);

		WHEN("We ask if entity is in there")
		{
			THEN("These results are expected")
			{
				REQUIRE(entityList.Has(entity->GetId()));
				const Ndk::EntityHandle& entity = world.CreateEntity();
				REQUIRE(!entityList.Has(entity->GetId()));
			}
		}

		WHEN("We remove then insert")
		{
			entityList.Remove(*entityList.begin());

			THEN("Set should be empty")
			{
				REQUIRE(entityList.empty());
			}