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) { 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>()) { ; } } }
#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); } }
#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(); }
// Running GetValue should not trigger any changes to chunk version. void GetValue(ChangeMode mode) { EmptySystem.Update(); var entityArray = EmptySystem.GetEntityQuery(typeof(EcsTestData)).ToEntityArray(Allocator.TempJob); if (mode == ChangeMode.SetComponentData) { for (int i = 0; i != entityArray.Length; i++) { m_Manager.GetComponentData <EcsTestData>(entityArray[i]); } } else if (mode == ChangeMode.SetComponentDataFromEntity) { for (int i = 0; i != entityArray.Length; i++) { m_Manager.GetComponentData <EcsTestData>(entityArray[i]); } } entityArray.Dispose(); }