Пример #1
0
        public virtual TaskStatus OnUpdate()
        {
            AgentActor   agent        = this.Agent;
            AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile;
            StuffItem    carryingItem = agent.AgentData.CarryingItem;

            if (carryingItem == null)
            {
                return((TaskStatus)1);
            }
            return(!agentProfile.CanStandEatItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == carryingItem.CategoryID && pair.itemID == carryingItem.ID)) ? (TaskStatus)2 : (TaskStatus)1);
        }
        public virtual TaskStatus OnUpdate()
        {
            AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile;

            foreach (StuffItem stuffItem in this.Agent.AgentData.ItemList)
            {
                StuffItem item = stuffItem;
                if (agentProfile.CanStandEatItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == item.CategoryID && pair.itemID == item.ID)))
                {
                    return((TaskStatus)2);
                }
            }
            return((TaskStatus)1);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        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));
            }
Пример #6
0
        private static void CreateList(
            AgentActor agent,
            List <ActionPoint> source,
            List <ActionPoint> destination,
            EventType eventType,
            bool isFollow)
        {
            int searchCount = Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount;
            Dictionary <int, bool> toRelease = DictionaryPool <int, bool> .Get();

            foreach (ActionPoint actionPoint1 in source)
            {
                if (!Object.op_Equality((Object)actionPoint1, (Object)null) && !Object.op_Equality((Object)actionPoint1.OwnerArea, (Object)null) && (actionPoint1.IsNeutralCommand && !actionPoint1.IsReserved(agent)))
                {
                    List <ActionPoint> connectedActionPoints = actionPoint1.ConnectedActionPoints;
                    if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>())
                    {
                        bool flag = false;
                        foreach (ActionPoint actionPoint2 in connectedActionPoints)
                        {
                            if (!Object.op_Equality((Object)actionPoint2, (Object)null) && (!actionPoint2.IsNeutralCommand || actionPoint2.IsReserved(agent)))
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (flag)
                        {
                            continue;
                        }
                    }
                    MapArea ownerArea = actionPoint1.OwnerArea;
                    bool    flag1;
                    if (!toRelease.TryGetValue(ownerArea.AreaID, out flag1))
                    {
                        toRelease[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID);
                    }
                    if (flag1 && (!isFollow ? actionPoint1.AgentEventType : actionPoint1.AgentDateEventType).Contains(eventType))
                    {
                        switch (eventType)
                        {
                        case EventType.Eat:
                            StuffItem       carryingItem     = agent.AgentData.CarryingItem;
                            AgentProfile    agentProfile     = Singleton <Resources> .Instance.AgentProfile;
                            ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems;
                            bool            flag2            = false;
                            foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems)
                            {
                                if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID)
                                {
                                    flag2 = true;
                                    break;
                                }
                            }
                            ActionPointInfo outInfo;
                            if (flag2)
                            {
                                PoseKeyPair eatDeskId1 = agentProfile.PoseIDTable.EatDeskID;
                                PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID;
                                if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) || actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo))
                                {
                                    break;
                                }
                                continue;
                            }
                            PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID;
                            if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out outInfo))
                            {
                                break;
                            }
                            continue;

                        case EventType.Search:
                            SearchActionPoint searchActionPoint = actionPoint1 as SearchActionPoint;
                            if (Object.op_Inequality((Object)searchActionPoint, (Object)null))
                            {
                                int registerId = searchActionPoint.RegisterID;
                                Dictionary <int, Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable;
                                Environment.SearchActionInfo searchActionInfo1;
                                if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1))
                                {
                                    Environment.SearchActionInfo searchActionInfo2 = new Environment.SearchActionInfo();
                                    searchActionLockTable[registerId] = searchActionInfo2;
                                    searchActionInfo1 = searchActionInfo2;
                                }
                                if (searchActionInfo1.Count < searchCount)
                                {
                                    int       tableId  = searchActionPoint.TableID;
                                    StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId);
                                    if (agent.SearchAreaID == 0)
                                    {
                                        if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                                        {
                                            continue;
                                        }
                                        break;
                                    }
                                    if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                                    {
                                        continue;
                                    }
                                    break;
                                }
                                continue;
                            }
                            break;
                        }
                        if (ExistsDesiredActionPoint._navMeshPath == null)
                        {
                            ExistsDesiredActionPoint._navMeshPath = new NavMeshPath();
                        }
                        if (agent.NavMeshAgent.CalculatePath(actionPoint1.LocatedPosition, ExistsDesiredActionPoint._navMeshPath) && ExistsDesiredActionPoint._navMeshPath.get_status() == null)
                        {
                            destination.Add(actionPoint1);
                        }
                    }
                }
            }
            DictionaryPool <int, bool> .Release(toRelease);
        }
