Exemple #1
0
        protected void UpdateRotateDir(VInt3 targetDir, int dt)
        {
            ActorRoot actor = this.Parent.actor;

            if (targetDir != VInt3.zero)
            {
                actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq);
                if (!actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate))
                {
                    actor.forward = targetDir;
                    if (actor.InCamera)
                    {
                        Vector3 forward = this.Parent.gameObject.transform.forward;
                        Vector3 vector2 = (Vector3)targetDir;
                        vector2.y = 0f;
                        forward.y = 0f;
                        VFactor factor = VInt3.AngleInt(targetDir, VInt3.forward);
                        int     num    = (targetDir.x * VInt3.forward.z) - (VInt3.forward.x * targetDir.z);
                        if (num < 0)
                        {
                            factor = VFactor.twoPi - factor;
                        }
                        Quaternion to = Quaternion.AngleAxis(factor.single * 57.29578f, Vector3.up);
                        actor.rotation = Quaternion.RotateTowards(actor.rotation, to, (this.Parent.RotateSpeed * dt) * 0.001f);
                    }
                }
            }
        }
        public void Update(ActorRoot _parent)
        {
            if (!this.childActorRoot)
            {
                return;
            }
            VInt3 vInt = _parent.location + this.translation;

            if (this.translation.x != 0 || this.translation.z != 0)
            {
                VInt3   forward = VInt3.forward;
                VFactor vFactor = VInt3.AngleInt(_parent.forward, forward);
                int     num     = _parent.forward.x * forward.z - forward.x * _parent.forward.z;
                if (num < 0)
                {
                    vFactor = VFactor.twoPi - vFactor;
                }
                VInt3 vInt2 = this.translation.RotateY(ref vFactor);
                vInt    = _parent.location + vInt2.NormalizeTo(this.distance.i);
                vInt.y += this.translation.y;
            }
            this.childActorRoot.get_handle().location = vInt;
            this.childActorRoot.get_handle().forward  = _parent.forward;
            this.UpdateMoveDelta(vInt);
        }
 public void CustumLateUpdate()
 {
     if (this.myRenderer != null && this.ActorObj != null)
     {
         bool isVisible = this.myRenderer.isVisible;
         if (isVisible != this.ActorObj.InCamera)
         {
             this.ActorObj.InCamera = isVisible;
             if (this.ActorObj.InCamera)
             {
                 if (this.ActorObj.isMovable)
                 {
                     this.oldLocation          = this.ActorObj.location;
                     this.myTransform.position = (Vector3)this.ActorObj.location;
                 }
                 if (this.ActorObj.isRotatable)
                 {
                     VInt3   forward = this.ActorObj.forward;
                     VFactor b       = VInt3.AngleInt(forward, VInt3.forward);
                     int     num     = forward.x * VInt3.forward.z - VInt3.forward.x * forward.z;
                     if (num < 0)
                     {
                         b = VFactor.twoPi - b;
                     }
                     this.tarRotation          = Quaternion.AngleAxis(b.single * 57.29578f, Vector3.up);
                     this.myTransform.rotation = this.tarRotation;
                 }
             }
         }
     }
 }
Exemple #4
0
 private void LateUpdate()
 {
     if (((this.myRenderer != null) && (this.ActorObj != null)) && (this.myRenderer.isVisible != this.ActorObj.InCamera))
     {
         this.ActorObj.InCamera = this.myRenderer.isVisible;
         if (this.ActorObj.InCamera)
         {
             if (this.ActorObj.isMovable)
             {
                 this.oldLocation = this.ActorObj.location;
                 base.gameObject.transform.position = (Vector3)this.ActorObj.location;
             }
             if (this.ActorObj.isRotatable)
             {
                 VFactor factor = VInt3.AngleInt(this.ActorObj.forward, VInt3.forward);
                 int     num    = (this.ActorObj.forward.x * VInt3.forward.z) - (VInt3.forward.x * this.ActorObj.forward.z);
                 if (num < 0)
                 {
                     factor = VFactor.twoPi - factor;
                 }
                 this.tarRotation = Quaternion.AngleAxis(factor.single * 57.29578f, Vector3.up);
                 base.gameObject.transform.rotation = this.tarRotation;
             }
         }
     }
 }
