コード例 #1
0
        public void Add_returns_false_if_already_added()
        {
            var registery = new EntityRegistery();
            var system    = new TestEntitySystem();

            var result  = registery.Add(system);
            var result2 = registery.Add(system);

            Assert.True(result);
            Assert.False(result2);
        }
コード例 #2
0
        public void Contains_Returns_True_If_System_Is_Added()
        {
            var registery = new EntityRegistery();
            var system    = new TestEntitySystem();

            registery.Add(system);

            Assert.True(registery.Contains(system));
        }
コード例 #3
0
        public void Get_Returns_System_If_added()
        {
            var registery = new EntityRegistery();
            var system    = new TestEntitySystem();

            registery.Add(system);

            var result = registery.Get <TestEntitySystem>();

            Assert.Equal(system, result);
        }
コード例 #4
0
        public void Add_Set_Registery_On_System()
        {
            var registery = new EntityRegistery();
            var system    = new TestEntitySystem();

            var result = registery.Add(system);


            Assert.True(result);
            Assert.Equal(registery, system.Registery);
        }
コード例 #5
0
        public void Add_Sets_Component_EntityRecord()
        {
            var registery = new EntityRegistery();
            var record    = registery.Create("Test Entity");

            var component = new TestComponent();

            registery.Add(record, component);

            Assert.Equal(record, component.Record);
        }
コード例 #6
0
        public void Remove_Removes_A_Component_From_An_Entity()
        {
            var registery = new EntityRegistery();
            var record    = registery.Create("Test Entity");

            registery.Add(record, new TestComponent());

            var component = record.GetComponent <TestComponent>();

            Assert.NotNull(record.GetComponent <TestComponent>());
            Assert.True(registery.Remove(record, component));
            Assert.Null(record.GetComponent <TestComponent>());
        }
コード例 #7
0
        public void Add_Component_To_Entity()
        {
            var registery = new EntityRegistery();

            var entity        = registery.Create();
            var testComponent = new TestComponent();

            registery.Add(entity, testComponent);

            var component = registery.GetComponent <TestComponent>(entity);


            Assert.Equal(testComponent, component);
        }
コード例 #8
0
        static void Main(string[] args)
        {
            var registery = new EntityRegistery();

            registery.Add(new SampleSystem());

            var e = registery.Create();

            e.AddComponent(new SampleComponent());


            for (float delta = 0f; delta < 1000f; delta++)
            {
                registery.Update(delta);
            }
        }
コード例 #9
0
        public void Get_Component_Gets_Added_Components()
        {
            var registery = new EntityRegistery();
            var record    = registery.Create("Test Entity");

            var component = new TestComponent();

            registery.Add(record, component);

            var registeryComponent = registery.GetComponent <TestComponent>(record);

            Assert.Equal(component, registeryComponent);

            var entityComponent = record.GetComponent <TestComponent>();

            Assert.Equal(component, entityComponent);
        }