Пример #7
0
        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);
        }
Пример #8
0
        private void Complete()
        {
            AgentActor agent = this.Agent;

            agent.ResetActionFlag();
            AgentData        agentData        = agent.AgentData;
            List <StuffItem> itemListInPantry = Singleton <Game> .Instance.WorldData.Environment.ItemListInPantry;
            List <StuffItem> stuffItemList1   = ListPool <StuffItem> .Get();

            Dictionary <int, Dictionary <int, Dictionary <int, FoodParameterPacket> > > dictionary1 = this._checkType != CheckPantry.CheckType.Eat ? Singleton <Resources> .Instance.GameInfo.DrinkParameterTable : Singleton <Resources> .Instance.GameInfo.FoodParameterTable;

            foreach (StuffItem stuffItem in itemListInPantry)
            {
                Dictionary <int, Dictionary <int, FoodParameterPacket> > dictionary2;
                if (dictionary1.TryGetValue(stuffItem.CategoryID, out dictionary2) && dictionary2.TryGetValue(stuffItem.ID, out Dictionary <int, FoodParameterPacket> _))
                {
                    stuffItemList1.Add(stuffItem);
                }
            }
            StuffItem stuffItem1 = (StuffItem)null;

            if (this._checkType == CheckPantry.CheckType.Eat)
            {
                stuffItem1 = stuffItemList1.GetElement <StuffItem>(Random.Range(0, stuffItemList1.Count));
            }
            else
            {
                AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile;
                float        num          = agentData.StatsTable[0];
                if ((double)num <= (double)agentProfile.ColdTempBorder)
                {
                    List <StuffItem> stuffItemList2 = ListPool <StuffItem> .Get();

                    foreach (StuffItem stuffItem2 in stuffItemList1)
                    {
                        StuffItem stuffItem = stuffItem2;
                        if (agentProfile.LowerTempDrinkItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == stuffItem.CategoryID && pair.itemID == stuffItem.ID)))
                        {
                            stuffItemList2.Add(stuffItem);
                        }
                    }
                    if (!stuffItemList2.IsNullOrEmpty <StuffItem>())
                    {
                        stuffItem1 = stuffItemList2.GetElement <StuffItem>(Random.Range(0, stuffItemList2.Count));
                    }
                    ListPool <StuffItem> .Release(stuffItemList2);
                }
                else if ((double)num >= (double)agentProfile.HotTempBorder)
                {
                    List <StuffItem> stuffItemList2 = ListPool <StuffItem> .Get();

                    foreach (StuffItem stuffItem2 in stuffItemList1)
                    {
                        StuffItem stuffItem = stuffItem2;
                        if (agentProfile.RaiseTempDrinkItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == stuffItem.CategoryID && pair.itemID == stuffItem.ID)))
                        {
                            stuffItemList2.Add(stuffItem);
                        }
                    }
                    if (!stuffItemList2.IsNullOrEmpty <StuffItem>())
                    {
                        stuffItem1 = stuffItemList2.GetElement <StuffItem>(Random.Range(0, stuffItemList2.Count));
                    }
                    ListPool <StuffItem> .Release(stuffItemList2);
                }
                if (stuffItem1 == null)
                {
                    stuffItem1 = stuffItemList1.GetElement <StuffItem>(Random.Range(0, stuffItemList1.Count));
                }
            }
            if (stuffItem1 != null)
            {
                StuffItem stuffItem2 = new StuffItem(stuffItem1.CategoryID, stuffItem1.ID, 1);
                agentData.ItemList.Add(stuffItem2);
                itemListInPantry.RemoveItem(stuffItem2);
            }
            ListPool <StuffItem> .Release(stuffItemList1);

            if (Object.op_Inequality((Object)agent.CurrentPoint, (Object)null))
            {
                agent.CurrentPoint.SetActiveMapItemObjs(true);
                agent.CurrentPoint.ReleaseSlot((Actor)agent);
                agent.CurrentPoint = (ActionPoint)null;
            }
            agent.EventKey                 = (EventType)0;
            agent.PrevActionPoint          = agent.TargetInSightActionPoint;
            agent.TargetInSightActionPoint = (ActionPoint)null;
        }
