Example #1
0
        protected void UpdateMovement()
        {
            CharacterInfo obj = GetOwner();

            if (null != obj && !obj.IsDead() && null != ObjectInfo)
            {
                if (obj.IsNpc && !obj.CastNpcInfo().CanMove)
                {
                    return;
                }
                MovementStateInfo msi = obj.GetMovementStateInfo();
                ObjectInfo.FaceDir     = msi.GetFaceDir();
                ObjectInfo.WantFaceDir = msi.GetWantFaceDir();
                if (msi.IsMoving)
                {
                    Vector3 pos = msi.GetPosition3D();
                    ObjectInfo.MoveCos   = (float)msi.MoveDirCosAngle;
                    ObjectInfo.MoveSin   = (float)msi.MoveDirSinAngle;
                    ObjectInfo.MoveSpeed = (float)obj.GetActualProperty().MoveSpeed *(float)obj.VelocityCoefficient;

                    if (obj is UserInfo)
                    {
                        if (msi.TargetPosition.LengthSquared() < Geometry.c_FloatPrecision)
                        {
                            ObjectInfo.MoveTargetDistanceSqr = 100.0f;
                        }
                        else
                        {
                            ObjectInfo.MoveTargetDistanceSqr = msi.CalcDistancSquareToTarget();
                        }
                    }
                    else
                    {
                        ObjectInfo.MoveTargetDistanceSqr = msi.CalcDistancSquareToTarget();
                    }

                    ObjectInfo.IsLogicMoving = true;
                }
                else
                {
                    ObjectInfo.IsLogicMoving = false;
                }
            }
            else
            {
                ObjectInfo.IsLogicMoving = false;
            }
        }
Example #2
0
        public static void ExecObjFaceCommand(int objId, float dir)
        {
            CharacterInfo obj = WorldSystem.Instance.GetCharacterById(objId);

            if (null != obj)
            {
                MovementStateInfo msi = obj.GetMovementStateInfo();
                if (dir < 0)
                {
                    msi.SetFaceDir(msi.GetWantFaceDir());
                }
                else
                {
                    msi.SetFaceDir(dir);
                    msi.SetWantFaceDir(dir);
                }
            }
        }
Example #3
0
        protected void SimulateMove()
        {
            if (!m_Npc.IsSimulateMove)
            {
                return;
            }
            if (m_Npc.SummonOwnerId < 0)
            {
                return;
            }
            CharacterInfo owner = WorldSystem.Instance.GetCharacterById(m_Npc.SummonOwnerId);

            if (owner == null)
            {
                return;
            }
            CharacterView owner_view = EntityManager.Instance.GetCharacterViewById(m_Npc.SummonOwnerId);

            if (owner_view == null)
            {
                return;
            }
            MovementStateInfo msi     = m_Npc.GetMovementStateInfo();
            MovementStateInfo sim_msi = owner.GetMovementStateInfo();

            m_Npc.GetActualProperty().SetMoveSpeed(Operate_Type.OT_Absolute, owner.GetActualProperty().MoveSpeed);
            m_Npc.VelocityCoefficient = owner.VelocityCoefficient;
            if (owner_view.ObjectInfo.IsGfxMoveControl)
            {
                msi.IsMoving = false;
            }
            else
            {
                msi.IsMoving = sim_msi.IsMoving;
            }
            msi.SetFaceDir(sim_msi.GetFaceDir());
            msi.SetWantFaceDir(sim_msi.GetWantFaceDir());
            msi.SetMoveDir(sim_msi.GetMoveDir());
        }
Example #4
0
        private void UpdateSpatial()
        {
            if (null != m_Npc)
            {
                MovementStateInfo msi = m_Npc.GetMovementStateInfo();
                if (ObjectInfo.IsGfxMoveControl)
                {
                    if (ObjectInfo.DataChangedByGfx)
                    {
                        msi.PositionX = ObjectInfo.X;
                        msi.PositionY = ObjectInfo.Y;
                        msi.PositionZ = ObjectInfo.Z;
                        msi.SetFaceDir(ObjectInfo.FaceDir);
                        ObjectInfo.DataChangedByGfx = false;
                    }
                    if (ObjectInfo.WantDirChangedByGfx)
                    {
                        msi.SetWantFaceDir(ObjectInfo.WantFaceDir);
                        ObjectInfo.WantDirChangedByGfx = false;
                    }
                }
                else
                {
                    if (ObjectInfo.DataChangedByGfx)
                    {
                        msi.PositionX = ObjectInfo.X;
                        msi.PositionY = ObjectInfo.Y;
                        msi.PositionZ = ObjectInfo.Z;
                        //msi.SetFaceDir(ObjectInfo.FaceDir);

                        ObjectInfo.DataChangedByGfx = false;
                    }
                    SimulateMove();
                    UpdateMovement();
                }
                ObjectInfo.WantFaceDir = msi.GetWantFaceDir();
            }
        }