Example #1
0
    // Token: 0x0600087C RID: 2172 RVA: 0x00041424 File Offset: 0x0003F624
    private GameObject CreateObject(ZDO zdo)
    {
        int prefab = zdo.GetPrefab();

        if (prefab == 0)
        {
            return(null);
        }
        GameObject prefab2 = this.GetPrefab(prefab);

        if (prefab2 == null)
        {
            return(null);
        }
        Vector3    position = zdo.GetPosition();
        Quaternion rotation = zdo.GetRotation();

        ZNetView.m_useInitZDO = true;
        ZNetView.m_initZDO    = zdo;
        GameObject result = UnityEngine.Object.Instantiate <GameObject>(prefab2, position, rotation);

        if (ZNetView.m_initZDO != null)
        {
            ZLog.LogWarning(string.Concat(new object[]
            {
                "ZDO ",
                zdo.m_uid,
                " not used when creating object ",
                prefab2.name
            }));
            ZNetView.m_initZDO = null;
        }
        ZNetView.m_useInitZDO = false;
        return(result);
    }
Example #2
0
    // Token: 0x06000F7A RID: 3962 RVA: 0x0006DBD0 File Offset: 0x0006BDD0
    public void Teleport(Player player)
    {
        if (!this.TargetFound())
        {
            return;
        }
        if (!player.IsTeleportable())
        {
            player.Message(MessageHud.MessageType.Center, "$msg_noteleport", 0, null);
            return;
        }
        ZLog.Log("Teleporting " + player.GetPlayerName());
        ZDOID zdoid = this.m_nview.GetZDO().GetZDOID("target");

        if (zdoid == ZDOID.None)
        {
            return;
        }
        ZDO        zdo      = ZDOMan.instance.GetZDO(zdoid);
        Vector3    position = zdo.GetPosition();
        Quaternion rotation = zdo.GetRotation();
        Vector3    a        = rotation * Vector3.forward;
        Vector3    pos      = position + a * this.m_exitDistance + Vector3.up;

        player.TeleportTo(pos, rotation, true);
    }
Example #3
0
        private static void DoTP()
        {
            ZDO zdo = GetClosestTP();

            if (zdo != null && Player.m_localPlayer.IsTeleportable())
            {
                Vector3    position = zdo.GetPosition();
                Quaternion rotation = zdo.GetRotation();
                Vector3    pos      = position + rotation * Vector3.forward + Vector3.up;
                LeaveTPMode();
                SetMapMode(1);
                Player.m_localPlayer.TeleportTo(pos, rotation, true);
            }
        }
    // 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;
        }
    }