Пример #9
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            AgentActor agent = this.Agent;

            agent.ElectNextPoint();
            this._poseInfo = new PoseKeyPair?();
            if (Random.Range(0, 2) == 0 || agent.PrevMode == Desire.ActionType.Encounter)
            {
                return;
            }
            agent.SetActiveOnEquipedItem(false);
            agent.ChaControl.setAllLayerWeight(0.0f);
            AgentProfile agentProfile = Singleton <Resources> .Instance.AgentProfile;
            float        num1         = agent.AgentData.StatsTable[0];
            float        num2         = agent.AgentData.StatsTable[2];
            int          desireKey1   = Desire.GetDesireKey(Desire.Type.Bath);
            float?       desire1      = agent.GetDesire(desireKey1);
            int          desireKey2   = Desire.GetDesireKey(Desire.Type.Sleep);
            float?       desire2      = agent.GetDesire(desireKey2);

            if (agent.AgentData.SickState.ID == 0)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.CoughID);
            }
            else if ((!desire2.HasValue ? 0 : ((double)desire2.GetValueOrDefault() >= 70.0 ? 1 : 0)) != 0)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.YawnID);
            }
            else if ((!desire1.HasValue ? 0 : ((double)desire1.GetValueOrDefault() >= 70.0 ? 1 : 0)) != 0)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.GrossID);
            }
            else if ((double)num1 <= (double)agentProfile.ColdTempBorder)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.ColdPoseID);
            }
            else if ((double)num1 >= (double)agentProfile.HotTempBorder)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.HotPoseID);
            }
            else if ((double)num2 <= 0.0)
            {
                this._poseInfo = new PoseKeyPair?(agentProfile.PoseIDTable.HungryID);
            }
            if (!this._poseInfo.HasValue)
            {
                return;
            }
            PoseKeyPair poseKeyPair = this._poseInfo.Value;

            agent.ActionID = poseKeyPair.postureID;
            agent.PoseID   = poseKeyPair.poseID;
            PlayState     info     = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[poseKeyPair.postureID][poseKeyPair.poseID];
            ActorAnimInfo animInfo = agent.Animation.LoadActionState(poseKeyPair.postureID, poseKeyPair.poseID, info);

            agent.LoadActionFlag(poseKeyPair.postureID, poseKeyPair.poseID);
            agent.DeactivateNavMeshAgent();
            agent.Animation.RecoveryPoint = (Transform)null;
            agent.Animation.StopAllAnimCoroutine();
            agent.Animation.PlayInAnimation(animInfo.inEnableBlend, animInfo.inBlendSec, info.MainStateInfo.FadeOutTime, animInfo.layer);
            this._onEndActionDisposable = 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>)(_ => this.Agent.Animation.PlayActionAnimation(animInfo.layer)));
            }
            this._onCompleteActionDisposable = ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>((IObservable <M0>)agent.AnimationAgent.OnCompleteActionAsObservable(), 1), (System.Action <M0>)(_ => this.Complete()));
            if (!animInfo.isLoop)
            {
                return;
            }
            agent.SetCurrentSchedule(animInfo.isLoop, "立ちアクション", animInfo.loopMinTime, animInfo.loopMaxTime, animInfo.hasAction, false);
        }
        private static void CreateList(
            AgentActor agent,
            List <ActionPoint> source,
            List <ActionPoint> destination,
            EventType eventType,
            bool isFollow,
            bool isRain)
        {
            int   searchCount        = Singleton <Manager.Map> .Instance.EnvironmentProfile.SearchCount;
            float meshSampleDistance = Singleton <Resources> .Instance.LocomotionProfile.ActionPointNavMeshSampleDistance;

            foreach (ActionPoint actionPoint1 in source)
            {
                if (!Object.op_Equality((Object)actionPoint1, (Object)null) && !Object.op_Equality((Object)actionPoint1.OwnerArea, (Object)null) && (actionPoint1.IsNeutralCommand && !actionPoint1.IsReserved(agent)))
                {
                    List <ActionPoint> connectedActionPoints = actionPoint1.ConnectedActionPoints;
                    if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>())
                    {
                        bool flag = false;
                        foreach (ActionPoint actionPoint2 in connectedActionPoints)
                        {
                            if (!Object.op_Equality((Object)actionPoint2, (Object)null) && (!actionPoint2.IsNeutralCommand || actionPoint2.IsReserved(agent)))
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (flag)
                        {
                            continue;
                        }
                    }
                    if ((!isRain || actionPoint1.AreaType == MapArea.AreaType.Indoor) && (!isFollow ? actionPoint1.AgentEventType : actionPoint1.AgentDateEventType).Contains(eventType))
                    {
                        switch (eventType)
                        {
                        case EventType.Eat:
                            StuffItem       carryingItem     = agent.AgentData.CarryingItem;
                            AgentProfile    agentProfile     = Singleton <Resources> .Instance.AgentProfile;
                            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 eatDeskId1 = agentProfile.PoseIDTable.EatDeskID;
                                PoseKeyPair eatDeskId2 = agentProfile.PoseIDTable.EatDeskID;
                                if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) || actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo))
                                {
                                    break;
                                }
                                continue;
                            }
                            PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID;
                            if (actionPoint1.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out outInfo))
                            {
                                break;
                            }
                            continue;

                        case EventType.Search:
                            SearchActionPoint searchActionPoint = actionPoint1 as SearchActionPoint;
                            if (Object.op_Inequality((Object)searchActionPoint, (Object)null))
                            {
                                int registerId = searchActionPoint.RegisterID;
                                Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable;
                                AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1;
                                if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1))
                                {
                                    AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo();
                                    searchActionLockTable[registerId] = searchActionInfo2;
                                    searchActionInfo1 = searchActionInfo2;
                                }
                                if (searchActionInfo1.Count < searchCount)
                                {
                                    int       tableId  = searchActionPoint.TableID;
                                    StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId);
                                    if (agent.SearchAreaID == 0)
                                    {
                                        if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                                        {
                                            continue;
                                        }
                                        break;
                                    }
                                    if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                                    {
                                        continue;
                                    }
                                    break;
                                }
                                continue;
                            }
                            break;

                        case EventType.Warp:
                            WarpPoint warpPoint = actionPoint1 as WarpPoint;
                            Dictionary <int, List <WarpPoint> > dictionary;
                            List <WarpPoint> warpPointList;
                            if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(warpPoint.OwnerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2))
                            {
                                continue;
                            }
                            break;
                        }
                        if (SetDesiredActionOtherChange._navMeshPath == null)
                        {
                            SetDesiredActionOtherChange._navMeshPath = new NavMeshPath();
                        }
                        NavMeshHit navMeshHit;
                        if (agent.NavMeshAgent.CalculatePath(actionPoint1.LocatedPosition, SetDesiredActionOtherChange._navMeshPath) && SetDesiredActionOtherChange._navMeshPath.get_status() == null && NavMesh.SamplePosition(actionPoint1.LocatedPosition, ref navMeshHit, meshSampleDistance, agent.NavMeshAgent.get_areaMask()))
                        {
                            destination.Add(actionPoint1);
                        }
                    }
                }
            }
        }
        public virtual TaskStatus OnUpdate()
        {
            AgentActor agent = this.Agent;
            Dictionary <int, CollisionState> collisionStateTable = agent.ActionPointCollisionStateTable;
            List <ActionPoint> toRelease = ListPool <ActionPoint> .Get();

            foreach (ActionPoint searchTarget in agent.SearchTargets)
            {
                CollisionState collisionState;
                if (collisionStateTable.TryGetValue(searchTarget.InstanceID, out collisionState) && collisionState == CollisionState.Enter)
                {
                    toRelease.Add(searchTarget);
                }
            }
            if (toRelease.Count > 0)
            {
                List <ActionPoint> actionPointList = ListPool <ActionPoint> .Get();

                foreach (ActionPoint actionPoint in toRelease)
                {
                    if (actionPoint.IsNeutralCommand)
                    {
                        actionPointList.Add(actionPoint);
                    }
                }
                Desire.Type requestedDesire = agent.RequestedDesire;
                EventType   type            = (EventType)0;
                foreach (ValueTuple <EventType, Desire.Type> valuePair in Desire.ValuePairs)
                {
                    if ((Desire.Type)valuePair.Item2 == requestedDesire)
                    {
                        type = (EventType)valuePair.Item1;
                        break;
                    }
                }
                ActionPoint point = (ActionPoint)null;
                foreach (ActionPoint actionPoint in actionPointList)
                {
                    if (Object.op_Inequality((Object)agent.Partner, (Object)null))
                    {
                        if (actionPoint.AgentDateEventType.Contains(type))
                        {
                            point = actionPoint;
                        }
                    }
                    else if (actionPoint.AgentEventType.Contains(type))
                    {
                        point = actionPoint;
                    }
                }
                if (Object.op_Equality((Object)point, (Object)null))
                {
                    point = actionPointList.GetElement <ActionPoint>(Random.Range(0, actionPointList.Count));
                    if (Object.op_Equality((Object)point, (Object)null))
                    {
                        ListPool <ActionPoint> .Release(actionPointList);

                        ListPool <ActionPoint> .Release(toRelease);

                        return((TaskStatus)1);
                    }
                }
                ListPool <ActionPoint> .Release(actionPointList);

                if (Debug.get_isDebugBuild())
                {
                    if (Object.op_Inequality((Object)agent.Partner, (Object)null))
                    {
                        Debug.Log((object)string.Format("{0} :: Enter Point In Sight: {1} <{2}>", (object)((Object)((Component)agent).get_gameObject()).get_name(), (object)((Object)point).get_name(), (object)point.AgentDateEventType));
                    }
                    else
                    {
                        Debug.Log((object)string.Format("{0} :: Enter Point In Sight: {1} <{2}>", (object)((Object)((Component)agent).get_gameObject()).get_name(), (object)((Object)point).get_name(), (object)point.AgentEventType));
                    }
                }
                if (requestedDesire == Desire.Type.Bath && type == EventType.DressIn && (double)agent.ChaControl.fileGameInfo.flavorState[2] < (double)Singleton <Resources> .Instance.StatusProfile.CanDressBorder)
                {
                    type = EventType.Bath;
                }
                if (type == EventType.Eat)
                {
                    StuffItem       carryingItem     = agent.AgentData.CarryingItem;
                    AgentProfile    agentProfile     = Singleton <Resources> .Instance.AgentProfile;
                    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;
                        }
                    }
                    if (flag)
                    {
                        PoseKeyPair     eatDeskId  = agentProfile.PoseIDTable.EatDeskID;
                        PoseKeyPair     eatChairId = agentProfile.PoseIDTable.EatChairID;
                        ActionPointInfo outInfo;
                        if (!point.FindAgentActionPointInfo(EventType.Eat, eatDeskId.poseID, out outInfo) && !point.FindAgentActionPointInfo(EventType.Eat, eatChairId.poseID, out outInfo))
                        {
                            return((TaskStatus)1);
                        }
                    }
                    else
                    {
                        PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID;
                        if (!point.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out ActionPointInfo _))
                        {
                            return((TaskStatus)1);
                        }
                    }
                }
                switch (agent.AgentController.GetPermission(point))
                {
                case AgentController.PermissionStatus.Prohibition:
                    Debug.Log((object)string.Format("目的地落選: {0}", (object)((Object)point).get_name()));
                    break;

                case AgentController.PermissionStatus.Permission:
                    Debug.Log((object)string.Format("目的地当選: {0}", (object)((Object)point).get_name()));
                    if (type == (EventType)0)
                    {
                        Debug.LogError((object)string.Format("EventType該当なし: {0}", (object)requestedDesire));
                    }
                    agent.EventKey = type;
                    agent.TargetInSightActionPoint = point;
                    agent.RuntimeDesire            = agent.RequestedDesire;
                    break;
                }
            }
            ListPool <ActionPoint> .Release(toRelease);

            if (!Object.op_Inequality((Object)agent.TargetInSightActionPoint, (Object)null))
            {
                return((TaskStatus)1);
            }
            agent.ClearReservedNearActionWaypoints();
            agent.AbortActionPatrol();
            return((TaskStatus)2);
        }