Exemple #5
0
 public void CustumLateUpdate()
 {
     if (this.myRenderer != null && this.ActorObj != null)
     {
         bool isVisible = this.myRenderer.isVisible;
         if (isVisible != this.ActorObj.InCamera)
         {
             this.ActorObj.InCamera = isVisible;
             if (this.ActorObj.InCamera)
             {
                 if (this.ActorObj.isMovable)
                 {
                     this.oldLocation          = this.ActorObj.location;
                     this.myTransform.position = (Vector3)this.ActorObj.location;
                 }
                 if (this.ActorObj.isRotatable)
                 {
                     VInt3   forward  = this.ActorObj.forward;
                     VFactor vFactor  = VInt3.AngleInt(forward, VInt3.forward);
                     int     arg_CE_0 = forward.x;
                     VInt3   forward2 = VInt3.forward;
                     int     arg_E5_0 = arg_CE_0 * forward2.z;
                     VInt3   forward3 = VInt3.forward;
                     int     num      = arg_E5_0 - forward3.x * forward.z;
                     if (num < 0)
                     {
                         vFactor = VFactor.twoPi - vFactor;
                     }
                     this.tarRotation          = Quaternion.AngleAxis(vFactor.get_single() * 57.29578f, Vector3.up);
                     this.myTransform.rotation = this.tarRotation;
                 }
             }
         }
     }
 }
        protected void UpdateRotateDir(VInt3 targetDir, int dt)
        {
            ActorRoot actor = this.Parent.actor;

            if (targetDir == VInt3.zero)
            {
                return;
            }
            actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq);
            if (actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate))
            {
                return;
            }
            actor.forward = targetDir;
            if (actor.InCamera)
            {
                Vector3 forward = this.Parent.actor.myTransform.forward;
                ((Vector3)targetDir).y = 0f;
                forward.y = 0f;
                VFactor vFactor  = VInt3.AngleInt(targetDir, VInt3.forward);
                int     arg_B8_0 = targetDir.x;
                VInt3   forward2 = VInt3.forward;
                int     arg_CF_0 = arg_B8_0 * forward2.z;
                VInt3   forward3 = VInt3.forward;
                int     num      = arg_CF_0 - forward3.x * targetDir.z;
                if (num < 0)
                {
                    vFactor = VFactor.twoPi - vFactor;
                }
                Quaternion to = Quaternion.AngleAxis(vFactor.get_single() * 57.29578f, Vector3.up);
                actor.rotation = Quaternion.RotateTowards(actor.rotation, to, (float)(this.Parent.RotateSpeed * dt) * 0.001f);
            }
        }
        protected void UpdateRotateDir(VInt3 targetDir, int dt)
        {
            ActorRoot actor = this.Parent.actor;

            if (targetDir == VInt3.zero)
            {
                return;
            }
            actor.ObjLinker.SetForward(targetDir, this.Parent.actor.ActorControl.curMoveSeq);
            if (actor.ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveRotate))
            {
                return;
            }
            actor.forward = targetDir;
            if (actor.InCamera)
            {
                Vector3 forward = this.Parent.actor.myTransform.forward;
                ((Vector3)targetDir).y = 0f;
                forward.y = 0f;
                VFactor b   = VInt3.AngleInt(targetDir, VInt3.forward);
                int     num = targetDir.x * VInt3.forward.z - VInt3.forward.x * targetDir.z;
                if (num < 0)
                {
                    b = VFactor.twoPi - b;
                }
                Quaternion quaternion = Quaternion.AngleAxis(b.single * 57.29578f, Vector3.up);
                actor.rotation = Quaternion.RotateTowards(actor.rotation, quaternion, (float)(this.Parent.RotateSpeed * dt) * 0.001f);
            }
        }
        public override void Process(Action _action, Track _track, int _localTime)
        {
            if (!this.actorTarget)
            {
                return;
            }
            int num = _localTime - this.lastTime;

            this.lastTime = _localTime;
            if (this.actorTarget.get_handle().ActorControl.curMoveCommand != null)
            {
                FrameCommand <MoveDirectionCommand> frameCommand = (FrameCommand <MoveDirectionCommand>) this.actorTarget.get_handle().ActorControl.curMoveCommand;
                VInt3 vInt  = this.actorTarget.get_handle().forward;
                VInt3 right = VInt3.right;
                this.destDir = right.RotateY((int)frameCommand.cmdData.Degree);
                if (this.destDir != vInt)
                {
                    this.bNeedRotate  = true;
                    this.curRotateSpd = this.rotateSpeed;
                    int num2 = this.destDir.x * vInt.z - vInt.x * this.destDir.z;
                    if (num2 == 0)
                    {
                        int num3 = VInt3.Dot(this.destDir, vInt);
                        if (num3 >= 0)
                        {
                            return;
                        }
                        this.curRotateSpd = this.rotateSpeed;
                    }
                    else if (num2 < 0)
                    {
                        this.curRotateSpd = -this.rotateSpeed;
                    }
                    VFactor vFactor  = VInt3.AngleInt(this.destDir, vInt);
                    VFactor vFactor2 = VFactor.pi * (long)num * (long)this.curRotateSpd / 180L / 1000L;
                    if (vFactor <= vFactor2)
                    {
                        vInt             = vInt.RotateY(ref vFactor);
                        this.bNeedRotate = false;
                    }
                    else
                    {
                        vInt = vInt.RotateY(ref vFactor2);
                    }
                    this.actorTarget.get_handle().MovementComponent.SetRotate(vInt, true);
                }
            }
            else
            {
                this.destDir      = this.actorTarget.get_handle().forward;
                this.bNeedRotate  = false;
                this.curRotateSpd = 0;
            }
            base.Process(_action, _track, _localTime);
        }
