public void UpdateState() { this.CalcAnimSpeed(); MerchantActor actor = this._actor as MerchantActor; NavMeshAgent navMeshAgent = actor.NavMeshAgent; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; if (actor.CurrentMode == Merchant.ActionType.GotoLesbianSpotFollow) { if (((Behaviour)navMeshAgent).get_isActiveAndEnabled() && !navMeshAgent.get_pathPending()) { if (!actor.IsRunning && (double)agentProfile.RunDistance < (double)navMeshAgent.get_remainingDistance()) { actor.IsRunning = true; } float num; if (actor.IsRunning) { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.runSpeed); num = locomotionProfile.MerchantSpeed.runSpeed; } else { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed); num = locomotionProfile.MerchantSpeed.walkSpeed; } navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed)); } else { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed); } } else if (this.MovePoseID == 0) { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed); this.AnimState.setMediumOnWalk = true; this.AnimState.medVelocity = locomotionProfile.MerchantSpeed.walkSpeed; this.AnimState.maxVelocity = locomotionProfile.MerchantSpeed.runSpeed; } else { this.AnimState.moveDirection = Vector3.get_zero(); this.AnimState.setMediumOnWalk = false; this.AnimState.maxVelocity = locomotionProfile.MerchantSpeed.walkSpeed; } this.CharacterAnimation.UpdateState(this.AnimState); }
public virtual TaskStatus OnUpdate() { AgentActor agent = this.Agent; if (Object.op_Equality((Object)agent.Partner, (Object)null)) { return((TaskStatus)1); } AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; NavMeshAgent navMeshAgent = agent.NavMeshAgent; Vector3 destination = this.DesiredPosition(agent.Partner); if ((double)Vector3.Distance(destination, agent.Position) >= (double)agentProfile.RestDistance) { this.SetDestination(destination); this._moved = true; } else { NavMeshPathStatus pathStatus = navMeshAgent.get_pathStatus(); if (pathStatus == 1 || pathStatus == 2) { if ((double)Vector3.Distance(agent.Position, agent.Partner.Position) < (double)agentProfile.RestDistance) { this.Stop(); if (agent.IsRunning) { agent.IsRunning = false; } } } else if (!navMeshAgent.get_pathPending()) { if ((double)navMeshAgent.get_remainingDistance() < (double)agentProfile.RestDistance && agent.IsRunning) { agent.IsRunning = false; } if (this._moved && (double)navMeshAgent.get_remainingDistance() < (double)navMeshAgent.get_stoppingDistance()) { this.Stop(); this._moved = false; } } } return((TaskStatus)3); }
public bool TryGetRemainingDistance( NavMeshAgent agent, Actor actor, out float remainingDistance) { remainingDistance = float.MaxValue; if (Object.op_Equality((Object)agent, (Object)null) || !((Behaviour)agent).get_isActiveAndEnabled() || !agent.get_isOnNavMesh()) { return(false); } if (!agent.get_hasPath()) { return(agent.get_pathPending()); } Vector3[] corners = agent.get_path().get_corners(); remainingDistance = 0.0f; for (int index = 0; index < corners.Length - 1; ++index) { remainingDistance += Vector3.Distance(corners[index], corners[index + 1]); } return(true); }
protected override void OnUpdate(PlayerActor player, ref Actor.InputInfo info) { AgentActor agentPartner = player.AgentPartner; if (Object.op_Equality((Object)agentPartner, (Object)null)) { return; } AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; NavMeshAgent navMeshAgent1 = player.NavMeshAgent; if (navMeshAgent1.get_isOnOffMeshLink()) { this.Stop(player); OffMeshLinkData currentOffMeshLinkData1 = navMeshAgent1.get_currentOffMeshLinkData(); if (!Object.op_Inequality((Object)((OffMeshLinkData) ref currentOffMeshLinkData1).get_offMeshLink(), (Object)null)) { return; } NavMeshAgent navMeshAgent2 = player.NavMeshAgent; M0 m0; if (navMeshAgent2 == null) { m0 = (M0)null; } else { OffMeshLinkData currentOffMeshLinkData2 = navMeshAgent2.get_currentOffMeshLinkData(); m0 = ((Component)((OffMeshLinkData) ref currentOffMeshLinkData2).get_offMeshLink())?.GetComponent <ActionPoint>(); } ActionPoint point = (ActionPoint)m0; if (!Object.op_Inequality((Object)point, (Object)null) || !point.OffMeshAvailablePoint((Actor)player)) { return; } if (point is DoorPoint) { player.CurrentPoint = point; player.PlayerController.ChangeState("DoorOpen", point, (Action)null); } else { player.CurrentPoint = point; player.PlayerController.ChangeState("Move", point, (Action)null); } } else { Vector3 destination = this.DesiredPosition((Actor)agentPartner); if ((double)Vector3.Distance(destination, player.Position) >= (double)agentProfile.RestDistance) { this.SetDestination(player, destination); this._moved = true; } else { NavMeshPathStatus pathStatus = navMeshAgent1.get_pathStatus(); if (pathStatus == 1 || pathStatus == 2) { if ((double)Vector3.Distance(player.Position, agentPartner.Position) >= (double)agentProfile.RestDistance) { return; } this.Stop(player); if (!player.IsRunning) { return; } player.IsRunning = false; } else { if (navMeshAgent1.get_pathPending()) { return; } if ((double)navMeshAgent1.get_remainingDistance() < (double)agentProfile.RestDistance && player.IsRunning) { player.IsRunning = false; } if (!this._moved || (double)navMeshAgent1.get_remainingDistance() >= (double)navMeshAgent1.get_stoppingDistance()) { return; } this.Stop(player); this._moved = false; } } } }
public void UpdateState() { this.CalcAnimSpeed(); this.Look(); this.GroundCheck(); AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; AgentActor actor = this._actor as AgentActor; StuffItem carryingItem = actor.AgentData.CarryingItem; int caseID; if (carryingItem != null && !agentProfile.CanStandEatItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == carryingItem.CategoryID && pair.itemID == carryingItem.ID))) { caseID = 0; } else { int id = actor.AgentData.SickState.ID; Weather weather = Singleton <Manager.Map> .Instance.Simulator.Weather; switch (id) { case 3: caseID = 1; break; case 4: caseID = 0; break; default: StuffItem equipedUmbrellaItem = actor.AgentData.EquipedUmbrellaItem; CommonDefine.ItemIDDefines itemIdDefine = Singleton <Resources> .Instance.CommonDefine.ItemIDDefine; if (equipedUmbrellaItem != null && equipedUmbrellaItem.CategoryID == itemIdDefine.UmbrellaID.categoryID && equipedUmbrellaItem.ID == itemIdDefine.UmbrellaID.itemID) { if (weather == Weather.Rain || weather == Weather.Storm) { caseID = 0; break; } this.SetLocomotionInfo(actor, weather, out caseID); break; } this.SetLocomotionInfo(actor, weather, out caseID); break; } } ActorLocomotion.AnimationState animState = this.AnimState; NavMeshAgent navMeshAgent = this._actor.NavMeshAgent; if (actor.Mode == Desire.ActionType.Date) { if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending()) { if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance && !actor.IsRunning) { actor.IsRunning = true; } float num; if (actor.IsRunning) { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.followRunSpeed); num = locomotionProfile.AgentSpeed.followRunSpeed; } else { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); num = locomotionProfile.AgentSpeed.walkSpeed; } animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed)); } else { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); } } else if (actor.Mode == Desire.ActionType.TakeHPoint || actor.Mode == Desire.ActionType.ChaseYobai || actor.Mode == Desire.ActionType.ComeSleepTogether) { if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending()) { navMeshAgent.set_speed(locomotionProfile.AgentSpeed.runSpeed); } animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed); animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; } else if (actor.Mode == Desire.ActionType.WalkWithAgentFollow || actor.BehaviorResources.Mode == Desire.ActionType.WalkWithAgentFollow) { if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending()) { float num; if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance) { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed); num = locomotionProfile.AgentSpeed.runSpeed; } else { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); num = locomotionProfile.AgentSpeed.walkSpeed; } animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed)); } else { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.followRunSpeed); } } else if (this._actor.Mode == Desire.ActionType.Escape) { if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending()) { float escapeSpeed = locomotionProfile.AgentSpeed.escapeSpeed; animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, escapeSpeed); navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), escapeSpeed, locomotionProfile.LerpSpeed)); } } else { if (actor.TutorialMode) { switch (Manager.Map.GetTutorialProgress()) { case 14: case 15: caseID = actor.TutorialLocomoCaseID; break; } } switch (caseID) { case 0: animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); animState.setMediumOnWalk = false; animState.maxVelocity = locomotionProfile.AgentSpeed.walkSpeed; break; case 1: animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; break; case 2: animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed); animState.setMediumOnWalk = false; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; break; case 100: animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.tutorialWalkSpeed); animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.tutorialWalkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.tutorialRunSpeed; break; case 101: animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.tutorialRunSpeed); animState.setMediumOnWalk = false; animState.maxVelocity = locomotionProfile.AgentSpeed.tutorialRunSpeed; break; default: float num = actor.AgentData.StatsTable[5] * agentProfile.MustRunMotivationPercent; int desireKey = Desire.GetDesireKey(actor.RequestedDesire); float?motivation = actor.GetMotivation(desireKey); if (motivation.HasValue && (double)motivation.Value < (double)num) { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed); } else if (Object.op_Inequality((Object)actor.MapArea, (Object)null)) { int areaId = actor.MapArea.AreaID; animState.moveDirection = !Object.op_Inequality((Object)actor.TargetInSightActionPoint, (Object)null) ? (!Object.op_Inequality((Object)actor.DestWaypoint, (Object)null) ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed) : (actor.DestWaypoint.OwnerArea.AreaID != areaId ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed) : Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed))) : (actor.TargetInSightActionPoint.OwnerArea.AreaID != areaId ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed) : Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed)); } else { animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); } animState.setMediumOnWalk = true; animState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; animState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; animState.onGround = this._actor.IsOnGround; break; } actor.UpdateLocomotionSpeed(actor.DestWaypoint); } this.AnimState = animState; this.CharacterAnimation.UpdateState(animState); }