internal static GroupCore CreateGroup(CacheGroup cacheGroup, Type groupType, Composition composition) { var gr = (Activator.CreateInstance(groupType, true) as GroupCore).Initialize(composition); gr.id = cacheGroup.length; return(gr); }
internal void Add(int tagID, CacheGroup anotherGroupStorage) { if (len == cache.Length - 1) { var l = len << 1; Array.Resize(ref cache, l); Array.Resize(ref tagsID, l); } var pointer = len++; var indexLast = pointer; var index = pointer - 1; if (index >= 0) { if (tagID < tagsID[index]) { var startIndex = 0; var endIndex = indexLast; while (endIndex > startIndex) { var middleIndex = (endIndex + startIndex) / 2; var middleValue = tagsID[middleIndex]; if (middleValue == tagID) { pointer = middleIndex; break; } if (middleValue < tagID) { startIndex = middleIndex + 1; pointer = startIndex; } else { endIndex = middleIndex; pointer = endIndex; } } } } for (int i = indexLast; i >= pointer; i--) { tagsID[i + 1] = tagsID[i]; cache[i + 1] = cache[i]; } cache[pointer] = anotherGroupStorage; tagsID[pointer] = tagID; }
public static bool Contain(this CacheGroup container, GroupCore groupCore) { var len = container.length; for (int i = 0; i < len; i++) { var groupAdded = container.Elements[i]; if (groupAdded.Equals(groupCore)) { return(true); } } return(false); }
public static bool TryGetValue(this CacheGroup container, Type t, Composition composition, out GroupCore group) { var len = container.length; for (int i = 0; i < len; i++) { var instance = container.Elements[i]; if (t != instance.GetType()) { continue; } if (instance.composition.Hash.value == composition.Hash.value) { group = instance; return(true); } } group = default; return(false); }
internal bool TryGetValue(int tagID, out CacheGroup groupOld) { var id = -1; for (int i = 0; i < len; i++) { if (tagsID[i] == tagID) { id = i; break; } id = -1; } if (id > -1) { groupOld = cache[id]; return(true); } groupOld = default; return(false); }
public static GroupCore Add(this CacheGroup container, GroupCore group) { ref var len = ref container.length;
internal static void Add(this CacheGroup container, GroupCore group) { ref var len = ref container.length;