Example #1
0
        public virtual TaskStatus OnUpdate()
        {
            float num1 = 0.0f;

            Desire.Type type = Desire.WithPlayerDesireTable[0];
            if (this._withPlayer)
            {
                foreach (Desire.Type key in Desire.WithPlayerDesireTable)
                {
                    float num2;
                    if (this.Agent.AgentData.DesireTable.TryGetValue(Desire.GetDesireKey(key), out num2) && (double)num1 < (double)num2)
                    {
                        num1 = num2;
                        type = key;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <int, float> keyValuePair in this.Agent.AgentData.DesireTable)
                {
                    if ((double)num1 < (double)keyValuePair.Value)
                    {
                        num1 = keyValuePair.Value;
                        type = (Desire.Type)keyValuePair.Key;
                    }
                }
            }
            if (type == Desire.Type.None)
            {
                return((TaskStatus)1);
            }
            return(type == this._desire ? (TaskStatus)2 : (TaskStatus)1);
        }
 public static ValueTuple <EventType, Desire.Type> FirstDesire(
     ValueTuple <EventType, Desire.Type>[] collection,
     Desire.Type type)
 {
     foreach (ValueTuple <EventType, Desire.Type> valueTuple in collection)
     {
         if ((Desire.Type)valueTuple.Item2 == type)
         {
             return(valueTuple);
         }
     }
     return((ValueTuple <EventType, Desire.Type>)null);
 }
 private static bool AnyDesire(
     ReadOnlyDictionary <EventType, Desire.Type> table,
     Desire.Type type)
 {
     using (IEnumerator <KeyValuePair <EventType, Desire.Type> > enumerator = table.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.Value == type)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 private static KeyValuePair <EventType, Desire.Type> FirstDesire(
     ReadOnlyDictionary <EventType, Desire.Type> table,
     Desire.Type type)
 {
     using (IEnumerator <KeyValuePair <EventType, Desire.Type> > enumerator = table.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             KeyValuePair <EventType, Desire.Type> current = enumerator.Current;
             if (current.Value == type)
             {
                 return(current);
             }
         }
     }
     return(new KeyValuePair <EventType, Desire.Type>());
 }
Example #5
0
        public static ValueTuple <AIProject.EventType, Desire.Type>[] FindAt(
            Desire.Type type)
        {
            List <ValueTuple <AIProject.EventType, Desire.Type> > toRelease = ListPool <ValueTuple <AIProject.EventType, Desire.Type> > .Get();

            foreach (ValueTuple <AIProject.EventType, Desire.Type> valuePair in Desire.ValuePairs)
            {
                if (type == (Desire.Type)valuePair.Item2)
                {
                    toRelease.Add(valuePair);
                }
            }
            ValueTuple <AIProject.EventType, Desire.Type>[] array = toRelease.ToArray();
            ListPool <ValueTuple <AIProject.EventType, Desire.Type> > .Release(toRelease);

            return(array);
        }
 private static bool AnyDesire(ValueTuple <EventType, Desire.Type>[] collection, Desire.Type type)
 {
     foreach (ValueTuple <EventType, Desire.Type> valueTuple in collection)
     {
         if ((Desire.Type)valueTuple.Item2 == type)
         {
             return(true);
         }
     }
     return(false);
 }
        public AgentController.PermissionStatus GetPermission(ActionPoint point)
        {
            AgentActor actor = this._actor as AgentActor;

            ValueTuple <EventType, Desire.Type>[] valuePairs = Desire.ValuePairs;
            Desire.Type requestedDesire = actor.RequestedDesire;
            if (!point.IsNeutralCommand)
            {
                Debug.Log((object)"行動ポイントが満員御礼");
                AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                this.Permission = permissionStatus1;
                AgentController.PermissionStatus permissionStatus2;
                return(permissionStatus2 = permissionStatus1);
            }
            AgentController.PermissionStatus permissionStatus3;
            if (AgentController.AnyDesire(valuePairs, requestedDesire))
            {
                EventType type = (EventType)AgentController.FirstDesire(valuePairs, requestedDesire).Item1;
                if (requestedDesire == Desire.Type.Bath && (double)actor.ChaControl.fileGameInfo.flavorState[2] < (double)Singleton <Resources> .Instance.StatusProfile.CanDressBorder)
                {
                    type = EventType.Bath;
                }
                if (point.AgentEventType.Contains(type))
                {
                    if (point is SearchActionPoint)
                    {
                        SearchActionPoint searchActionPoint = point as SearchActionPoint;
                        StuffItem         itemInfo          = actor.AgentData.EquipedSearchItem(searchActionPoint.TableID);
                        if (actor.SearchAreaID == 0)
                        {
                            if (searchActionPoint.TableID == 0 || searchActionPoint.TableID == 1 || searchActionPoint.TableID == 2)
                            {
                                if (searchActionPoint.CanSearch(EventType.Search, itemInfo))
                                {
                                    AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Permission;
                                    this.Permission   = permissionStatus1;
                                    permissionStatus3 = permissionStatus1;
                                }
                                else
                                {
                                    AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                                    this.Permission   = permissionStatus1;
                                    permissionStatus3 = permissionStatus1;
                                }
                            }
                            else
                            {
                                AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                                this.Permission   = permissionStatus1;
                                permissionStatus3 = permissionStatus1;
                            }
                        }
                        else if (actor.SearchAreaID == searchActionPoint.TableID)
                        {
                            if (searchActionPoint.CanSearch(EventType.Search, itemInfo))
                            {
                                AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Permission;
                                this.Permission   = permissionStatus1;
                                permissionStatus3 = permissionStatus1;
                            }
                            else
                            {
                                AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                                this.Permission   = permissionStatus1;
                                permissionStatus3 = permissionStatus1;
                            }
                        }
                        else
                        {
                            AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                            this.Permission   = permissionStatus1;
                            permissionStatus3 = permissionStatus1;
                        }
                    }
                    else
                    {
                        AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Permission;
                        this.Permission   = permissionStatus1;
                        permissionStatus3 = permissionStatus1;
                    }
                }
                else
                {
                    AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                    this.Permission   = permissionStatus1;
                    permissionStatus3 = permissionStatus1;
                }
            }
            else
            {
                AgentController.PermissionStatus permissionStatus1 = AgentController.PermissionStatus.Prohibition;
                this.Permission   = permissionStatus1;
                permissionStatus3 = permissionStatus1;
            }
            return(permissionStatus3);
        }
        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);
        }
 public static bool Contains(this Desire.Type source, Desire.Type desire)
 {
     return(source == (source | desire) && desire != Desire.Type.None);
 }
Example #10
0
        public static int GetDesireKey(Desire.Type key)
        {
            int num;

            return(!Desire._desireKeyTable.TryGetValue(key, out num) ? -1 : num);
        }