private void OnOpen() { collection.Set(MessageCodes.EnteredScene, SceneEntered.ToMessageHandler()); collection.Set(MessageCodes.ChangeScene, SceneChanged.ToMessageHandler()); collection.Set(MessageCodes.GameObjectAdded, GameObjectsAdded.ToMessageHandler()); collection.Set(MessageCodes.GameObjectRemoved, GameObjectsRemoved.ToMessageHandler()); collection.Set(MessageCodes.PositionChanged, PositionChanged.ToMessageHandler()); collection.Set(MessageCodes.AnimationStateChanged, AnimationStateChanged.ToMessageHandler()); collection.Set(MessageCodes.Attacked, Attacked.ToMessageHandler()); collection.Set(MessageCodes.BubbleNotification, BubbleMessageReceived.ToMessageHandler()); Connected?.Invoke(); }
private static void OnGameObjectsRemoved(GameObjectGroupEventArgs args) { // Fire a global event to indicate that the objects are going to be shut down GameObjectsRemoved?.Invoke(current, args); // Gather a list of components to deactivate int objCount = 0; List <ICmpInitializable> initList = new List <ICmpInitializable>(); foreach (GameObject obj in args.Objects) { if (!obj.ActiveSingle && !obj.Disposed) { continue; } obj.GatherInitComponents(initList, false); objCount++; } // If we collected components from more than one object, sort by exec order. // Otherwise, we can safely assume that the list is already sorted. if (objCount > 1) { Component.ExecOrder.SortTypedItems(initList, item => item.GetType(), true); } else { initList.Reverse(); } // Invoke the init event on all gathered components in the right order foreach (ICmpInitializable component in initList) { component.OnShutdown(Component.ShutdownContext.Deactivate); } }