Exemple #9
0
        public void SetForward(VInt3 InDir, int nSeq)
        {
            if (!this.bNeedLerp || !this.ActorObj.InCamera)
            {
                return;
            }
            bool flag = false;

            if (this.nPreMoveSeq < 0 || nSeq < 0 || nSeq == this.nPreMoveSeq)
            {
                flag = true;
            }
            else if (nSeq > this.nPreMoveSeq)
            {
                byte b  = (byte)nSeq;
                byte b2 = (byte)this.nPreMoveSeq;
                b   -= 128;
                b2  -= 128;
                flag = (b < b2);
            }
            if (flag)
            {
                this.moveForward = ((Vector3)InDir).normalized;
                VInt3 vInt;
                if (this.ActorObj.ActorControl != null && this.ActorObj.ActorControl.CanRotate)
                {
                    vInt = (VInt3)this.moveForward;
                }
                else
                {
                    vInt = this.ActorObj.forward;
                }
                VFactor vFactor   = VInt3.AngleInt(vInt, VInt3.forward);
                int     arg_F3_0  = vInt.x;
                VInt3   forward   = VInt3.forward;
                int     arg_10A_0 = arg_F3_0 * forward.z;
                VInt3   forward2  = VInt3.forward;
                int     num       = arg_10A_0 - forward2.x * vInt.z;
                if (num < 0)
                {
                    vFactor = VFactor.twoPi - vFactor;
                }
                this.tarRotation = Quaternion.AngleAxis(vFactor.get_single() * 57.29578f, Vector3.up);
            }
        }
        private bool TargetMoveDirectionFilter(ref PoolObjHandle <ActorRoot> soucreActor, ref PoolObjHandle <ActorRoot> targetActor)
        {
            if (!this.bFilterMoveDirection || !soucreActor || !targetActor || this.Angle <= 0)
            {
                return(false);
            }
            VInt3 vInt    = soucreActor.get_handle().location - targetActor.get_handle().location;
            VInt3 forward = targetActor.get_handle().forward;

            if (vInt.get_magnitude() == 0 || forward.get_magnitude() == 0)
            {
                return(false);
            }
            VFactor vFactor  = VInt3.AngleInt(vInt, forward);
            VFactor vFactor2 = VFactor.pi * (long)(this.Angle / 2) / 180L;

            return(vFactor > vFactor2);
        }
        private bool TargetMoveDirectionFilter(ref PoolObjHandle <ActorRoot> sourceActor, ref PoolObjHandle <ActorRoot> targetActor)
        {
            if (!this.bFilterMoveDirection || !sourceActor || !targetActor || this.Angle <= 0)
            {
                return(false);
            }
            VInt3 lhs     = sourceActor.handle.location - targetActor.handle.location;
            VInt3 forward = targetActor.handle.forward;

            if (lhs.magnitude == 0 || forward.magnitude == 0)
            {
                return(false);
            }
            VFactor a = VInt3.AngleInt(lhs, forward);
            VFactor b = VFactor.pi * (long)(this.Angle / 2) / 180L;

            return(a > b);
        }
