Ejemplo n.º 1
0
    // Token: 0x06000887 RID: 2183 RVA: 0x00041908 File Offset: 0x0003FB08
    private void RemoveObjects(List <ZDO> currentNearObjects, List <ZDO> currentDistantObjects)
    {
        int frameCount = Time.frameCount;

        foreach (ZDO zdo in currentNearObjects)
        {
            zdo.m_tempRemoveEarmark = frameCount;
        }
        foreach (ZDO zdo2 in currentDistantObjects)
        {
            zdo2.m_tempRemoveEarmark = frameCount;
        }
        this.m_tempRemoved.Clear();
        foreach (ZNetView znetView in this.m_instances.Values)
        {
            if (znetView.GetZDO().m_tempRemoveEarmark != frameCount)
            {
                this.m_tempRemoved.Add(znetView);
            }
        }
        for (int i = 0; i < this.m_tempRemoved.Count; i++)
        {
            ZNetView znetView2 = this.m_tempRemoved[i];
            ZDO      zdo3      = znetView2.GetZDO();
            znetView2.ResetZDO();
            UnityEngine.Object.Destroy(znetView2.gameObject);
            if (!zdo3.m_persistent && zdo3.IsOwner())
            {
                ZDOMan.instance.DestroyZDO(zdo3);
            }
            this.m_instances.Remove(zdo3);
        }
    }
Ejemplo n.º 2
0
 // Token: 0x060007CD RID: 1997 RVA: 0x0003D550 File Offset: 0x0003B750
 public void DestroyZDO(ZDO zdo)
 {
     if (!zdo.IsOwner())
     {
         return;
     }
     this.m_destroySendList.Add(zdo.m_uid);
 }
Ejemplo n.º 3
0
    // Token: 0x0600087D RID: 2173 RVA: 0x000414C0 File Offset: 0x0003F6C0
    public void Destroy(GameObject go)
    {
        ZNetView component = go.GetComponent <ZNetView>();

        if (component && component.GetZDO() != null)
        {
            ZDO zdo = component.GetZDO();
            component.ResetZDO();
            this.m_instances.Remove(zdo);
            if (zdo.IsOwner())
            {
                ZDOMan.instance.DestroyZDO(zdo);
            }
        }
        UnityEngine.Object.Destroy(go);
    }
Ejemplo n.º 4
0
        public static List <Container> GetNearbyContainers(Vector3 center)
        {
            List <Container> containers = new List <Container>();

            foreach (Container container in containerList)
            {
                ZNetView znv = (ZNetView)typeof(Container).GetField("m_nview", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(container);
                if (znv == null)
                {
                    continue;
                }
                ZDO zdo = (ZDO)typeof(ZNetView).GetField("m_zdo", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(znv);
                if (zdo == null)
                {
                    continue;
                }
                if (container != null && container.transform != null && zdo.IsOwner() && Vector3.Distance(center, container.transform.position) < m_range.Value)
                {
                    containers.Add(container);
                }
            }
            return(containers);
        }
Ejemplo n.º 5
0
        private static bool Prefix(ref ZNetScene __instance, ref List<ZDO> currentNearObjects, ref List<ZDO> currentDistantObjects)
        {
            int frameCount = Time.frameCount;

            foreach (ZDO currentNearObject in currentNearObjects)
                currentNearObject.m_tempRemoveEarmark = frameCount;
            foreach (ZDO currentDistantObject in currentDistantObjects)
                currentDistantObject.m_tempRemoveEarmark = frameCount;

            __instance.m_tempRemoved.Clear();

            foreach (ZNetView znetView in __instance.m_instances.Values)
            {
                if (znetView.GetZDO().m_tempRemoveEarmark != frameCount)
                    __instance.m_tempRemoved.Add(znetView);
            }

            for (int index = 0; index < __instance.m_tempRemoved.Count; ++index)
            {
                ZNetView znetView = __instance.m_tempRemoved[index];

                ZDO zdo = znetView.GetZDO();

                znetView.ResetZDO();

                UnityEngine.Object.Destroy((UnityEngine.Object)znetView.gameObject);

                if (!zdo.m_persistent && zdo.IsOwner())
                    ZDOMan.instance.DestroyZDO(zdo);

                __instance.m_instances.Remove(zdo);
            }

            // Skip original code.
            return false;
        }
Ejemplo n.º 6
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;
    }
Ejemplo n.º 7
0
    // Token: 0x060009D6 RID: 2518 RVA: 0x000477E4 File Offset: 0x000459E4
    private void ClientSync(float dt)
    {
        ZDO zdo = this.m_nview.GetZDO();

        if (zdo.IsOwner())
        {
            return;
        }
        int frameCount = Time.frameCount;

        if (this.m_lastUpdateFrame == frameCount)
        {
            return;
        }
        this.m_lastUpdateFrame = frameCount;
        if (this.m_isKinematicBody)
        {
            if (this.m_syncPosition)
            {
                Vector3 vector = zdo.GetPosition();
                if (Vector3.Distance(this.m_body.position, vector) > 5f)
                {
                    this.m_body.position = vector;
                }
                else
                {
                    if (Vector3.Distance(this.m_body.position, vector) > 0.01f)
                    {
                        vector = Vector3.Lerp(this.m_body.position, vector, 0.2f);
                    }
                    this.m_body.MovePosition(vector);
                }
            }
            if (this.m_syncRotation)
            {
                Quaternion rotation = zdo.GetRotation();
                if (Quaternion.Angle(this.m_body.rotation, rotation) > 45f)
                {
                    this.m_body.rotation = rotation;
                }
                else
                {
                    this.m_body.MoveRotation(rotation);
                }
            }
        }
        else
        {
            if (this.m_syncPosition)
            {
                this.SyncPosition(zdo, dt);
            }
            if (this.m_syncRotation)
            {
                Quaternion rotation2 = zdo.GetRotation();
                if (Quaternion.Angle(base.transform.rotation, rotation2) > 0.001f)
                {
                    base.transform.rotation = Quaternion.Slerp(base.transform.rotation, rotation2, 0.2f);
                }
            }
            if (this.m_body)
            {
                this.m_body.useGravity = false;
                if (this.m_syncBodyVelocity && this.m_nview.HasOwner())
                {
                    Vector3 vec  = zdo.GetVec3(ZSyncTransform.m_bodyVel, Vector3.zero);
                    Vector3 vec2 = zdo.GetVec3(ZSyncTransform.m_bodyAVel, Vector3.zero);
                    if (vec.magnitude > 0.01f || vec2.magnitude > 0.01f)
                    {
                        this.m_body.velocity        = vec;
                        this.m_body.angularVelocity = vec2;
                    }
                    else
                    {
                        this.m_body.Sleep();
                    }
                }
                else if (!this.m_body.IsSleeping())
                {
                    this.m_body.velocity        = Vector3.zero;
                    this.m_body.angularVelocity = Vector3.zero;
                    this.m_body.Sleep();
                }
            }
        }
        if (this.m_syncScale)
        {
            Vector3 vec3 = zdo.GetVec3(ZSyncTransform.m_scaleHash, base.transform.localScale);
            base.transform.localScale = vec3;
        }
    }