Ejemplo n.º 1
0
        public static void Process(ulong sender, params object[] args)
        {
            //Debug.Log("On Rec Connect Req Response");
            //Core.net.OnConnectRequestResponse(sender, (int)args[0], (int)args[1]);
            int           prefabId    = (int)args[0];
            int           networkId   = (int)args[1];
            int           owner       = (int)args[2];
            int           controller  = (int)args[3];
            int           scopeStatus = (int)args[4];
            NetworkEntity e           = Core.net.GetEntity(owner, networkId);

            if (e == null)
            {
                return;
            }
            Debug.Log("EntityScopeResponse: " + scopeStatus);
            switch (scopeStatus)
            {
            case 0:
                //sender just has no data for this entity, but it is still important. Don't do anything
                break;

            case 1:
                //sender isn't replicating this entity to you anymore because you have fallen out of scope.
                //destroy this locally
                e.DestroyInternal();
                break;

            case 2:
                //sender doesn't care about this entity anymore (they fell out of scope).  You still care about this
                //entity beacuse you sent the EntityScopeRequest.
                //take control of this entity.
                //sending a take control request will not come back because the entity no longer exists on the other end.
                //so assume the request came back as true
                if (e.canMigrate)
                {
                    e.TakeControlInternal();
                }
                else
                {
                    e.DestroyInternal();
                }
                break;
            }

            //if(e != null && canDestroy) {
            //    e.DestroyInternal();
            //}
        }