Esempio n. 1
0
        private void OnAuthorityJustKilled(uint killerID, string animEventID, KillEffect killEffect)
        {
            MPSendPacketContainer pc = Singleton <MPManager> .Instance.CreateSendPacket <Packet_Entity_Kill>();

            StringOffset animEventIDOffset = MPMiscs.CreateString(pc.builder, animEventID);

            pc.Finish <Packet_Entity_Kill>(Packet_Entity_Kill.CreatePacket_Entity_Kill(pc.builder, killerID, animEventIDOffset, (byte)killEffect));
            Singleton <MPManager> .Instance.SendReliableToOthers(base.runtimeID, pc);
        }
        protected virtual void OnRemoteTransformSync(Packet_Entity_TransformSync packet)
        {
            this._animatorEntity.SteerFaceDirectionTo(MPMiscs.XZAnglesToForward(packet.StateSync.XzAngle));
            Vector3 targetPosition = MPMiscs.Convert(packet.StateSync.XzPosition);
            Vector3 vector2        = targetPosition - this._animatorEntity.XZPosition;

            if (vector2.sqrMagnitude > 8f)
            {
                this._animatorEntity.SyncPosition(targetPosition);
            }
        }
        protected virtual void AuthoritySendTransformSyncCore()
        {
            if ((Time.time - this._lastSentTime) > this._sendInterval)
            {
                float   xzAngle    = MPMiscs.ForwardToXZAngles(this._lastSetForward);
                Vector3 xZPosition = this._animatorEntity.XZPosition;
                Vector3 vector2    = xZPosition - this._lastSendXZ;
                if (MPMiscs.NeedSyncTransform(vector2.sqrMagnitude, xzAngle - this._lastSentXZAngle))
                {
                    MPSendPacketContainer pc = Singleton <MPManager> .Instance.CreateSendPacket <Packet_Entity_TransformSync>();

                    Packet_Entity_TransformSync.StartPacket_Entity_TransformSync(pc.builder);
                    Packet_Entity_TransformSync.AddStateSync(pc.builder, EntityStateSync.CreateEntityStateSync(pc.builder, this._animatorEntity.XZPosition.x, this._animatorEntity.XZPosition.z, xzAngle));
                    pc.Finish <Packet_Entity_TransformSync>(Packet_Entity_TransformSync.EndPacket_Entity_TransformSync(pc.builder));
                    Singleton <MPManager> .Instance.SendStateUpdateToOthers(base.runtimeID, pc);

                    this._lastSendXZ      = xZPosition;
                    this._lastSentXZAngle = xzAngle;
                    this._lastSentTime    = Time.time;
                }
            }
        }
        public void AuthorityOnAnimatorStateChanged(AnimatorStateInfo fromState, AnimatorStateInfo toState)
        {
            if (!Miscs.ArrayContains <int>(this._muteSyncTagHashes, toState.tagHash))
            {
                MPSendPacketContainer pc = Singleton <MPManager> .Instance.CreateSendPacket <Packet_Entity_AnimatorStateChange>();

                Packet_Entity_AnimatorStateChange.StartPacket_Entity_AnimatorStateChange(pc.builder);
                Packet_Entity_AnimatorStateChange.AddNormalizedTimeTo(pc.builder, (fromState.shortNameHash != toState.shortNameHash) ? toState.normalizedTime : 0f);
                Packet_Entity_AnimatorStateChange.AddToStateHash(pc.builder, toState.shortNameHash);
                Packet_Entity_AnimatorStateChange.AddStateSync(pc.builder, EntityStateSync.CreateEntityStateSync(pc.builder, this._animatorEntity.XZPosition.x, this._animatorEntity.XZPosition.z, MPMiscs.ForwardToXZAngles(this._animatorEntity.FaceDirection)));
                pc.Finish <Packet_Entity_AnimatorStateChange>(Packet_Entity_AnimatorStateChange.EndPacket_Entity_AnimatorStateChange(pc.builder));
                Singleton <MPManager> .Instance.SendStateUpdateToOthers(base.runtimeID, pc);
            }
        }
 protected virtual void OnRemoteEntityAnimatorStateChanged(Packet_Entity_AnimatorStateChange packet)
 {
     this._animatorEntity.SyncAnimatorState(packet.ToStateHash, packet.NormalizedTimeTo);
     this._animatorEntity.SteerFaceDirectionTo(MPMiscs.XZAnglesToForward(packet.StateSync.XzAngle));
 }
Esempio n. 6
0
        public override void PreInitReplicateRemote(MPRecvPacketContainer pc)
        {
            Packet_Monster_MonsterCreation creation = pc.As <Packet_Monster_MonsterCreation>();

            Singleton <MonsterManager> .Instance.CreateMonster(creation.MonsterName, creation.MonsterType, creation.Level, true, MPMiscs.Convert(creation.InitPos), pc.runtimeID, creation.IsElite, creation.UniqueMonsterID, true, false, 0);
        }