public void DeregisterZenBehaviour(IZenBehaviour removedZenBehaviour) { ZenImplementationFlags currFlags; //already loaded this type, add to lists via impl flags typeImplDict.TryGetValue(removedZenBehaviour.ObjectType, out currFlags); if (currFlags.HasOnStart) { OnStartList.Remove((IOnStart)removedZenBehaviour); } if (currFlags.HasOnUpdate) { OnUpdateList.Remove((IOnUpdate)removedZenBehaviour); } if (currFlags.HasOnFixedUpdate) { OnFixedUpdateList.Remove((IOnFixedUpdate)removedZenBehaviour); } if (currFlags.HasOnLateUpdate) { OnLateUpdateList.Remove((IOnLateUpdate)removedZenBehaviour); } if (currFlags.HasInitAfterECS) { InitAfterEcsList.Remove((IInitAfterECS)removedZenBehaviour); } }
public void RegisterZenBehaviour(IZenBehaviour newZenBehaviour) { if (Application.isEditor && !Application.isPlaying) { return; } ZenImplementationFlags currFlags; if (typeImplDict.ContainsKey(newZenBehaviour.ObjectType)) { //already loaded this type, add to lists via impl flags typeImplDict.TryGetValue(newZenBehaviour.ObjectType, out currFlags); } else { //First encounter with this type currFlags.HasOnAwake = newZenBehaviour is IOnAwake; currFlags.HasOnStart = newZenBehaviour is IOnStart; currFlags.HasOnUpdate = newZenBehaviour is IOnUpdate; currFlags.HasOnFixedUpdate = newZenBehaviour is IOnFixedUpdate; currFlags.HasOnLateUpdate = newZenBehaviour is IOnLateUpdate; currFlags.HasInitAfterECS = newZenBehaviour is IInitAfterECS; typeImplDict.Add(newZenBehaviour.ObjectType, currFlags); } if (currFlags.HasOnStart) { OnStartList.Add((IOnStart)newZenBehaviour); OnStartList.Sort((a, b) => a.ExecutionPriority.CompareTo(b.ExecutionPriority)); } if (currFlags.HasOnUpdate) { OnUpdateList.Add((IOnUpdate)newZenBehaviour); OnUpdateList.Sort((a, b) => a.ExecutionPriority.CompareTo(b.ExecutionPriority)); } if (currFlags.HasOnFixedUpdate) { OnFixedUpdateList.Add((IOnFixedUpdate)newZenBehaviour); OnFixedUpdateList.Sort((a, b) => a.ExecutionPriority.CompareTo(b.ExecutionPriority)); } if (currFlags.HasOnLateUpdate) { OnLateUpdateList.Add((IOnLateUpdate)newZenBehaviour); OnLateUpdateList.Sort((a, b) => a.ExecutionPriority.CompareTo(b.ExecutionPriority)); } if (currFlags.HasInitAfterECS) { InitAfterEcsList.Add((IInitAfterECS)newZenBehaviour); InitAfterEcsList.Sort((a, b) => a.ExecutionPriority.CompareTo(b.ExecutionPriority)); } if (currFlags.HasOnAwake) { ((IOnAwake)newZenBehaviour).OnAwake(); } }