Ejemplo n.º 1
0
        private static void OnGameObjectsAdded(GameObjectGroupEventArgs args)
        {
            // Gather a list of components to activate
            int objCount = 0;
            List <ICmpInitializable> initList = new List <ICmpInitializable>();

            foreach (GameObject obj in args.Objects)
            {
                if (!obj.ActiveSingle)
                {
                    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(), false);
            }

            // Invoke the init event on all gathered components in the right order
            foreach (ICmpInitializable component in initList)
            {
                component.OnInit(Component.InitContext.Activate);
            }

            // Fire a global event to indicate that the new objects are ready
            GameObjectsAdded?.Invoke(current, args);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 private void OnSceneOnGameObjectsAdded(object sender, GameObjectGroupEventArgs args)
 {
     GameObjectsAdded?.Invoke(sender, args);
 }
Ejemplo n.º 4
0
 public void TriggerGameObjectsAdded(List <GameObject> gameObjects)
 {
     GameObjectsAdded?.Invoke(this, new GameObjectGroupEventArgs(gameObjects));
 }