public void AddComponentToEntity() { ECSWorld world = new ECSWorld(); var buffer = new EntityCommandBuffer(world); SharedComponent1 shared1 = new SharedComponent1(); EntityArchetype archetype = EntityArchetype.Empty; archetype = archetype.Add <TestComponent1>(); archetype = archetype.AddShared(shared1); Entity target = world.Instantiate(archetype); buffer.AddComponent(target, new TestComponent2 { i = 2, d = 3, f = 4 }); buffer.Playback(); ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent1>(); query.IncludeReadWrite <TestComponent2>(); query.IncludeShared <SharedComponent1>(); Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => { Assert.Equal(1, accessor.GetEntityData().Length); var cData = accessor.GetComponentData <TestComponent2>(); Assert.Equal(2, cData[0].i); Assert.Equal(3d, cData[0].d, 3); Assert.Equal(4f, cData[0].f, 3); }); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeReadonly <FollowTarget>(); query.IncludeReadWrite <Position>(); query.IncludeReadWrite <Rotation>(); return(query); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeShared <FaceCameraComponent>(); query.IncludeReadWrite <Position>(); query.IncludeReadWrite <Rotation>(); return(query); }
public override ComponentQuery GetQuery() { var query = new ComponentQuery(); query.IncludeShared <Camera>(); query.IncludeReadWrite <Position>(); query.IncludeReadWrite <Rotation>(); query.IncludeReadonly <CameraFlightComponent>(); return(query); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeReadonly <Player>(); query.IncludeReadonly <Rotation>(); query.IncludeReadWrite <Velocity>(); query.IncludeReadWrite <AngularVelocity>(); return(query); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <RigidBody>(); query.IncludeReadWrite <Position>(); query.IncludeReadWrite <Rotation>(); query.IncludeReadonly <Velocity>(); query.IncludeReadonly <AngularVelocity>(); return(query); }
public override ComponentQuery GetQuery() { var query = new ComponentQuery(); query.IncludeReadWrite <Position>(); query.IncludeReadWrite <Rotation>(); query.IncludeReadWrite <Velocity>(); query.IncludeReadWrite <AngularVelocity>(); query.IncludeReadonly <PhysicsBodyLockedValues>(); query.IncludeReadonly <PhysicsBodyLockAxis>(); return(query); }
public void Include() { ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent1>(); query.IncludeReadWrite <TestComponent2>(); Assert.False(query.Matches(archetypeEmpty)); Assert.True(query.Matches(archetypeC1C2S1)); Assert.True(query.Matches(archetypeC1C2S1S2)); Assert.False(query.Matches(archetypeC1)); Assert.True(query.Matches(archetypeC1C2)); Assert.False(query.Matches(archetypeC1S1)); Assert.False(query.Matches(archetypeC2S1)); }
public void HashCodeSame() { ComponentQuery query1 = new ComponentQuery(); query1.IncludeReadWrite <TestComponent1>(); ComponentQuery query2 = new ComponentQuery(); query2.IncludeReadWrite <TestComponent1>(); Assert.Equal(query1.GetHashCode(), query2.GetHashCode()); query1 = new ComponentQuery(); query1.Exclude <TestComponent1>(); query2 = new ComponentQuery(); query2.Exclude <TestComponent1>(); Assert.Equal(query1.GetHashCode(), query2.GetHashCode()); query1 = new ComponentQuery(); query1.IncludeShared <SharedComponent1>(); query2 = new ComponentQuery(); query2.IncludeShared <SharedComponent1>(); Assert.Equal(query1.GetHashCode(), query2.GetHashCode()); query1 = new ComponentQuery(); query1.ExcludeShared <SharedComponent1>(); query2 = new ComponentQuery(); query2.ExcludeShared <SharedComponent1>(); Assert.Equal(query1.GetHashCode(), query2.GetHashCode()); }
public void CreateEntityFromPrefab() { ECSWorld world = new ECSWorld(); var buffer = new EntityCommandBuffer(world); SharedComponent1 shared1 = new SharedComponent1(); Prefab prefab = new Prefab(); prefab.AddComponent(new TestComponent1 { i = 1, d = 2, f = 3 }); prefab.AddSharedComponent(shared1); buffer.CreateEntity(prefab); buffer.Playback(); ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent1>(); query.IncludeShared <SharedComponent1>(); Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => { Assert.Equal(1, accessor.GetEntityData().Length); var cData = accessor.GetComponentData <TestComponent1>(); Assert.Equal(1, cData[0].i); Assert.Equal(2d, cData[0].d, 3); Assert.Equal(3f, cData[0].f, 3); var shared = accessor.GetSharedComponentData <SharedComponent1>(); Assert.Same(shared1, shared); }); }
public void RemoveSharedComponentFromEntity() { ECSWorld world = new ECSWorld(); var buffer = new EntityCommandBuffer(world); SharedComponent1 shared1 = new SharedComponent1(); EntityArchetype archetype = EntityArchetype.Empty; archetype = archetype.Add <TestComponent1>(); archetype = archetype.AddShared(shared1); Entity target = world.Instantiate(archetype); buffer.RemoveSharedComponent <SharedComponent1>(target); buffer.Playback(); ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent1>(); query.ExcludeShared <SharedComponent1>(); Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => { Assert.Equal(1, accessor.GetEntityData().Length); }); }
public void DestroyEntity() { ECSWorld world = new ECSWorld(); var buffer = new EntityCommandBuffer(world); SharedComponent1 shared1 = new SharedComponent1(); EntityArchetype archetype = EntityArchetype.Empty; archetype = archetype.Add <TestComponent1>(); archetype = archetype.AddShared(shared1); buffer.CreateEntity(archetype); buffer.Playback(); ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent1>(); query.IncludeShared <SharedComponent1>(); Entity e = default; Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => { Assert.Equal(1, accessor.GetEntityData().Length); e = accessor.GetEntityData()[0]; }); buffer.DestroyEntity(e); buffer.Playback(); Assert.Empty(world.ComponentManager.GetBlocks(query)); }
public override ComponentQuery GetQuery() { posQuery.IncludeReadonly <Position>(); posQuery.Exclude <Rotation>(); posQuery.Exclude <Scale>(); posQuery.IncludeReadWrite <ObjectToWorld>(); return(posQuery); }
public override ComponentQuery GetQuery() { var query = new ComponentQuery(); query.IncludeReadonly <CameraFollow>(); query.IncludeReadWrite <Position>(); return(query); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <BoundingBox>(); query.IncludeReadonly <ObjectToWorld>(); query.IncludeShared <MeshRenderer>(); return(query); }
public override ComponentQuery GetQuery() { ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <RigidBody>(); query.IncludeReadonly <InternalColliderHandle>(); query.Exclude <InternalRigidBodyHandle>(); query.Exclude <StaticRigidBody>(); return(query); }
public void HashCodeNotZero() { ComponentQuery query1 = new ComponentQuery(); query1.IncludeReadWrite <TestComponent1>(); Assert.NotEqual(0, query1.GetHashCode()); query1 = new ComponentQuery(); query1.Exclude <TestComponent1>(); Assert.NotEqual(0, query1.GetHashCode()); query1 = new ComponentQuery(); query1.IncludeShared <SharedComponent1>(); Assert.NotEqual(0, query1.GetHashCode()); query1 = new ComponentQuery(); query1.ExcludeShared <SharedComponent1>(); Assert.NotEqual(0, query1.GetHashCode()); }
public void CreateEntitySetComponent() { ECSWorld world = new ECSWorld(); var buffer = new EntityCommandBuffer(world); SharedComponent1 shared1 = new SharedComponent1(); Prefab prefab = new Prefab(); prefab.AddComponent(new TestComponentVector3() { value = Vector3.UnitY }); prefab.AddSharedComponent(shared1); buffer.CreateEntity(prefab); buffer.CreateEntity(prefab); buffer.SetComponent(new TestComponentVector3 { value = Vector3.UnitX }); buffer.CreateEntity(prefab.Archetype); buffer.SetComponent(new TestComponentVector3 { value = Vector3.UnitZ }); buffer.Playback(); ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponentVector3>(); query.IncludeShared <SharedComponent1>(); Assert.Collection(world.ComponentManager.GetBlocks(query), accessor => { Assert.Equal(3, accessor.GetEntityData().Length); var cData = accessor.GetComponentData <TestComponentVector3>(); Assert.Equal(Vector3.UnitY, cData[0].value); Assert.Equal(Vector3.UnitX, cData[1].value); Assert.Equal(Vector3.UnitZ, cData[2].value); var shared = accessor.GetSharedComponentData <SharedComponent1>(); Assert.Same(shared1, shared); }); }
public void Setup() { world = new ECSWorld(); var archetype = EntityArchetype.Empty.Add <TestComponent>(); entities = world.EntityManager.CreateEntities(numEntities, archetype); foreach (Entity entity in entities) { entity.SetComponent(world, new TestComponent() { x = 1, y = 2, z = 3 }); } ComponentQuery query = new ComponentQuery(); query.IncludeReadWrite <TestComponent>(); Core.ECS.JobSystem.Jobs.Setup(); }