private void SetFinalPos()
 {
     if (!this.bStayInCurrentPosWhenStop)
     {
         VInt vInt = 0;
         PathfindingUtility.GetGroundY(this.finalPos, out vInt);
         this.finalPos.y             = vInt.i;
         this.actor_.handle.location = this.finalPos;
     }
     else if (!PathfindingUtility.IsValidTarget(this.actor_, this.actor_.handle.location))
     {
         bool  flag  = false;
         VInt3 vInt2 = VInt3.zero;
         vInt2 = PathfindingUtility.FindValidTarget(this.actor_, this.actor_.handle.location, this.finalPos, 10000, out flag);
         if (!flag)
         {
             vInt2 = PathfindingUtility.FindValidTarget(this.actor_, this.actor_.handle.location, this.srcPos, 10000, out flag);
         }
         if (flag)
         {
             VInt vInt3 = 0;
             PathfindingUtility.GetGroundY(vInt2, out vInt3);
             vInt2.y       = vInt3.i;
             this.finalPos = vInt2;
             this.actor_.handle.location = vInt2;
         }
         else
         {
             this.actor_.handle.location = this.finalPos;
         }
     }
 }
示例#2
0
        public void Teleport()
        {
            VInt  groundY = this.actor_.get_handle().groundY;
            VInt3 vInt    = this.dir.NormalizeTo(this.moveDistance);
            VInt3 vInt2   = this.actor_.get_handle().location + vInt;
            bool  flag    = false;

            if (PathfindingUtility.IsValidTarget(this.actor_, vInt2))
            {
                PathfindingUtility.GetGroundY(vInt2, out groundY);
                vInt2.y = groundY.i;
                this.actor_.get_handle().location = vInt2;
            }
            else
            {
                VInt3 vInt3 = PathfindingUtility.FindValidTarget(this.actor_, vInt2, this.actor_.get_handle().location, 10000, out flag);
                if (flag)
                {
                    PathfindingUtility.GetGroundY(vInt3, out groundY);
                    vInt3.y = groundY.i;
                    this.actor_.get_handle().location = vInt3;
                }
                else
                {
                    vInt = PathfindingUtility.Move(this.actor_.get_handle(), vInt, out groundY, out this.actor_.get_handle().hasReachedNavEdge, null);
                    this.actor_.get_handle().location += vInt;
                }
            }
            if (this.bUseRecordPosition)
            {
                this.actor_.get_handle().ActorControl.RmvNoAbilityFlag(ObjAbilityType.ObjAbility_MoveProtect);
            }
            this.actor_.get_handle().groundY = groundY;
            this.done_ = true;
        }
    public static VInt3 FindValidTarget(ActorRoot actor, VInt3 start, VInt3 end, int radius, out bool bResult)
    {
        long num  = (long)radius * (long)radius;
        long num2 = start.XZSqrMagnitude(ref end);

        if (num2 < num)
        {
            return(PathfindingUtility.FindValidTarget(actor, start, end, out bResult));
        }
        VInt3 vInt = end - start;
        VInt3 end2 = start + vInt.NormalizeTo(radius);

        return(PathfindingUtility.FindValidTarget(actor, start, end2, out bResult));
    }
