protected void RegisterManagedObject(ManagedObjectInfo objectInfo) { UnityEngine.Object Object = objectInfo.GetObject(); if (objectInfo.GetPostSignificanceType() == PostSignificanceType.Sequntial) { ++managedObjectsWithSequentialPostWork; } if (viewpoints.Count > 0) { objectInfo.UpdateSignificance(viewpoints, bSortSignificanceAscending); if (objectInfo.GetPostSignificanceType() == PostSignificanceType.Sequntial) { FManagedObjectPostSignificanceFunction PostSignificanceFunction = objectInfo.GetPostSignificanceFunction(); PostSignificanceFunction(objectInfo, 1.0f, objectInfo.GetSignificance(), false); } } managedObjects.Add(Object, objectInfo); List <ManagedObjectInfo> managedObjectInfos = FindOrAdd(objectInfo.GetTag(), managedObjectsByTag); if (managedObjectInfos.Count > 0) { int LowIndex = 0; int HighIndex = managedObjectInfos.Count - 1; while (true) { int MidIndex = LowIndex + (HighIndex - LowIndex) / 2; if (CompareBySignificanceAscending(objectInfo, managedObjectInfos[MidIndex])) { if (LowIndex == MidIndex) { managedObjectInfos.Insert(LowIndex, objectInfo); break; } else { HighIndex = MidIndex - 1; } } else if (LowIndex == HighIndex) { managedObjectInfos.Insert(LowIndex + 1, objectInfo); break; } else { LowIndex = MidIndex + 1; } } } else { managedObjectInfos.Add(objectInfo); } }
public void UpdateSignificance(List <Transform> inViewpoints) { viewpoints.Clear(); viewpoints.AddRange(inViewpoints); objArray.Capacity = managedObjects.Count; objWithSequentialPostWork.Capacity = managedObjectsWithSequentialPostWork; foreach (ManagedObjectInfo ObjectInfo in managedObjects.Values) { objArray.Add(ObjectInfo); if (ObjectInfo.GetPostSignificanceType() == PostSignificanceType.Sequntial) { SequentialPostWorkPair sequentialPostWorkPair = new SequentialPostWorkPair(); sequentialPostWorkPair.objectInfo = ObjectInfo; sequentialPostWorkPair.oldSignificance = ObjectInfo.GetSignificance(); objWithSequentialPostWork.Add(sequentialPostWorkPair); } } for (int i = 0; i < objArray.Count; i++) { ManagedObjectInfo ObjectInfo = objArray[i]; ObjectInfo.UpdateSignificance(viewpoints, bSortSignificanceAscending); } foreach (SequentialPostWorkPair sequentialPostWorkPair in objWithSequentialPostWork) { ManagedObjectInfo objectInfo = sequentialPostWorkPair.objectInfo; objectInfo.GetPostSignificanceFunction()(objectInfo, sequentialPostWorkPair.oldSignificance, objectInfo.GetSignificance(), false); } objArray.Clear(); objWithSequentialPostWork.Clear(); foreach (List <ManagedObjectInfo> managedObjectInfos in managedObjectsByTag.Values) { managedObjectInfos.Sort(CompareBySignificance); } }
public void UnregisterObject(UnityEngine.Object InObject) { ManagedObjectInfo objectInfo = RemoveAndReturnValue(InObject, managedObjects); if (objectInfo != null) { if (objectInfo.GetPostSignificanceType() == PostSignificanceType.Sequntial) { --managedObjectsWithSequentialPostWork; } if (managedObjectsByTag.ContainsKey(objectInfo.GetTag())) { List <ManagedObjectInfo> ObjectsWithTag = managedObjectsByTag[objectInfo.GetTag()]; if (ObjectsWithTag.Count == 1) { managedObjectsByTag.Remove(objectInfo.GetTag()); } else { ObjectsWithTag.Remove(objectInfo); } FManagedObjectPostSignificanceFunction ManagedObjectPostSignificanceFunction = objectInfo.GetPostSignificanceFunction(); if (ManagedObjectPostSignificanceFunction != null) { ManagedObjectPostSignificanceFunction(objectInfo, objectInfo.GetSignificance(), 1.0f, true); } } objectInfo = null; } }