#pragma warning restore 649

        unsafe void SetValue(int index, int value, ChangeMode mode)
        {
            EmptySystem.Update();
            var entityArray = EmptySystem.GetComponentGroup(typeof(EcsTestData)).GetEntityArray();
            var entity      = entityArray[index];

            if (mode == ChangeMode.ComponentDataArray)
            {
                var array = EmptySystem.GetComponentGroup(typeof(EcsTestData)).GetComponentDataArray <EcsTestData>();
                array[index] = new EcsTestData(value);
            }
            else if (mode == ChangeMode.SetComponentData)
            {
                m_Manager.SetComponentData(entity, new EcsTestData(value));
            }
            else if (mode == ChangeMode.SetComponentDataFromEntity)
            {
                //@TODO: Chaining correctness... Definately not implemented right now...
                var array = EmptySystem.GetComponentDataFromEntity <EcsTestData>(false);
                array[entity] = new EcsTestData(value);
            }
            else if (mode == ChangeMode.ComponentGroupArray)
            {
                *(EmptySystem.GetEntities <GroupRW>()[index].Data) = new EcsTestData(value);
            }
        }
예제 #2
0
        [StandaloneFixme] // Real problem : Atomic Safety
        public void ComponentDataArrayFromEntityThrowsIfNotExist()
        {
            var entity          = m_Manager.CreateEntity(typeof(EcsTestData));
            var destroyedEntity = m_Manager.CreateEntity(typeof(EcsTestData));

            m_Manager.DestroyEntity(destroyedEntity);

            var data = EmptySystem.GetComponentDataFromEntity <EcsTestData2>();

            Assert.Throws <System.ArgumentException>(() => { data[entity] = new EcsTestData2(); });
            Assert.Throws <System.ArgumentException>(() => { data[destroyedEntity] = new EcsTestData2(); });

            Assert.Throws <System.ArgumentException>(() => { var p = data[entity]; });
            Assert.Throws <System.ArgumentException>(() => { var p = data[destroyedEntity]; });
        }
예제 #3
0
#pragma warning restore 649

        // Running SetValue should change the chunk version for the data it's writing to.
        unsafe void SetValue(int index, int value, ChangeMode mode)
        {
            EmptySystem.Update();
            var entityArray = EmptySystem.GetEntityQuery(typeof(EcsTestData)).ToEntityArray(Allocator.TempJob);
            var entity      = entityArray[index];

            if (mode == ChangeMode.SetComponentData)
            {
                m_Manager.SetComponentData(entity, new EcsTestData(value));
            }
            else if (mode == ChangeMode.SetComponentDataFromEntity)
            {
                //@TODO: Chaining correctness... Definitely not implemented right now...
                var array = EmptySystem.GetComponentDataFromEntity <EcsTestData>(false);
                array[entity] = new EcsTestData(value);
            }

            entityArray.Dispose();
        }
예제 #4
0
        void GetValue(ChangeMode mode)
        {
            EmptySystem.Update();
            var entityArray = EmptySystem.GetComponentGroup(typeof(EcsTestData)).GetEntityArray();

            if (mode == ChangeMode.ComponentDataArray)
            {
                var array = EmptySystem.GetComponentGroup(typeof(EcsTestData)).GetComponentDataArray <EcsTestData>();
                for (int i = 0; i != array.Length; i++)
                {
                    var val = array[i];
                }
            }
            else if (mode == ChangeMode.SetComponentData)
            {
                for (int i = 0; i != entityArray.Length; i++)
                {
                    m_Manager.GetComponentData <EcsTestData>(entityArray[i]);
                }
            }
            else if (mode == ChangeMode.SetComponentDataFromEntity)
            {
                var array = EmptySystem.GetComponentDataFromEntity <EcsTestData>(false);
                for (int i = 0; i != entityArray.Length; i++)
                {
                    m_Manager.GetComponentData <EcsTestData>(entityArray[i]);
                }
            }
            else if (mode == ChangeMode.ComponentGroupArray)
            {
                foreach (var e in EmptySystem.GetEntities <GroupRO>())
                {
                    ;
                }
            }
        }