示例#4
0
        public override void Process(Action _action, Track _track, int _localTime)
        {
            base.Process(_action, _track, _localTime);
            if (!this.triggerActor || !this.targetActor || (this.moveSpeed == 0 && this.acceleration == 0))
            {
                return;
            }
            if (this.done_)
            {
                return;
            }
            VInt3 location = this.triggerActor.handle.location;
            VInt3 vInt     = this.targetActor.handle.location;
            int   num      = _localTime - this.lastTime_;

            this.lastTime_ = _localTime;
            VInt3 vInt2 = vInt - location;
            long  num2  = (long)this.curSpeed * (long)num + (long)this.acceleration * (long)num * (long)num / 2L / 1000L;

            this.curSpeed     = Mathf.Min(this.curSpeed + this.acceleration * num / 1000, this.maxMoveSpeed);
            this.curLerpSpeed = this.curSpeed;
            num2 /= 1000L;
            if (num2 >= (long)(vInt2.magnitude - this.lastDistance))
            {
                num2       = (long)Mathf.Max(vInt2.magnitude - this.lastDistance, 0);
                this.done_ = true;
                vInt       = location + vInt2.NormalizeTo((int)num2);
                if (!PathfindingUtility.IsValidTarget(this.triggerActor.handle, vInt))
                {
                    bool  flag  = false;
                    VInt3 vInt3 = PathfindingUtility.FindValidTarget(this.triggerActor.handle, vInt, this.triggerActor.handle.location, 10000, out flag);
                    VInt  vInt4 = 0;
                    PathfindingUtility.GetGroundY(vInt3, out vInt4);
                    vInt3.y = vInt4.i;
                    vInt    = vInt3;
                    vInt2   = vInt - this.triggerActor.handle.location;
                    num2    = (long)vInt2.magnitude;
                }
            }
            this.dir = vInt2;
            if (vInt2 != VInt3.zero)
            {
                this.triggerActor.handle.MovementComponent.SetRotate(this.dir, true);
                this.triggerActor.handle.rotation = Quaternion.LookRotation((Vector3)vInt2);
            }
            this.triggerActor.handle.location += vInt2.NormalizeTo((int)num2);
        }
 public override void Leave(Action _action, Track _track)
 {
     base.Leave(_action, _track);
     if (!this.triggerActor || !this.targetActor || this.moveSpeed == 0)
     {
         return;
     }
     this.done_ = true;
     this.triggerActor.get_handle().ActorControl.RmvNoAbilityFlag(ObjAbilityType.ObjAbility_Move);
     this.triggerActor.get_handle().ObjLinker.RmvCustomMoveLerp(new CustomMoveLerpFunc(this.ActionMoveLerp));
     if (!PathfindingUtility.IsValidTarget(this.triggerActor.get_handle(), this.triggerActor.get_handle().location))
     {
         bool  flag  = false;
         VInt3 vInt  = PathfindingUtility.FindValidTarget(this.triggerActor.get_handle(), this.targetActor.get_handle().location, this.triggerActor.get_handle().location, 10000, out flag);
         VInt  vInt2 = 0;
         PathfindingUtility.GetGroundY(vInt, out vInt2);
         vInt.y = vInt2.i;
         this.triggerActor.get_handle().location = vInt;
     }
 }
