public void ManualUpdate()
    {
        Vector3?vector = this.cachedPosition;

        if (vector == null)
        {
            this.cachedPosition = new Vector3?(base.transform.position);
        }
        if (this._followingWorldPosition != null)
        {
            base.transform.position = this._followingWorldPosition.position;
        }
        else
        {
            Transform transform = base.transform;
            Vector3?  vector2   = this.cachedPosition;
            transform.position = vector2.Value;
        }
        float num = 1f;

        if (this._onInverseMove)
        {
            num = -1f;
        }
        Vector3 localPosition = base.transform.localPosition;

        base.transform.Translate(Vector3.forward * this._worldDistance, Space.World);
        float num2 = Vector3.Distance(base.transform.localPosition, localPosition);

        base.transform.localPosition = localPosition;
        base.transform.Translate(this.GetInitializeRotation(this._lookVector) * (num2 * num));
        base.transform.Translate(this._differenceLocalPosition);
        BillboardObject.LookVector lookVector = this._lookVector;
        if (lookVector != BillboardObject.LookVector.X)
        {
            if (lookVector != BillboardObject.LookVector.Y)
            {
                if (lookVector == BillboardObject.LookVector.Z)
                {
                    base.transform.Translate(new Vector3(0f, 0f, this._localDistance * num));
                }
            }
            else
            {
                base.transform.Translate(new Vector3(0f, this._localDistance * num, 0f));
            }
        }
        else
        {
            base.transform.Translate(new Vector3(this._localDistance * num, 0f, 0f));
        }
        if (this._onManualLocalEulerAngles)
        {
            base.transform.localRotation = Quaternion.Euler(this._manualLocalEulerAngles);
        }
    }
 private Vector3 GetInitializeRotation(BillboardObject.LookVector lookVector)
 {
     if (lookVector == BillboardObject.LookVector.X)
     {
         return(Vector3.up);
     }
     if (lookVector != BillboardObject.LookVector.Y)
     {
         return(Vector3.forward);
     }
     return(Vector3.right);
 }
예제 #3
0
 private Vector3 GetLookVectorToPosition(BillboardObject.LookVector lookVector)
 {
     if (lookVector == BillboardObject.LookVector.X)
     {
         return(new Vector3(1f, 0f, 0f));
     }
     if (lookVector != BillboardObject.LookVector.Y)
     {
         return(new Vector3(0f, 0f, 1f));
     }
     return(new Vector3(0f, 1f, 0f));
 }
예제 #4
0
 private Vector3 GetLookVectorToScale(BillboardObject.LookVector lookVector)
 {
     if (lookVector == BillboardObject.LookVector.X)
     {
         return(new Vector3(-1f, 1f, 1f));
     }
     if (lookVector != BillboardObject.LookVector.Y)
     {
         return(new Vector3(1f, 1f, -1f));
     }
     return(new Vector3(1f, -1f, 1f));
 }
