public static bool Add(ComponentType type, ref UnsafeList reading, ref UnsafeList writing) { if (!type.RequiresJobDependency) { return(false); } // If any other dependency is added the Entity type dependency is removed to avoid the overhead of having all jobs // depend on this. if ((reading.m_size == 1) && reading.Contains(TypeManager.GetTypeIndex <Entity>())) { reading.m_size = 0; } if (type.AccessModeType == ComponentType.AccessMode.ReadOnly) { if (reading.Contains(type.TypeIndex)) { return(false); } if (writing.Contains(type.TypeIndex)) { return(false); } reading.Add(type.TypeIndex); return(true); } else { if (writing.Contains(type.TypeIndex)) { return(false); } var readingIndex = reading.IndexOf(type.TypeIndex); if (readingIndex != -1) { reading.RemoveAtSwapBack <int>(readingIndex); } writing.Add(type.TypeIndex); return(true); } }
internal void RemoveUnmanagedSystemFromUpdateList(SystemHandleUntyped sys) { CheckCreated(); if (m_UnmanagedSystemsToUpdate.Contains(sys) && !m_UnmanagedSystemsToRemove.Contains(sys)) { m_systemSortDirty = true; m_UnmanagedSystemsToRemove.Add(sys); } }
public static bool AddReaderTypeIndex(int typeIndex, ref UnsafeList reading, ref UnsafeList writing) { if (reading.Contains(typeIndex)) { return(false); } if (writing.Contains(typeIndex)) { return(false); } reading.Add(typeIndex); return(true); }
internal void RemoveUnmanagedSystemFromUpdateList(SystemHandleUntyped sys) { CheckCreated(); if (!EnableSystemSorting) { throw new InvalidOperationException("Removing systems from a group is not supported if group.EnableSystemSorting is false."); } if (m_UnmanagedSystemsToUpdate.Contains(sys) && !m_UnmanagedSystemsToRemove.Contains(sys)) { m_systemSortDirty = true; m_UnmanagedSystemsToRemove.Add(sys); } }
public static bool AddWriterTypeIndex(int typeIndex, ref UnsafeList reading, ref UnsafeList writing) { if (writing.Contains(typeIndex)) { return(false); } var readingIndex = reading.IndexOf(typeIndex); if (readingIndex != -1) { reading.RemoveAtSwapBack <int>(readingIndex); } writing.Add(typeIndex); return(true); }
public bool CheckConsistency() { for (int id = 0; id < idToIndex.Length; id++) { var index = idToIndex[id].index; if (index == -1) { if (!freeIDs.Contains(id)) { Debug.LogError($"!freeIDs.Contains({id})"); return(false); } continue; } if (index < 0 || index >= indexToID.Length) { Debug.LogError($"{index} < 0 || {index} >= {indexToID.Length}"); return(false); } if ((indexToID[index] - 1) != id) { Debug.LogError($"indexToID[{index}] - 1 ({(indexToID[index] - 1)}) == {id}"); return(false); } if (sectionManager.IsIndexFree(index)) { Debug.LogError($"sectionManager.IsIndexFree({index})"); return(false); } } for (int index = 0; index < indexToID.Length; index++) { var id = indexToID[index]; if (id == 0) { if (!sectionManager.IsIndexFree(index)) { Debug.LogError($"!sectionManager.IsIndexFree({index})"); return(false); } continue; } id--; if (id < 0 || id >= idToIndex.Length) { Debug.LogError($"{id} < 0 || {id} >= {idToIndex.Length}"); return(false); } if (idToIndex[id].index != index) { Debug.LogError($"idToIndex[{id}].index ({idToIndex[id].index}) == {index}"); return(false); } if (sectionManager.IsIndexFree(index)) { Debug.LogError($"sectionManager.IsIndexFree({index})"); return(false); } } return(true); }