示例#6
0
        public override void Enter(Action _action, Track _track)
        {
            this.done_     = false;
            this.lastTime_ = 0;
            base.Enter(_action, _track);
            this.actor_ = _action.GetActorHandle(this.actorId);
            if (!this.actor_ || (!this.teleport && this.moveSpeed == 0 && this.acceleration == 0))
            {
                return;
            }
            this.srcPos = this.actor_.get_handle().location;
            if (this.bForbidMoveFollowing)
            {
                this.actor_.get_handle().ActorControl.AddNoAbilityFlag(ObjAbilityType.ObjAbility_MoveProtect);
            }
            if (this.bUseRecordPosition && this.actor_.get_handle().SkillControl != null)
            {
                this.destPos = this.actor_.get_handle().SkillControl.RecordPosition;
                this.dir     = this.destPos - this.srcPos;
                int magnitude2D = (this.destPos - this.srcPos).get_magnitude2D();
                this.moveDistance += magnitude2D;
            }
            else if (this.moveType == ActorMoveType.Target)
            {
                PoolObjHandle <ActorRoot> actorHandle = _action.GetActorHandle(this.destId);
                if (!this.actor_ || !actorHandle)
                {
                    this.actor_.Release();
                    return;
                }
                int num;
                if (actorHandle.get_handle().ActorControl.GetNoAbilityFlag(ObjAbilityType.ObjAbility_MoveProtect) && actorHandle.get_handle().TheActorMeta.ActorCamp != this.actor_.get_handle().TheActorMeta.ActorCamp)
                {
                    num = 0;
                }
                else
                {
                    this.dir = actorHandle.get_handle().location - this.srcPos;
                    num      = (actorHandle.get_handle().location - this.srcPos).get_magnitude2D();
                }
                this.moveDistance += num;
            }
            else if (this.moveType == ActorMoveType.Position)
            {
                this.dir = this.destPos - this.srcPos;
                int magnitude2D2 = (this.destPos - this.srcPos).get_magnitude2D();
                if (magnitude2D2 < this.minMoveDistance)
                {
                    magnitude2D2 = this.minMoveDistance;
                }
                this.moveDistance += magnitude2D2;
            }
            else if (this.moveType == ActorMoveType.Directional)
            {
                this.dir = this.actor_.get_handle().forward;
            }
            this.dir.y = 0;
            this.actor_.get_handle().ActorControl.TerminateMove();
            if (this.bRecordPosition && this.actor_.get_handle().SkillControl != null)
            {
                this.actor_.get_handle().SkillControl.RecordPosition = this.actor_.get_handle().location;
            }
            if (!this.actor_.get_handle().isMovable || this.dir.get_sqrMagnitudeLong() <= 1L)
            {
                this.actor_.Release();
                this.done_ = true;
                return;
            }
            VInt3 vInt = this.dir;

            if (!this.bUseRecordPosition)
            {
                this.finalPos = this.srcPos + vInt.NormalizeTo(this.moveDistance);
            }
            else
            {
                this.finalPos = this.actor_.get_handle().SkillControl.RecordPosition;
                if (this.teleport)
                {
                    this.actor_.get_handle().ActorControl.AddNoAbilityFlag(ObjAbilityType.ObjAbility_MoveProtect);
                }
            }
            if (!PathfindingUtility.IsValidTarget(this.actor_, this.finalPos))
            {
                bool flag = false;
                if (this.moveType == ActorMoveType.Directional)
                {
                    this.IgnoreCollision = false;
                }
                else
                {
                    VInt3 pos = PathfindingUtility.FindValidTarget(this.actor_, this.finalPos, this.actor_.get_handle().location, 10000, out flag);
                    if (!flag)
                    {
                        this.IgnoreCollision = false;
                    }
                    else
                    {
                        VInt vInt2 = 0;
                        PathfindingUtility.GetGroundY(pos, out vInt2);
                        pos.y             = vInt2.i;
                        this.finalPos     = pos;
                        this.moveDistance = (this.finalPos - this.actor_.get_handle().location).get_magnitude2D();
                    }
                }
            }
            if (!this.shouldUseAcceleration)
            {
                this.moveTick = this.moveDistance * 1000 / this.moveSpeed;
            }
            else
            {
                long num2 = (long)this.moveDistance;
                long num3 = (long)this.acceleration;
                long num4 = (long)this.moveSpeed;
                this.moveTick          = (int)IntMath.Divide(((long)IntMath.Sqrt(num4 * num4 + 2L * num3 * num2) - num4) * 1000L, num3);
                this.lastMoveSpeed     = this.moveSpeed;
                this.lastLerpMoveSpeed = this.moveSpeed;
            }
            this.actor_.get_handle().ActorControl.AddNoAbilityFlag(ObjAbilityType.ObjAbility_Move);
            this.actor_.get_handle().ObjLinker.AddCustomMoveLerp(new CustomMoveLerpFunc(this.ActionMoveLerp));
            this.fromRot = this.actor_.get_handle().rotation;
            this.actor_.get_handle().MovementComponent.SetRotate(this.dir, true);
            if (this.rotationTime > 0)
            {
                this.toRot = Quaternion.LookRotation((Vector3)this.actor_.get_handle().forward);
            }
            else
            {
                this.actor_.get_handle().rotation = Quaternion.LookRotation((Vector3)this.actor_.get_handle().forward);
            }
        }
        private void EnterSpawnBullet(Action _action, Track _track)
        {
            string resourceName;

            if (this.bUseSkin)
            {
                resourceName = SkinResourceHelper.GetResourceName(_action, this.prefabName, this.bUseSkinAdvance);
            }
            else
            {
                resourceName = this.prefabName;
            }
            VInt3                     vInt           = VInt3.zero;
            VInt3                     forward        = VInt3.forward;
            SkillUseContext           refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");
            COM_PLAYERCAMP            camp           = (refParamObject == null || !refParamObject.Originator) ? 0 : refParamObject.Originator.get_handle().TheActorMeta.ActorCamp;
            GameObject                gameObject     = _action.GetGameObject(this.parentId);
            PoolObjHandle <ActorRoot> actorHandle    = _action.GetActorHandle(this.parentId);
            PoolObjHandle <ActorRoot> actorHandle2   = _action.GetActorHandle(this.objectSpaceId);

            if (actorHandle2)
            {
                ActorRoot handle = actorHandle2.get_handle();
                if (this.superTranslation)
                {
                    VInt3 zero = VInt3.zero;
                    _action.refParams.GetRefParam("_BulletPos", ref zero);
                    vInt = IntMath.Transform(zero, handle.forward, handle.location);
                }
                else if (this.modifyTranslation)
                {
                    vInt = IntMath.Transform(this.translation, handle.forward, handle.location);
                }
                if (this.modifyDirection)
                {
                    forward = actorHandle2.get_handle().forward;
                }
            }
            else if (this.bTargetPosition)
            {
                vInt = this.translation + this.targetPosition;
                if (this.modifyDirection && refParamObject != null && refParamObject.Originator)
                {
                    forward = refParamObject.Originator.get_handle().forward;
                }
            }
            else
            {
                if (this.modifyTranslation)
                {
                    vInt = this.translation;
                }
                if (this.modifyDirection && this.direction.x != 0 && this.direction.y != 0)
                {
                    forward = this.direction;
                    forward.NormalizeTo(1000);
                }
            }
            if (this.targetId >= 0)
            {
                _action.ExpandGameObject(this.targetId);
                GameObject gameObject2 = _action.GetGameObject(this.targetId);
                if (this.recreateExisting && gameObject2 != null)
                {
                    if (this.applyActionSpeedToAnimation)
                    {
                        _action.RemoveTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject2);
                    }
                    if (this.applyActionSpeedToParticle)
                    {
                        _action.RemoveTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject2);
                    }
                    ActorHelper.DetachActorRoot(gameObject2);
                    ActionManager.DestroyGameObject(gameObject2);
                    _action.SetGameObject(this.targetId, null);
                }
                bool flag = true;
                if (!(gameObject2 == null))
                {
                    return;
                }
                if (this.bForbidBulletInObstacle && !PathfindingUtility.IsValidTarget(refParamObject.Originator.get_handle(), vInt))
                {
                    bool  flag2 = false;
                    VInt3 vInt2 = PathfindingUtility.FindValidTarget(refParamObject.Originator.get_handle(), vInt, refParamObject.Originator.get_handle().location, 10000, out flag2);
                    if (flag2)
                    {
                        VInt vInt3 = 0;
                        PathfindingUtility.GetGroundY(vInt2, out vInt3);
                        vInt2.y = vInt3.i;
                        vInt    = vInt2;
                    }
                    else
                    {
                        vInt = refParamObject.Originator.get_handle().location;
                    }
                }
                GameObject gameObject3 = MonoSingleton <SceneMgr> .GetInstance().Spawn("TempObject", SceneObjType.Bullet, vInt, forward);

                if (!gameObject3)
                {
                    throw new Exception("Age:SpawnObjectDuration Spawn Exception");
                }
                gameObject3.transform.localScale = Vector3.one;
                bool flag3       = true;
                int  particleLOD = GameSettings.ParticleLOD;
                if (GameSettings.DynamicParticleLOD)
                {
                    if (refParamObject != null && refParamObject.Originator && refParamObject.Originator.get_handle().TheActorMeta.PlayerId == Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer().PlayerId)
                    {
                        flag3 = false;
                    }
                    if (!flag3 && particleLOD > 1)
                    {
                        GameSettings.ParticleLOD = 1;
                    }
                    MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag3;
                }
                this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(resourceName, true, SceneObjType.ActionRes, gameObject3.transform.position, gameObject3.transform.rotation, out flag);

                if (GameSettings.DynamicParticleLOD)
                {
                    MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                }
                if (this.m_particleObj == null)
                {
                    if (GameSettings.DynamicParticleLOD)
                    {
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = flag3;
                    }
                    this.m_particleObj = MonoSingleton <SceneMgr> .GetInstance().GetPooledGameObjLOD(this.prefabName, true, SceneObjType.ActionRes, gameObject3.transform.position, gameObject3.transform.rotation, out flag);

                    if (GameSettings.DynamicParticleLOD)
                    {
                        MonoSingleton <SceneMgr> .GetInstance().m_dynamicLOD = false;
                    }
                }
                if (GameSettings.DynamicParticleLOD)
                {
                    GameSettings.ParticleLOD = particleLOD;
                }
                if (this.m_particleObj != null)
                {
                    this.m_particleObj.transform.SetParent(gameObject3.transform);
                    this.m_particleObj.transform.localPosition = Vector3.zero;
                    this.m_particleObj.transform.localRotation = Quaternion.identity;
                }
                this.actorRoot = ActorHelper.AttachActorRoot(gameObject3, ActorTypeDef.Actor_Type_Bullet, camp, null);
                _action.SetGameObject(this.targetId, gameObject3);
                this.actorRoot.get_handle().location = vInt;
                this.actorRoot.get_handle().forward  = forward;
                VCollisionShape.InitActorCollision(this.actorRoot, this.m_particleObj, _action.actionName);
                if (this.actorRoot.get_handle().shape != null)
                {
                    this.actorRoot.get_handle().shape.ConditionalUpdateShape();
                }
                if (this.bInvisibleBullet && this.actorRoot.get_handle().ActorControl != null)
                {
                    BulletWrapper bulletWrapper = this.actorRoot.get_handle().ActorControl as BulletWrapper;
                    if (bulletWrapper != null)
                    {
                        bulletWrapper.InitForInvisibleBullet();
                    }
                }
                this.actorRoot.get_handle().InitActor();
                if (refParamObject != null)
                {
                    refParamObject.EffectPos = this.actorRoot.get_handle().location;
                    if (this.actorRoot.get_handle().TheActorMeta.ActorType != ActorTypeDef.Actor_Type_EYE)
                    {
                        this.CreateBullet();
                    }
                }
                if (this.applyActionSpeedToAnimation)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject3);
                }
                if (this.applyActionSpeedToParticle)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject3);
                }
                this.actorRoot.get_handle().StartFight();
                if (this.enableLayer || this.enableTag)
                {
                    if (this.enableLayer)
                    {
                        gameObject3.layer = this.layer;
                    }
                    if (this.enableTag)
                    {
                        gameObject3.tag = this.tag;
                    }
                    Transform[] componentsInChildren = gameObject3.GetComponentsInChildren <Transform>();
                    for (int i = 0; i < componentsInChildren.Length; i++)
                    {
                        if (this.enableLayer)
                        {
                            componentsInChildren[i].gameObject.layer = this.layer;
                        }
                        if (this.enableTag)
                        {
                            componentsInChildren[i].gameObject.tag = this.tag;
                        }
                    }
                }
                if (flag)
                {
                    ParticleHelper.Init(gameObject3, this.scaling);
                }
                PoolObjHandle <ActorRoot> actorHandle3 = _action.GetActorHandle(this.targetId);
                this.SetParent(ref actorHandle, ref actorHandle3, this.translation);
                if (this.modifyScaling)
                {
                    gameObject3.transform.localScale = this.scaling;
                }
            }
            else
            {
                GameObject gameObject4;
                if (this.modifyDirection)
                {
                    gameObject4 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)vInt, Quaternion.LookRotation((Vector3)forward));
                }
                else
                {
                    gameObject4 = MonoSingleton <SceneMgr> .GetInstance().InstantiateLOD(this.prefabName, true, SceneObjType.ActionRes, (Vector3)vInt);
                }
                if (gameObject4 == null)
                {
                    return;
                }
                if (this.applyActionSpeedToAnimation)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Anim, gameObject4);
                }
                if (this.applyActionSpeedToParticle)
                {
                    _action.AddTempObject(Action.PlaySpeedAffectedType.ePSAT_Fx, gameObject4);
                }
                if (this.enableLayer)
                {
                    gameObject4.layer = this.layer;
                    Transform[] componentsInChildren2 = gameObject4.GetComponentsInChildren <Transform>();
                    for (int j = 0; j < componentsInChildren2.Length; j++)
                    {
                        componentsInChildren2[j].gameObject.layer = this.layer;
                    }
                }
                if (this.enableTag)
                {
                    gameObject4.tag = this.tag;
                    Transform[] componentsInChildren3 = gameObject4.GetComponentsInChildren <Transform>();
                    for (int k = 0; k < componentsInChildren3.Length; k++)
                    {
                        componentsInChildren3[k].gameObject.tag = this.tag;
                    }
                }
                if (gameObject4.GetComponent <ParticleSystem>() && this.modifyScaling)
                {
                    ParticleSystem[] componentsInChildren4 = gameObject4.GetComponentsInChildren <ParticleSystem>();
                    for (int l = 0; l < componentsInChildren4.Length; l++)
                    {
                        componentsInChildren4[l].startSize            *= this.scaling.x;
                        componentsInChildren4[l].startLifetime        *= this.scaling.y;
                        componentsInChildren4[l].startSpeed           *= this.scaling.z;
                        componentsInChildren4[l].transform.localScale *= this.scaling.x;
                    }
                }
                PoolObjHandle <ActorRoot> poolObjHandle = ActorHelper.GetActorRoot(gameObject4);
                this.SetParent(ref actorHandle, ref poolObjHandle, this.translation);
                if (this.modifyScaling)
                {
                    gameObject4.transform.localScale = this.scaling;
                }
            }
        }