예제 #5
0
    private void ManualUpdateInternal()
    {
        if (this._onIgnoreUpdate)
        {
            return;
        }
        if (this.lookTarget == null)
        {
            return;
        }
        this.cachedTransform = (this.cachedTransform ?? base.transform);
        if (this.cachedPosition == null)
        {
            this.cachedPosition = new Vector3?(this.cachedTransform.localPosition);
        }
        if (this.onManualPosition && !this._onUseLocalPositionAnimation)
        {
            if (this.manualPositionTransform != null)
            {
                base.transform.position = this.manualPositionTransform.position;
            }
            else
            {
                base.transform.localPosition = this.manualLocalPosition;
            }
            this.cachedPosition = new Vector3?(this.cachedTransform.localPosition);
        }
        if (this.cachedEulerAngles == null)
        {
            this.cachedEulerAngles = new Vector3?(this.cachedTransform.localEulerAngles);
        }
        if (this.onManualPosition)
        {
            float   num      = (float)((!this._onInverseDistance) ? 1 : -1);
            Vector3 position = this.lookTarget.transform.position;
            if (this._freezeDistanceThisVector)
            {
                if (this._lookVector == BillboardObject.LookVector.X)
                {
                    position.Set(this.lookTarget.transform.position.x, this.cachedTransform.position.y, this.lookTarget.transform.position.z);
                }
                else if (this._lookVector == BillboardObject.LookVector.Y)
                {
                    position.Set(this.lookTarget.transform.position.x, this.lookTarget.transform.position.y, this.cachedTransform.position.z);
                }
                else
                {
                    position.Set(this.lookTarget.transform.position.x, this.cachedTransform.position.y, this.lookTarget.transform.position.z);
                }
            }
            this.cachedTransform.position = this.cachedTransform.position + (position - this.cachedTransform.position).normalized * (this._worldDistance * num);
            this.cachedTransform.LookAt(this.lookTarget.transform);
            if (this._lookVector == BillboardObject.LookVector.X)
            {
                this.cachedTransform.Rotate(new Vector3(0f, -90f, 0f));
            }
            if (this._lookVector == BillboardObject.LookVector.Y)
            {
                this.cachedTransform.Rotate(new Vector3(90f, 0f, 0f));
            }
            if (this._freezeDistanceThisVector)
            {
                if (this._lookVector == BillboardObject.LookVector.X)
                {
                    position.Set(this.cachedTransform.localEulerAngles.x, this.cachedTransform.localEulerAngles.y, this.cachedEulerAngles.Value.z);
                }
                else if (this._lookVector == BillboardObject.LookVector.Y)
                {
                    position.Set(this.cachedEulerAngles.Value.x, this.cachedTransform.localEulerAngles.y, this.cachedTransform.localEulerAngles.z);
                }
                else
                {
                    position.Set(this.cachedEulerAngles.Value.x, this.cachedTransform.localEulerAngles.y, this.cachedTransform.localEulerAngles.z);
                }
                this.cachedTransform.localRotation = Quaternion.Euler(position);
            }
            this.cachedTransform.Translate(this.GetLookVectorToPosition(this._lookVector) * (this._localDistance * num), Space.Self);
            this.cachedTransform.localPosition = new Vector3((!this._freezeDistanceThisVector || !this.xFreeze) ? this.cachedTransform.localPosition.x : this.cachedPosition.Value.x, (!this._freezeDistanceThisVector || !this.yFreeze) ? this.cachedTransform.localPosition.y : this.cachedPosition.Value.y, (!this._freezeDistanceThisVector || !this.zFreeze) ? this.cachedTransform.localPosition.z : this.cachedPosition.Value.z);
            this.cachedTransform.Translate(this._manualDistanceLocalPosition, Space.Self);
        }
        this.cachedTransform.LookAt(this.lookTarget.transform);
        BillboardObject.LookVector lookVector = this._lookVector;
        if (lookVector != BillboardObject.LookVector.X)
        {
            if (lookVector == BillboardObject.LookVector.Y)
            {
                this.cachedTransform.Rotate(new Vector3(90f, 0f, 0f));
            }
        }
        else
        {
            this.cachedTransform.Rotate(new Vector3(0f, -90f, 0f));
        }
        Vector3 euler = new Vector3((!this.xFreeze) ? this.cachedTransform.localEulerAngles.x : this.cachedEulerAngles.Value.x, (!this.yFreeze) ? this.cachedTransform.localEulerAngles.y : this.cachedEulerAngles.Value.y, (!this.zFreeze) ? this.cachedTransform.localEulerAngles.z : this.cachedEulerAngles.Value.z);

        this.cachedTransform.localRotation = Quaternion.Euler(euler);
        Vector3?vector = this.cachedScale;

        if (vector == null)
        {
            this.cachedScale = new Vector3?(this.cachedTransform.localScale);
        }
        if (this.onUseLocalScaleAnimation)
        {
            this.cachedScale = new Vector3?(this.cachedTransform.localScale);
        }
        Vector3 lookVectorToScale = this.GetLookVectorToScale(this._lookVector);

        if (this.onInverse)
        {
            Transform transform = this.cachedTransform;
            Vector3?  vector2   = this.cachedScale;
            float     x         = vector2.Value.x * lookVectorToScale.x;
            Vector3?  vector3   = this.cachedScale;
            float     y         = vector3.Value.y * lookVectorToScale.y;
            Vector3?  vector4   = this.cachedScale;
            transform.localScale = new Vector3(x, y, vector4.Value.z * lookVectorToScale.z);
        }
        else
        {
            Transform transform2 = this.cachedTransform;
            Vector3?  vector5    = this.cachedScale;
            transform2.localScale = vector5.Value;
        }
        this.isDrawed = true;
    }