Пример #1
0
        public virtual TaskStatus OnUpdate()
        {
            AgentActor  agent            = this.Agent;
            ActionPoint sightActionPoint = agent.TargetInSightActionPoint;

            agent.CurrentPoint = sightActionPoint;
            ActionPoint actionPoint = sightActionPoint;

            actionPoint.SetSlot((Actor)agent);
            PoseKeyPair     sleepTogetherRight = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.SleepTogetherRight;
            PoseKeyPair     sleepTogetherLeft  = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.SleepTogetherLeft;
            bool            flag    = false;
            ActionPointInfo outInfo = new ActionPointInfo();

            if (Object.op_Inequality((Object)actionPoint, (Object)null))
            {
                flag = actionPoint.FindAgentActionPointInfo(EventType.Sleep, sleepTogetherRight.poseID, out outInfo) || actionPoint.FindAgentActionPointInfo(EventType.Sleep, sleepTogetherLeft.poseID, out outInfo);
            }
            if (!flag)
            {
                agent.ChangeBehavior(Desire.ActionType.Normal);
                return((TaskStatus)1);
            }
            Transform  t    = ((Component)actionPoint).get_transform().FindLoop(outInfo.baseNullName)?.get_transform() ?? ((Component)actionPoint).get_transform();
            GameObject loop = ((Component)actionPoint).get_transform().FindLoop(outInfo.recoveryNullName);

            agent.Animation.RecoveryPoint = loop?.get_transform();
            PlayState     info          = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[outInfo.eventID][outInfo.poseID];
            ActorAnimInfo actorAnimInfo = agent.Animation.LoadActionState(outInfo.eventID, outInfo.poseID, info);

            agent.SetActiveOnEquipedItem(false);
            agent.ChaControl.setAllLayerWeight(0.0f);
            agent.DisableActionFlag();
            agent.DeactivateNavMeshAgent();
            agent.IsKinematic = true;
            agent.Animation.PlayInAnimation(actorAnimInfo.inEnableBlend, actorAnimInfo.inBlendSec, info.MainStateInfo.FadeOutTime, actorAnimInfo.layer);
            agent.SetStand(t, info.MainStateInfo.InStateInfo.EnableFade, info.MainStateInfo.InStateInfo.FadeSecond, info.DirectionType);
            agent.SetCurrentSchedule(actorAnimInfo.isLoop, "添い寝", actorAnimInfo.loopMinTime, actorAnimInfo.loopMaxTime, actorAnimInfo.hasAction, true);
            agent.ChangeBehavior(Desire.ActionType.EndTaskSleepAfterDate);
            return((TaskStatus)2);
        }
        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);
        }
Пример #3
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()));
        }