Exemple #12
0
        public void Update(ActorRoot _parent)
        {
            VInt3 num = _parent.location + this.translation;

            if ((this.translation.x != 0) || (this.translation.z != 0))
            {
                VInt3   forward = VInt3.forward;
                VFactor radians = VInt3.AngleInt(_parent.forward, forward);
                int     num4    = (_parent.forward.x * forward.z) - (forward.x * _parent.forward.z);
                if (num4 < 0)
                {
                    radians = VFactor.twoPi - radians;
                }
                VInt3 num2 = this.translation.RotateY(ref radians);
                num    = _parent.location + num2.NormalizeTo(this.distance.i);
                num.y += this.translation.y;
            }
            this.childActorRoot.handle.location = num;
            this.childActorRoot.handle.forward  = _parent.forward;
        }
        public void SetForward(VInt3 InDir, int nSeq)
        {
            if (!this.bNeedLerp || !this.ActorObj.InCamera)
            {
                return;
            }
            bool flag = false;

            if (this.nPreMoveSeq < 0 || nSeq < 0 || nSeq == this.nPreMoveSeq)
            {
                flag = true;
            }
            else if (nSeq > this.nPreMoveSeq)
            {
                byte b  = (byte)nSeq;
                byte b2 = (byte)this.nPreMoveSeq;
                b   -= 128;
                b2  -= 128;
                flag = (b < b2);
            }
            if (flag)
            {
                this.moveForward = ((Vector3)InDir).normalized;
                VInt3 lhs;
                if (this.ActorObj.ActorControl != null && this.ActorObj.ActorControl.CanRotate)
                {
                    lhs = (VInt3)this.moveForward;
                }
                else
                {
                    lhs = this.ActorObj.forward;
                }
                VFactor b3  = VInt3.AngleInt(lhs, VInt3.forward);
                int     num = lhs.x * VInt3.forward.z - VInt3.forward.x * lhs.z;
                if (num < 0)
                {
                    b3 = VFactor.twoPi - b3;
                }
                this.tarRotation = Quaternion.AngleAxis(b3.single * 57.29578f, Vector3.up);
            }
        }
Exemple #14
0
 public void SetForward(VInt3 InDir, int nSeq)
 {
     if (this.bNeedLerp && this.ActorObj.InCamera)
     {
         bool flag = false;
         if (((this.nPreMoveSeq < 0) || (nSeq < 0)) || (nSeq == this.nPreMoveSeq))
         {
             flag = true;
         }
         else if (nSeq > this.nPreMoveSeq)
         {
             byte num         = (byte)nSeq;
             byte nPreMoveSeq = (byte)this.nPreMoveSeq;
             num         = (byte)(num - 0x80);
             nPreMoveSeq = (byte)(nPreMoveSeq - 0x80);
             flag        = num < nPreMoveSeq;
         }
         if (flag)
         {
             VInt3   moveForward;
             Vector3 vector = (Vector3)InDir;
             this.moveForward = vector.normalized;
             if ((this.ActorObj.ActorControl != null) && this.ActorObj.ActorControl.CanRotate)
             {
                 moveForward = (VInt3)this.moveForward;
             }
             else
             {
                 moveForward = this.ActorObj.forward;
             }
             VFactor factor = VInt3.AngleInt(moveForward, VInt3.forward);
             int     num4   = (moveForward.x * VInt3.forward.z) - (VInt3.forward.x * moveForward.z);
             if (num4 < 0)
             {
                 factor = VFactor.twoPi - factor;
             }
             this.tarRotation = Quaternion.AngleAxis(factor.single * 57.29578f, Vector3.up);
         }
     }
 }