public override void Move(Vector3 deltaPosition) { if (this._actor.IsKinematic) { return; } LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; Vector3 vector3; ((Vector3) ref vector3).\u002Ector((float)this._actor.StateInfo.move.x, 0.0f, (float)this._actor.StateInfo.move.z); switch (this._actor.Mode) { case Desire.ActionType.Normal: case Desire.ActionType.Date: vector3 = Singleton <Manager.Input> .Instance.IsDown((KeyCode)304) || Singleton <Manager.Input> .Instance.IsDown((KeyCode)303) ? Vector3.op_Multiply(vector3, locomotionProfile.PlayerSpeed.walkSpeed) : Vector3.op_Multiply(vector3, locomotionProfile.PlayerSpeed.normalSpeed); break; default: vector3 = Vector3.op_Multiply(vector3, locomotionProfile.PlayerSpeed.walkSpeed); break; } vector3 = Vector3.op_Addition(vector3, new Vector3((float)this.platformVelocity.x, 0.0f, (float)this.platformVelocity.z)); if (!((this._actor as PlayerActor).PlayerController.State is Follow) && ((Behaviour)this._navMeshAgent).get_enabled()) { this._navMeshAgent.Move(Vector3.op_Multiply(vector3, Time.get_deltaTime())); } this._actor.ForwardMLP = Mathf.Lerp(this._actor.ForwardMLP, this.onGround ? this.GetSlopeDamper(Vector3.op_Division(Vector3.op_UnaryNegation(deltaPosition), Time.get_deltaTime()), this._actor.Normal) : 1f, Time.get_deltaTime() * 5f); if (!float.IsNaN(this._actor.ForwardMLP)) { return; } this._actor.ForwardMLP = 0.0f; }
public void InitializeFaceLight(GameObject root) { if (Object.op_Inequality((Object)this.FaceLight, (Object)null)) { Object.Destroy((Object)((Component)this.FaceLight).get_gameObject()); } if (!Singleton <Resources> .IsInstance() || Object.op_Equality((Object)root, (Object)null)) { return; } LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; string fadeLightParentName = locomotionProfile.FadeLightParentName; if (fadeLightParentName.IsNullOrEmpty()) { return; } GameObject loop = root.get_transform().FindLoop(fadeLightParentName); if (Object.op_Equality((Object)loop, (Object)null)) { return; } DefinePack definePack = Singleton <Resources> .Instance.DefinePack; GameObject gameObject1 = AssetUtility.LoadAsset <GameObject>(definePack.ABPaths.ActorPrefab, "FaceLight", definePack.ABManifests.Default); if (Object.op_Equality((Object)gameObject1, (Object)null)) { return; } GameObject gameObject2 = (GameObject)Object.Instantiate <GameObject>((M0)gameObject1, loop.get_transform(), false); if (Object.op_Equality((Object)gameObject2, (Object)null)) { return; } this.FaceLight = (Light)gameObject2.GetComponent <Light>(); if (Object.op_Equality((Object)this.FaceLight, (Object)null)) { Object.Destroy((Object)gameObject2); } else { ((Component)this.FaceLight).get_transform().set_localRotation(Quaternion.get_identity()); ((Component)this.FaceLight).get_transform().set_localPosition(locomotionProfile.FaceLightOffset); if (!((Behaviour)this.FaceLight).get_enabled()) { return; } ((Behaviour)this.FaceLight).set_enabled(false); } }
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); }
private void CreateHousingWaypoint(int housingID, GameObject objRoot, Vector3 areaSize) { if (Object.op_Equality((Object)objRoot, (Object)null) || !Singleton <Resources> .IsInstance()) { return; } LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; if (Object.op_Equality((Object)locomotionProfile, (Object)null)) { return; } List <ValueTuple <Vector3, Waypoint> > waypointList; if (!this._housingWaypointCacheTable.TryGetValue(housingID, out waypointList) || waypointList == null) { this._housingWaypointCacheTable[housingID] = waypointList = new List <ValueTuple <Vector3, Waypoint> >(); Transform transform = objRoot.get_transform(); if (Object.op_Equality((Object)transform, (Object)null)) { return; } float installationDistance = locomotionProfile.HousingWaypointSetting.InstallationDistance; float installationHeight = locomotionProfile.HousingWaypointSetting.InstallationHeight; SpiralPoint spiralPoint = new SpiralPoint(999); for (int index = 0; (double)installationHeight * (double)index < areaSize.y; ++index) { float num = installationHeight * (float)index; spiralPoint.Clear(); spiralPoint.Limit = 999; while (!spiralPoint.End) { Vector3 vector3 = Vector3.op_Multiply(new Vector3((float)((Vector2Int) ref spiralPoint.Current).get_x(), 0.0f, (float)((Vector2Int) ref spiralPoint.Current).get_y()), installationDistance); vector3.y = (__Null)(double)num; if (areaSize.y > vector3.y && vector3.x > -areaSize.x / 2.0 && (areaSize.x / 2.0 > vector3.x && vector3.z > -areaSize.z / 2.0) && areaSize.z / 2.0 > vector3.z) { vector3 = Vector3.op_Addition(transform.get_position(), Quaternion.op_Multiply(transform.get_rotation(), vector3)); waypointList.Add(new ValueTuple <Vector3, Waypoint>(vector3, (Waypoint)null)); spiralPoint.Next(); } else { break; } } } } this.RefreshWaypoints(housingID, waypointList); }
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 void UpdateState(Actor.InputInfo state, ActorLocomotion.UpdateType updateType) { this._actor.StateInfo = state; this.Look(updateType); this.GroundCheck(); AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile; LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; PlayerActor actor = this._actor as PlayerActor; NavMeshAgent navMeshAgent = this._actor.NavMeshAgent; if (actor.PlayerController.State is Follow) { Actor.InputInfo stateInfo = this._actor.StateInfo; ref Actor.InputInfo local = ref stateInfo; Vector3 vector3 = Vector3.Scale(this._actor.NavMeshAgent.get_velocity(), new Vector3(1f, 0.0f, 1f)); Vector3 normalized = ((Vector3) ref vector3).get_normalized(); local.move = normalized; this._actor.StateInfo = stateInfo; if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance && !actor.IsRunning) { actor.IsRunning = true; } this.AnimState.setMediumOnWalk = true; this.AnimState.medVelocity = locomotionProfile.AgentSpeed.walkSpeed; this.AnimState.maxVelocity = locomotionProfile.AgentSpeed.runSpeed; float num; if (actor.IsRunning) { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed); num = locomotionProfile.AgentSpeed.followRunSpeed; } else { this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed); num = locomotionProfile.AgentSpeed.walkSpeed; } navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed)); }
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); }
public virtual void OnStart() { AgentActor agent = this.Agent; agent.EventKey = EventType.Eat; agent.CurrentPoint = agent.TargetInSightActionPoint; agent.SetActiveOnEquipedItem(false); agent.ChaControl.setAllLayerWeight(0.0f); agent.ElectNextPoint(); agent.CurrentPoint.SetActiveMapItemObjs(false); StuffItem carryingItem = agent.AgentData.CarryingItem; ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems; bool flag = false; foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems) { if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID) { flag = true; break; } } ActionPointInfo outInfo; if (flag) { PoseKeyPair eatDeskId = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.EatDeskID; PoseKeyPair eatChairId = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.EatChairID; if (agent.TargetInSightActionPoint.FindAgentActionPointInfo(EventType.Eat, eatDeskId.poseID, out outInfo)) { agent.Animation.ActionPointInfo = outInfo; } else if (agent.TargetInSightActionPoint.FindAgentActionPointInfo(EventType.Eat, eatChairId.poseID, out outInfo)) { agent.Animation.ActionPointInfo = outInfo; } } else { PoseKeyPair eatDishId = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.EatDishID; if (agent.TargetInSightActionPoint.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out outInfo)) { agent.Animation.ActionPointInfo = outInfo; } } Transform t = ((Component)agent.CurrentPoint).get_transform().FindLoop(outInfo.baseNullName)?.get_transform() ?? ((Component)agent.CurrentPoint).get_transform(); GameObject loop = ((Component)agent.CurrentPoint).get_transform().FindLoop(outInfo.recoveryNullName); agent.Animation.RecoveryPoint = loop?.get_transform(); int eventId = outInfo.eventID; agent.ActionID = eventId; int index = eventId; int poseId = outInfo.poseID; agent.PoseID = poseId; int poseID = poseId; PlayState info = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[index][poseID]; ActorAnimInfo animInfo = agent.Animation.LoadActionState(index, poseID, info); Dictionary <int, int> dictionary; int num; ActionItemInfo eventItemInfo; if (Singleton <Resources> .Instance.Map.FoodEventItemList.TryGetValue(carryingItem.CategoryID, out dictionary) && dictionary.TryGetValue(carryingItem.ID, out num) && Singleton <Resources> .Instance.Map.EventItemList.TryGetValue(num, out eventItemInfo)) { LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile; string parentName = !flag ? locomotionProfile.RootParentName : locomotionProfile.RightHandParentName; GameObject gameObject = agent.LoadEventItem(num, parentName, false, eventItemInfo); if (Object.op_Inequality((Object)gameObject, (Object)null)) { foreach (Renderer componentsInChild in (Renderer[])gameObject.GetComponentsInChildren <Renderer>(true)) { componentsInChild.set_enabled(true); } } } agent.LoadActionFlag(index, poseID); agent.DeactivateNavMeshAgent(); agent.Animation.StopAllAnimCoroutine(); agent.Animation.PlayInAnimation(animInfo.inEnableBlend, animInfo.inBlendSec, info.MainStateInfo.FadeOutTime, animInfo.layer); this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>((IObservable <M0>)agent.AnimationAgent.OnEndActionAsObservable(), 1), (System.Action <M0>)(_ => { agent.Animation.StopAllAnimCoroutine(); agent.Animation.PlayOutAnimation(animInfo.outEnableBlend, animInfo.outBlendSec, animInfo.layer); })); if (animInfo.hasAction) { this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnActionPlayAsObservable(), (System.Action <M0>)(_ => agent.Animation.PlayActionAnimation(animInfo.layer))); } this._onCompleteActionDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnCompleteActionAsObservable(), (System.Action <M0>)(_ => this.Complete())); agent.CurrentPoint.SetSlot((Actor)agent); agent.SetStand(t, info.MainStateInfo.InStateInfo.EnableFade, info.MainStateInfo.InStateInfo.FadeSecond, info.DirectionType); if (!animInfo.isLoop) { return; } agent.SetCurrentSchedule(animInfo.isLoop, outInfo.actionName, animInfo.loopMinTime, animInfo.loopMaxTime, animInfo.hasAction, true); }