Пример #1
0
        private void RedirectEvent(IEvtWithRemoteID evt, int peerID)
        {
            System.Type           type = MPMappings.SerializeToProtocol(this._eventBuilder, evt);
            MPSendPacketContainer pc   = Singleton <MPManager> .Instance.CreateSendPacket(type, this._eventBuilder);

            pc.state = MPSendContainerState.Finished;
            Singleton <MPManager> .Instance.SendReliableToPeer(evt.GetChannelID(), peerID, pc);
        }
Пример #2
0
        private MPDispatchBehavior CheckForDispatchBehavior(BaseEvent evt)
        {
            System.Type item = evt.GetType();
            if (!MPData.ReplicatedEventTypes.Contains(item))
            {
                return(MPDispatchBehavior.NormalDispatch);
            }
            if (evt.remoteState == EventRemoteState.IsAutorityReceiveRedirected)
            {
                return(MPDispatchBehavior.NormalDispatch);
            }
            if (evt.remoteState == EventRemoteState.IsRemoteReceiveHandledReplcated)
            {
                return(MPDispatchBehavior.NormalDispatch);
            }
            bool flag = false;

            if (evt.remoteState == EventRemoteState.Idle)
            {
                flag = true;
            }
            else if (evt.remoteState == EventRemoteState.NeedCheckForRemote)
            {
                IEvtWithRemoteID eid       = (IEvtWithRemoteID)evt;
                uint             senderID  = eid.GetSenderID();
                uint             remoteID  = eid.GetRemoteID();
                BaseMPIdentity   identity  = this.ResolveRemoteModeIdentity(senderID);
                BaseMPIdentity   identity2 = this.ResolveRemoteModeIdentity(remoteID);
                if ((identity2 == null) || (identity == null))
                {
                    return(MPDispatchBehavior.RemoteModeDropped);
                }
                bool flag2 = identity.isAuthority || ((identity.remoteMode == IdentityRemoteMode.SendAndNoReceive) || (identity.remoteMode == IdentityRemoteMode.SendAndReceive));
                bool flag3 = identity2.isAuthority || ((identity2.remoteMode == IdentityRemoteMode.ReceiveAndNoSend) || (identity2.remoteMode == IdentityRemoteMode.SendAndReceive));
                flag = flag2 && flag3;
            }
            if (!Singleton <RuntimeIDManager> .Instance.IsSyncedRuntimeID(evt.targetID))
            {
                return(MPDispatchBehavior.NormalDispatch);
            }
            BaseMPIdentity identity3 = Singleton <MPManager> .Instance.TryGetIdentity(evt.targetID);

            if (!flag || (identity3 == null))
            {
                return(MPDispatchBehavior.RemoteModeDropped);
            }
            if (identity3.isAuthority)
            {
                return(MPDispatchBehavior.NormalDispatch);
            }
            return(MPDispatchBehavior.RemoteModeDirectToAuthority);
        }