Ejemplo n.º 1
0
    // Token: 0x060009D4 RID: 2516 RVA: 0x000473A4 File Offset: 0x000455A4
    private void OwnerSync()
    {
        ZDO zdo = this.m_nview.GetZDO();

        if (!zdo.IsOwner())
        {
            return;
        }
        if (base.transform.position.y < -5000f)
        {
            if (this.m_body)
            {
                this.m_body.velocity = Vector3.zero;
            }
            ZLog.Log("Object fell out of world:" + base.gameObject.name);
            float   groundHeight = ZoneSystem.instance.GetGroundHeight(base.transform.position);
            Vector3 position     = base.transform.position;
            position.y = groundHeight + 1f;
            base.transform.position = position;
            return;
        }
        if (this.m_syncPosition)
        {
            zdo.SetPosition(this.GetPosition());
            zdo.Set(ZSyncTransform.m_velHash, this.GetVelocity());
            if (this.m_characterParentSync)
            {
                ZDOID   id;
                Vector3 value;
                Vector3 value2;
                if (this.m_character.GetRelativePosition(out id, out value, out value2))
                {
                    zdo.Set(ZSyncTransform.m_parentIDHash, id);
                    zdo.Set(ZSyncTransform.m_relPos, value);
                    zdo.Set(ZSyncTransform.m_velHash, value2);
                }
                else
                {
                    zdo.Set(ZSyncTransform.m_parentIDHash, ZDOID.None);
                }
            }
        }
        if (this.m_syncRotation && base.transform.hasChanged)
        {
            Quaternion rotation = this.m_body ? this.m_body.rotation : base.transform.rotation;
            zdo.SetRotation(rotation);
        }
        if (this.m_syncScale && base.transform.hasChanged)
        {
            zdo.Set(ZSyncTransform.m_scaleHash, base.transform.localScale);
        }
        if (this.m_body)
        {
            if (this.m_syncBodyVelocity)
            {
                this.m_nview.GetZDO().Set(ZSyncTransform.m_bodyVel, this.m_body.velocity);
                this.m_nview.GetZDO().Set(ZSyncTransform.m_bodyAVel, this.m_body.angularVelocity);
            }
            this.m_body.useGravity = this.m_useGravity;
        }
        base.transform.hasChanged = false;
    }