Пример #12
0
        private static bool CheckNeutral(
            AgentActor agent,
            ActionPoint pt,
            Dictionary <int, bool> availableArea,
            int searchCount,
            int chunkID,
            EventType eventType,
            bool isFollow,
            bool isRain,
            float sampleDistance)
        {
            if (Object.op_Equality((Object)pt, (Object)null) || Object.op_Equality((Object)pt.OwnerArea, (Object)null) || (!pt.IsNeutralCommand || pt.IsReserved(agent)))
            {
                return(false);
            }
            List <ActionPoint> connectedActionPoints = pt.ConnectedActionPoints;

            if (!connectedActionPoints.IsNullOrEmpty <ActionPoint>())
            {
                foreach (ActionPoint actionPoint in connectedActionPoints)
                {
                    if (!Object.op_Equality((Object)actionPoint, (Object)null) && (!actionPoint.IsNeutralCommand || actionPoint.IsReserved(agent)))
                    {
                        return(false);
                    }
                }
            }
            if (isRain && pt.AreaType != MapArea.AreaType.Indoor)
            {
                return(false);
            }
            MapArea ownerArea = pt.OwnerArea;

            if (ownerArea.ChunkID == chunkID)
            {
                return(false);
            }
            bool flag1;

            if (!availableArea.TryGetValue(ownerArea.AreaID, out flag1))
            {
                availableArea[ownerArea.AreaID] = flag1 = Singleton <Manager.Map> .Instance.CheckAvailableMapArea(ownerArea.AreaID);
            }
            if (!flag1 || !(!isFollow ? pt.AgentEventType : pt.AgentDateEventType).Contains(eventType))
            {
                return(false);
            }
            switch (eventType)
            {
            case EventType.Eat:
                StuffItem       carryingItem     = agent.AgentData.CarryingItem;
                AgentProfile    agentProfile     = Singleton <Resources> .Instance.AgentProfile;
                ItemIDKeyPair[] canStandEatItems = Singleton <Resources> .Instance.AgentProfile.CanStandEatItems;
                bool            flag2            = false;
                foreach (ItemIDKeyPair itemIdKeyPair in canStandEatItems)
                {
                    if (carryingItem.CategoryID == itemIdKeyPair.categoryID && carryingItem.ID == itemIdKeyPair.itemID)
                    {
                        flag2 = true;
                        break;
                    }
                }
                if (flag2)
                {
                    PoseKeyPair     eatDeskId1 = agentProfile.PoseIDTable.EatDeskID;
                    PoseKeyPair     eatDeskId2 = agentProfile.PoseIDTable.EatDeskID;
                    ActionPointInfo outInfo;
                    if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId1.poseID, out outInfo) && !pt.FindAgentActionPointInfo(EventType.Eat, eatDeskId2.poseID, out outInfo))
                    {
                        return(false);
                    }
                    break;
                }
                PoseKeyPair eatDishId = agentProfile.PoseIDTable.EatDishID;
                if (!pt.FindAgentActionPointInfo(EventType.Eat, eatDishId.poseID, out ActionPointInfo _))
                {
                    return(false);
                }
                break;

            case EventType.Search:
                SearchActionPoint searchActionPoint = pt as SearchActionPoint;
                if (Object.op_Inequality((Object)searchActionPoint, (Object)null))
                {
                    int registerId = searchActionPoint.RegisterID;
                    Dictionary <int, AIProject.SaveData.Environment.SearchActionInfo> searchActionLockTable = agent.AgentData.SearchActionLockTable;
                    AIProject.SaveData.Environment.SearchActionInfo searchActionInfo1;
                    if (!searchActionLockTable.TryGetValue(registerId, out searchActionInfo1))
                    {
                        AIProject.SaveData.Environment.SearchActionInfo searchActionInfo2 = new AIProject.SaveData.Environment.SearchActionInfo();
                        searchActionLockTable[registerId] = searchActionInfo2;
                        searchActionInfo1 = searchActionInfo2;
                    }
                    if (searchActionInfo1.Count >= searchCount)
                    {
                        return(false);
                    }
                    int       tableId  = searchActionPoint.TableID;
                    StuffItem itemInfo = agent.AgentData.EquipedSearchItem(tableId);
                    if (agent.SearchAreaID == 0)
                    {
                        if (tableId != 0 && tableId != 1 && tableId != 2 || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                        {
                            return(false);
                        }
                        break;
                    }
                    if (agent.SearchAreaID != searchActionPoint.TableID || !searchActionPoint.CanSearch(EventType.Search, itemInfo))
                    {
                        return(false);
                    }
                    break;
                }
                break;

            case EventType.Warp:
                WarpPoint warpPoint = pt as WarpPoint;
                Dictionary <int, List <WarpPoint> > dictionary;
                List <WarpPoint> warpPointList;
                if (!Object.op_Inequality((Object)warpPoint, (Object)null) || !Singleton <Manager.Map> .Instance.WarpPointDic.TryGetValue(ownerArea.ChunkID, out dictionary) || (!dictionary.TryGetValue(warpPoint.TableID, out warpPointList) || warpPointList.Count < 2))
                {
                    return(false);
                }
                break;
            }
            if (SetDesiredActionOtherChunk._navMeshPath == null)
            {
                SetDesiredActionOtherChunk._navMeshPath = new NavMeshPath();
            }
            NavMeshHit navMeshHit;

            return(agent.NavMeshAgent.CalculatePath(pt.LocatedPosition, SetDesiredActionOtherChunk._navMeshPath) && SetDesiredActionOtherChunk._navMeshPath.get_status() == null && NavMesh.SamplePosition(pt.LocatedPosition, ref navMeshHit, sampleDistance, agent.NavMeshAgent.get_areaMask()));
        }