Esempio n. 1
0
    public virtual void MountTo(Router parentRouter)
    {
        Debug.LogFormat(
            "Router.Mount {0}({1}) To {2}({3})",
            this.gameObject.name,
            this.gameObject.scene.name,
            parentRouter.gameObject.name,
            parentRouter.gameObject.scene.name);

        var nodeName = gameObject.name;

        parentRouter.mount
        .Where(mount => mount != null && mount.MatchHead(nodeName))
        .Subscribe(
            mount => {
            if (mount.path.Count == 1)
            {
                Debug.LogFormat(
                    "<color=green>Router.mount: {0}({1}) to {2}({3})</color>",
                    mount.router.gameObject.name,
                    mount.router.gameObject.scene.name,
                    this.gameObject.name,
                    this.gameObject.scene.name);
                mount.Print();
                mount.router.MountTo(this);
            }
            ProceedMount(mount, 1);
        })
        .AddTo(this);

        parentRouter.leave
        .Where(plan => plan != null && plan.MatchHead(nodeName))
        .Subscribe(
            plan => {
            Debug.Log("Router(Leave): " + nodeName);
            ProceedLeave(plan, 1);
        })
        .AddTo(this);

        parentRouter.enter
        .Where(plan => plan != null && plan.MatchHead(nodeName))
        .Subscribe(
            plan => {
            Debug.Log("Router(Enter): " + nodeName);
            ProceedEnter(plan, 1);
        })
        .AddTo(this);
    }