Beispiel #1
0
        private void CheckPlayer()
        {
            List <Actor> toRelease = ListPool <Actor> .Get();

            foreach (Actor targetActor in this.Agent.TargetActors)
            {
                CollisionState collisionState;
                if (targetActor is PlayerActor && this.Agent.ActorCollisionStateTable.TryGetValue(targetActor.InstanceID, out collisionState) && collisionState == CollisionState.Enter)
                {
                    toRelease.Add(targetActor);
                }
            }
            if (toRelease.Count > 0)
            {
                List <Actor> actorList = ListPool <Actor> .Get();

                foreach (Actor actor in toRelease)
                {
                    actorList.Add(actor);
                }
                ActorController capturedInSight = AgentActor.GetCapturedInSight(this.Agent, actorList);
                ListPool <Actor> .Release(actorList);

                if (Object.op_Equality((Object)capturedInSight, (Object)null) || !(capturedInSight.Actor is PlayerActor))
                {
                    ListPool <Actor> .Release(toRelease);

                    return;
                }
                if (!capturedInSight.Actor.IsNeutralCommand)
                {
                    return;
                }
                this.Agent.TargetInSightActor = capturedInSight.Actor;
            }
            ListPool <Actor> .Release(toRelease);
        }
        public Weather Lottery(List <Weather> list)
        {
            Dictionary <Weather, float>           table     = this.Table;
            List <KeyValuePair <Weather, float> > toRelease = ListPool <KeyValuePair <Weather, float> > .Get();

            foreach (KeyValuePair <Weather, float> keyValuePair in table)
            {
                foreach (Weather weather in list)
                {
                    if (keyValuePair.Key == weather)
                    {
                        toRelease.Add(keyValuePair);
                    }
                }
            }
            float num1 = 0.0f;

            foreach (KeyValuePair <Weather, float> keyValuePair in toRelease)
            {
                num1 += keyValuePair.Value;
            }
            float   num2     = Random.Range(0.0f, num1);
            Weather weather1 = ~Weather.Clear;

            foreach (KeyValuePair <Weather, float> keyValuePair in toRelease)
            {
                if ((double)num2 <= (double)keyValuePair.Value)
                {
                    weather1 = keyValuePair.Key;
                    break;
                }
                num2 -= keyValuePair.Value;
            }
            ListPool <KeyValuePair <Weather, float> > .Release(toRelease);

            return(weather1);
        }
Beispiel #3
0
        public void RefreshCommands()
        {
            List <CommandLabel.CommandInfo> toRelease = ListPool <CommandLabel.CommandInfo> .Get();

            PlayerActor player     = Singleton <Manager.Map> .Instance.Player;
            AgentActor  agentActor = (AgentActor)null;

            if (Object.op_Inequality((Object)player, (Object)null))
            {
                agentActor = player.AgentPartner;
            }
            foreach (ICommandable considerationObject in this._considerationObjects)
            {
                if (Object.op_Equality((Object)agentActor, (Object)null))
                {
                    if (!considerationObject.Labels.IsNullOrEmpty <CommandLabel.CommandInfo>())
                    {
                        foreach (CommandLabel.CommandInfo label in considerationObject.Labels)
                        {
                            Func <bool> displayCondition = label.DisplayCondition;
                            bool?       nullable1;
                            bool?       nullable2;
                            if (displayCondition == null)
                            {
                                nullable1 = new bool?();
                                nullable2 = nullable1;
                            }
                            else
                            {
                                nullable2 = new bool?(displayCondition());
                            }
                            nullable1 = nullable2;
                            if ((!nullable1.HasValue ? 1 : (nullable1.Value ? 1 : 0)) != 0)
                            {
                                label.Position = considerationObject.CommandCenter;
                                toRelease.Add(label);
                            }
                        }
                    }
                }
                else
                {
                    CommandLabel.CommandInfo[] source = !Object.op_Inequality((Object)player, (Object)null) ? (CommandLabel.CommandInfo[])null : (player.Mode != Desire.ActionType.Date ? considerationObject.Labels : considerationObject.DateLabels);
                    if (!source.IsNullOrEmpty <CommandLabel.CommandInfo>())
                    {
                        foreach (CommandLabel.CommandInfo commandInfo in source)
                        {
                            commandInfo.Position = considerationObject.CommandCenter;
                            toRelease.Add(commandInfo);
                        }
                    }
                }
            }
            if (Object.op_Equality((Object)agentActor, (Object)null) && this._isFishableState.get_Value())
            {
                this.FishingLabel.Position = this.BobberPosition;
                toRelease.Add(this.FishingLabel);
            }
            if (Singleton <MapUIContainer> .IsInstance())
            {
                MapUIContainer.CommandLabel.ObjectCommands = toRelease.ToArray();
            }
            ListPool <CommandLabel.CommandInfo> .Release(toRelease);
        }
Beispiel #4
0
        protected override void InitSub()
        {
            CommonDefine.CommonIconGroup icon          = Singleton <Resources> .Instance.CommonDefine.Icon;
            EventType playerEventMask                  = Singleton <Resources> .Instance.DefinePack.MapDefines.PlayerEventMask;
            List <CommandLabel.CommandInfo> toRelease1 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.LabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                WarpPoint warpPoint = this;
                if (this._playerEventType.Contains(pair.Key) && playerEventMask.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    ActionPointInfo actionPointInfo = this._playerInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                    string          actionName      = actionPointInfo.actionName;
                    Sprite          sprite;
                    Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);

                    this._tableID = actionPointInfo.searchAreaID;
                    Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                    toRelease1.Add(new CommandLabel.CommandInfo()
                    {
                        Text             = actionName,
                        Icon             = sprite,
                        IsHold           = true,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = transform,
                        Condition        = (Func <PlayerActor, bool>)(x => warpPoint.CanAccess()),
                        ErrorText        = (Func <PlayerActor, string>)(x => warpPoint.ErrorText()),
                        Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)warpPoint))
                    });
                }
            }
            this._labels = toRelease1.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease1);

            for (int key = 0; key < 2; ++key)
            {
                List <CommandLabel.CommandInfo> toRelease2 = ListPool <CommandLabel.CommandInfo> .Get();

                foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.DateLabelTable)
                {
                    KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                    WarpPoint warpPoint = this;
                    List <DateActionPointInfo> dateActionPointInfoList;
                    if (this._playerDateEventType[key].Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _) && this._playerDateInfos.TryGetValue(key, out dateActionPointInfoList))
                    {
                        DateActionPointInfo dateActionPointInfo = dateActionPointInfoList.Find((Predicate <DateActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                        string actionName = dateActionPointInfo.actionName;
                        Sprite sprite;
                        Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(dateActionPointInfo.iconID, out sprite);

                        Transform transform = ((Component)this).get_transform().FindLoop(dateActionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                        toRelease2.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = true,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Condition        = (Func <PlayerActor, bool>)(x => warpPoint.CanAccess()),
                            ErrorText        = (Func <PlayerActor, string>)(x => warpPoint.ErrorText()),
                            Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)warpPoint))
                        });
                    }
                }
                this._dateLabels[key] = toRelease2.ToArray();
                ListPool <CommandLabel.CommandInfo> .Release(toRelease2);
            }
            List <CommandLabel.CommandInfo> toRelease3 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.SickLabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                WarpPoint warpPoint = this;
                if (this._playerEventType.Contains(pair.Key) && playerEventMask.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    ActionPointInfo actionPointInfo = this._playerInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                    string          actionName      = actionPointInfo.actionName;
                    Sprite          sprite;
                    Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);

                    Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                    toRelease3.Add(new CommandLabel.CommandInfo()
                    {
                        Text             = pair.Value.Item2,
                        Icon             = sprite,
                        IsHold           = true,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = transform,
                        Condition        = (Func <PlayerActor, bool>)(x => warpPoint.CanAccess()),
                        ErrorText        = (Func <PlayerActor, string>)(x => warpPoint.ErrorText()),
                        Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)warpPoint))
                    });
                }
            }
            this._sickLabels = toRelease3.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease3);

            if (!this._playerInfos.IsNullOrEmpty <ActionPointInfo>() && this._playerInfos.Exists((Predicate <ActionPointInfo>)(x => x.eventTypeMask == EventType.Warp)) || !this._agentEventType.Contains(EventType.Warp))
            {
                return;
            }
            this._tableID = this._agentInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == EventType.Warp)).searchAreaID;
        }
        protected override void InitSub()
        {
            this._offMeshLink  = (OffMeshLink)((Component)this).GetComponent <OffMeshLink>();
            this.DoorAnimation = (DoorAnimation)((Component)this).GetComponent <DoorAnimation>();
            CommonDefine.CommonIconGroup icon          = Singleton <Resources> .Instance.CommonDefine.Icon;
            EventType playerEventMask                  = Singleton <Resources> .Instance.DefinePack.MapDefines.PlayerEventMask;
            List <CommandLabel.CommandInfo> toRelease1 = ListPool <CommandLabel.CommandInfo> .Get();

            List <CommandLabel.CommandInfo> toRelease2 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.LabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                DoorPoint doorPoint = this;
                if (this._playerEventType.Contains(pair.Key) && playerEventMask.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    ActionPointInfo actionPointInfo = this._playerInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                    string          actionName      = actionPointInfo.actionName;
                    Sprite          sprite;
                    Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);

                    Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                    if (pair.Key == EventType.DoorOpen)
                    {
                        toRelease1.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = false,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)doorPoint))
                        });
                        if (actionPointInfo.doorOpenType > -1)
                        {
                            this._openType = (DoorPoint.OpenTypeState)actionPointInfo.doorOpenType;
                        }
                    }
                    else if (pair.Key == EventType.DoorClose)
                    {
                        toRelease2.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = false,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)doorPoint))
                        });
                        if (actionPointInfo.doorOpenType > -1)
                        {
                            this._openType = (DoorPoint.OpenTypeState)actionPointInfo.doorOpenType;
                        }
                    }
                }
            }
            this._openingLabels = toRelease1.ToArray();
            this._closingLabels = toRelease2.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease1);

            ListPool <CommandLabel.CommandInfo> .Release(toRelease2);

            List <CommandLabel.CommandInfo> toRelease3 = ListPool <CommandLabel.CommandInfo> .Get();

            List <CommandLabel.CommandInfo> toRelease4 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.SickLabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                DoorPoint doorPoint = this;
                if (this._playerEventType.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    ActionPointInfo actionPointInfo = this._playerInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                    string          actionName      = actionPointInfo.actionName;
                    Sprite          sprite;
                    Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);

                    Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                    if (pair.Key == EventType.DoorOpen)
                    {
                        toRelease3.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = false,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)doorPoint))
                        });
                        if (actionPointInfo.doorOpenType > -1)
                        {
                            this._openType = (DoorPoint.OpenTypeState)actionPointInfo.doorOpenType;
                        }
                    }
                    else if (pair.Key == EventType.DoorClose)
                    {
                        toRelease4.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = false,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)doorPoint))
                        });
                        if (actionPointInfo.doorOpenType > -1)
                        {
                            this._openType = (DoorPoint.OpenTypeState)actionPointInfo.doorOpenType;
                        }
                    }
                }
            }
            this._sickOpeningLabels = toRelease3.ToArray();
            this._sickClosingLabels = toRelease4.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease3);

            ListPool <CommandLabel.CommandInfo> .Release(toRelease4);
        }
        private void LoadAreaOpenObjects()
        {
            if (!Singleton <Manager.Map> .IsInstance() || !Singleton <Resources> .IsInstance())
            {
                return;
            }
            Dictionary <int, Dictionary <bool, ForcedHideObject[]> > areaOpenObjectTable  = Singleton <Manager.Map> .Instance.AreaOpenObjectTable;
            Dictionary <int, Dictionary <bool, string[]> >           stateObjectNameTable = Singleton <Resources> .Instance.Map.AreaOpenStateObjectNameTable;

            areaOpenObjectTable.Clear();
            if (stateObjectNameTable.IsNullOrEmpty <int, Dictionary <bool, string[]> >())
            {
                return;
            }
            foreach (KeyValuePair <int, Dictionary <bool, string[]> > keyValuePair1 in stateObjectNameTable)
            {
                if (!keyValuePair1.Value.IsNullOrEmpty <bool, string[]>())
                {
                    int key1 = keyValuePair1.Key;
                    foreach (KeyValuePair <bool, string[]> keyValuePair2 in keyValuePair1.Value)
                    {
                        if (!keyValuePair2.Value.IsNullOrEmpty <string>())
                        {
                            bool key2 = keyValuePair2.Key;
                            List <GameObject> gameObjectList = ListPool <GameObject> .Get();

                            foreach (string str in keyValuePair2.Value)
                            {
                                if (!str.IsNullOrEmpty())
                                {
                                    GameObject loop = ((Component)this).get_transform().FindLoop(str);
                                    if (!Object.op_Equality((Object)loop, (Object)null))
                                    {
                                        gameObjectList.Add(loop);
                                    }
                                }
                            }
                            if (!gameObjectList.IsNullOrEmpty <GameObject>())
                            {
                                List <ForcedHideObject> toRelease = ListPool <ForcedHideObject> .Get();

                                for (int index = 0; index < gameObjectList.Count; ++index)
                                {
                                    ForcedHideObject orAddComponent = gameObjectList[index].GetOrAddComponent <ForcedHideObject>();
                                    if (!Object.op_Equality((Object)orAddComponent, (Object)null) && !toRelease.Contains(orAddComponent))
                                    {
                                        orAddComponent.Init();
                                        toRelease.Add(orAddComponent);
                                    }
                                }
                                ForcedHideObject[] forcedHideObjectArray = new ForcedHideObject[toRelease.Count];
                                for (int index = 0; index < forcedHideObjectArray.Length; ++index)
                                {
                                    forcedHideObjectArray[index] = toRelease[index];
                                }
                                Dictionary <bool, ForcedHideObject[]> dictionary;
                                if (!areaOpenObjectTable.TryGetValue(key1, out dictionary) || dictionary == null)
                                {
                                    areaOpenObjectTable[key1] = dictionary = new Dictionary <bool, ForcedHideObject[]>();
                                }
                                dictionary[key2] = forcedHideObjectArray;
                                ListPool <ForcedHideObject> .Release(toRelease);
                            }
                            ListPool <GameObject> .Release(gameObjectList);
                        }
                    }
                }
            }
            Singleton <Manager.Map> .Instance.RefreshAreaOpenObject();
        }
        protected override void InitSub()
        {
            CommonDefine.CommonIconGroup icon          = Singleton <Resources> .Instance.CommonDefine.Icon;
            EventType playerEventMask                  = Singleton <Resources> .Instance.DefinePack.MapDefines.PlayerEventMask;
            List <CommandLabel.CommandInfo> toRelease1 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.LabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                SearchActionPoint searchActionPoint = this;
                if (this._playerEventType.Contains(pair.Key) && playerEventMask.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    ActionPointInfo actionPointInfo = this._playerInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                    string          actionName      = actionPointInfo.actionName;
                    Sprite          sprite;
                    if (pair.Key == EventType.Search)
                    {
                        if (actionPointInfo.searchAreaID > -1)
                        {
                            this._tableID = actionPointInfo.searchAreaID;
                        }
                        if (actionPointInfo.gradeValue > -1 && actionPointInfo.gradeValue > this._grade)
                        {
                            this._grade = actionPointInfo.gradeValue;
                        }
                        Dictionary <int, int> dictionary;
                        if (Singleton <Resources> .Instance.itemIconTables.EquipmentIconTable.TryGetValue(this._tableID, out dictionary))
                        {
                            int key;
                            if (dictionary.TryGetValue(this._grade, out key))
                            {
                                Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(key, out sprite);
                            }
                            else
                            {
                                sprite = (Sprite)null;
                            }
                        }
                        else
                        {
                            sprite = (Sprite)null;
                        }
                    }
                    else
                    {
                        Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);
                    }
                    Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                    toRelease1.Add(new CommandLabel.CommandInfo()
                    {
                        Text             = actionName,
                        Icon             = sprite,
                        IsHold           = pair.Key == EventType.Search,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = transform,
                        Condition        = (Func <PlayerActor, bool>)(x => closure_0.CanAction(x, pair.Key, actionPointInfo.searchAreaID)),
                        ErrorText        = (Func <PlayerActor, string>)(x => closure_0.ErrorText(x, pair.Key, actionPointInfo.searchAreaID)),
                        CoolTimeFillRate = (Func <float>)(() =>
                        {
                            AIProject.SaveData.Environment.SearchActionInfo searchActionInfo;
                            if (!Singleton <Game> .Instance.Environment.SearchActionLockTable.TryGetValue(closure_0.RegisterID, out searchActionInfo))
                            {
                                return(0.0f);
                            }
                            EnvironmentProfile environmentProfile = Singleton <Manager.Map> .Instance.EnvironmentProfile;
                            return(searchActionInfo.Count < environmentProfile.SearchCount ? 0.0f : 1f - searchActionInfo.ElapsedTime / environmentProfile.SearchCoolTimeDuration);
                        }),
                        Event = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)closure_0))
                    });
                }
            }
            this._labels = toRelease1.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease1);

            for (int key1 = 0; key1 < 2; ++key1)
            {
                List <CommandLabel.CommandInfo> toRelease2 = ListPool <CommandLabel.CommandInfo> .Get();

                foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.DateLabelTable)
                {
                    KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                    SearchActionPoint          searchActionPoint = this;
                    List <DateActionPointInfo> dateActionPointInfoList;
                    if (this._playerDateEventType[key1].Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _) && this._playerDateInfos.TryGetValue(key1, out dateActionPointInfoList))
                    {
                        DateActionPointInfo actionPointInfo = dateActionPointInfoList.Find((Predicate <DateActionPointInfo>)(x => x.eventTypeMask == pair.Key));
                        string actionName = actionPointInfo.actionName;
                        Sprite sprite;
                        if (pair.Key == EventType.Search)
                        {
                            if (actionPointInfo.searchAreaID > -1)
                            {
                                this._tableID = actionPointInfo.searchAreaID;
                            }
                            if (actionPointInfo.gradeValue > -1 && actionPointInfo.gradeValue > this._grade)
                            {
                                this._grade = actionPointInfo.gradeValue;
                            }
                            Dictionary <int, int> dictionary;
                            if (Singleton <Resources> .Instance.itemIconTables.EquipmentIconTable.TryGetValue(this._tableID, out dictionary))
                            {
                                int key2;
                                if (dictionary.TryGetValue(this._grade, out key2))
                                {
                                    Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(key2, out sprite);
                                }
                                else
                                {
                                    sprite = (Sprite)null;
                                }
                            }
                            else
                            {
                                sprite = (Sprite)null;
                            }
                        }
                        else
                        {
                            Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(actionPointInfo.iconID, out sprite);
                        }
                        Transform transform = ((Component)this).get_transform().FindLoop(actionPointInfo.labelNullName)?.get_transform() ?? ((Component)this).get_transform();
                        toRelease2.Add(new CommandLabel.CommandInfo()
                        {
                            Text             = actionName,
                            Icon             = sprite,
                            IsHold           = pair.Key == EventType.Search,
                            TargetSpriteInfo = icon.ActionSpriteInfo,
                            Transform        = transform,
                            Condition        = (Func <PlayerActor, bool>)(x => closure_1.CanAction(x, pair.Key, actionPointInfo.searchAreaID)),
                            ErrorText        = (Func <PlayerActor, string>)(x => closure_1.ErrorText(x, pair.Key, actionPointInfo.searchAreaID)),
                            CoolTimeFillRate = (Func <float>)(() =>
                            {
                                AIProject.SaveData.Environment.SearchActionInfo searchActionInfo;
                                if (!Singleton <Game> .Instance.Environment.SearchActionLockTable.TryGetValue(closure_1.RegisterID, out searchActionInfo))
                                {
                                    return(0.0f);
                                }
                                EnvironmentProfile environmentProfile = Singleton <Manager.Map> .Instance.EnvironmentProfile;
                                return(searchActionInfo.Count < environmentProfile.SearchCount ? 0.0f : 1f - searchActionInfo.ElapsedTime / environmentProfile.SearchCoolTimeDuration);
                            }),
                            Event = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)closure_1))
                        });
                    }
                }
                this._dateLabels[key1] = toRelease2.ToArray();
                ListPool <CommandLabel.CommandInfo> .Release(toRelease2);
            }
            List <CommandLabel.CommandInfo> toRelease3 = ListPool <CommandLabel.CommandInfo> .Get();

            foreach (KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > keyValuePair in ActionPoint.SickLabelTable)
            {
                KeyValuePair <EventType, Tuple <int, string, System.Action <PlayerActor, ActionPoint> > > pair = keyValuePair;
                SearchActionPoint searchActionPoint = this;
                if (this._playerEventType.Contains(pair.Key) && playerEventMask.Contains(pair.Key) && AIProject.Definitions.Action.NameTable.TryGetValue(pair.Key, out ValueTuple <int, string> _))
                {
                    toRelease3.Add(new CommandLabel.CommandInfo()
                    {
                        Text             = pair.Value.Item2,
                        Icon             = (Sprite)null,
                        IsHold           = false,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = ((Component)this).get_transform(),
                        Event            = (System.Action)(() => pair.Value.Item3(Singleton <Manager.Map> .Instance.Player, (ActionPoint)searchActionPoint))
                    });
                }
            }
            this._sickLabels = toRelease3.ToArray();
            ListPool <CommandLabel.CommandInfo> .Release(toRelease3);

            if (!this._playerInfos.IsNullOrEmpty <ActionPointInfo>() && this._playerInfos.Exists((Predicate <ActionPointInfo>)(x => x.eventTypeMask == EventType.Search)) || !this._agentEventType.Contains(EventType.Search))
            {
                return;
            }
            this._tableID = this._agentInfos.Find((Predicate <ActionPointInfo>)(x => x.eventTypeMask == EventType.Search)).searchAreaID;
        }
Beispiel #8
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            AgentActor agent    = this.Agent;
            Actor      listener = this._partner = agent.CommandPartner;

            if (Object.op_Equality((Object)listener, (Object)null))
            {
                return;
            }
            agent.SetActiveOnEquipedItem(false);
            listener.SetActiveOnEquipedItem(false);
            agent.StopNavMeshAgent();
            listener.StopNavMeshAgent();
            agent.ChangeStaticNavMeshAgentAvoidance();
            listener.ChangeStaticNavMeshAgentAvoidance();
            agent.DisableActionFlag();
            if (listener is AgentActor)
            {
                (listener as AgentActor).DisableActionFlag();
            }
            agent.RuntimeDesire = Desire.Type.Lonely;
            int listenID = 0;
            Dictionary <int, int> listenerRelationTable;

            if (listener is AgentActor)
            {
                AgentActor partner = this._partner as AgentActor;
                int        id      = this.Agent.ID;
                if (!partner.AgentData.FriendlyRelationShipTable.TryGetValue(id, out this._relationShip))
                {
                    int num = 50;
                    partner.AgentData.FriendlyRelationShipTable[id] = num;
                    this._relationShip = num;
                }
                listenerRelationTable = Singleton <Resources> .Instance.Animation.TalkListenerRelationTable;
            }
            else
            {
                int id = listener.ID;
                if (!agent.AgentData.FriendlyRelationShipTable.TryGetValue(id, out this._relationShip))
                {
                    int num = 50;
                    agent.AgentData.FriendlyRelationShipTable[id] = num;
                    this._relationShip = num;
                }
                listenerRelationTable = Singleton <Resources> .Instance.Animation.MerchantListenerRelationTable;
            }
            List <KeyValuePair <int, int> > toRelease = ListPool <KeyValuePair <int, int> > .Get();

            foreach (KeyValuePair <int, int> keyValuePair in listenerRelationTable)
            {
                toRelease.Add(keyValuePair);
            }
            toRelease.Sort((Comparison <KeyValuePair <int, int> >)((v1, v2) => v1.Value - v2.Value));
            for (int index = 0; index < toRelease.Count; ++index)
            {
                KeyValuePair <int, int> keyValuePair = toRelease[index];
                if (this._relationShip <= keyValuePair.Value)
                {
                    listenID = keyValuePair.Key;
                    break;
                }
            }
            ListPool <KeyValuePair <int, int> > .Release(toRelease);

            agent.StartTalkSequence(listener, agent.ChaControl.fileParam.personality, listenID);
        }
        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);
        }
Beispiel #10
0
        public bool CanDelete()
        {
            if (this._kind != CraftPoint.CraftKind.Recycling || !Singleton <Manager.Map> .IsInstance() || !Singleton <Game> .IsInstance())
            {
                return(true);
            }
            WorldData worldData = Singleton <Game> .Instance.WorldData;

            AIProject.SaveData.Environment environment = worldData == null ? (AIProject.SaveData.Environment)null : worldData.Environment;
            if (environment == null)
            {
                return(true);
            }
            RecyclingData recyclingData = (RecyclingData)null;

            if (!environment.RecyclingDataTable.TryGetValue(this.RegisterID, out recyclingData) || recyclingData == null)
            {
                return(true);
            }
            recyclingData.DecidedItemList.RemoveAll((Predicate <StuffItem>)(x => x == null || x.Count <= 0));
            recyclingData.CreatedItemList.RemoveAll((Predicate <StuffItem>)(x => x == null || x.Count <= 0));
            if (recyclingData.DecidedItemList.IsNullOrEmpty <StuffItem>() && recyclingData.CreatedItemList.IsNullOrEmpty <StuffItem>())
            {
                return(true);
            }
            List <StuffItem> stuffItemList1 = ListPool <StuffItem> .Get();

            foreach (StuffItem decidedItem in recyclingData.DecidedItemList)
            {
                StuffItem itemInstance = CraftPoint.GetItemInstance();
                CraftPoint.CopyItem(decidedItem, itemInstance);
                stuffItemList1.AddItem(itemInstance);
            }
            foreach (StuffItem createdItem in recyclingData.CreatedItemList)
            {
                StuffItem itemInstance = CraftPoint.GetItemInstance();
                CraftPoint.CopyItem(createdItem, itemInstance);
                stuffItemList1.AddItem(itemInstance);
            }
            Manager.Map instance = Singleton <Manager.Map> .Instance;
            List <ValueTuple <int, List <StuffItem> > > inventoryList  = instance.GetInventoryList();
            List <ValueTuple <int, List <StuffItem> > > valueTupleList = ListPool <ValueTuple <int, List <StuffItem> > > .Get();

            using (List <ValueTuple <int, List <StuffItem> > > .Enumerator enumerator = inventoryList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ValueTuple <int, List <StuffItem> > current = enumerator.Current;
                    int num = (int)current.Item1;
                    List <StuffItem> source         = (List <StuffItem>)current.Item2;
                    List <StuffItem> stuffItemList2 = ListPool <StuffItem> .Get();

                    valueTupleList.Add(new ValueTuple <int, List <StuffItem> >(num, stuffItemList2));
                    if (!source.IsNullOrEmpty <StuffItem>())
                    {
                        foreach (StuffItem from in source)
                        {
                            StuffItem itemInstance = CraftPoint.GetItemInstance();
                            CraftPoint.CopyItem(from, itemInstance);
                            stuffItemList2.Add(itemInstance);
                        }
                    }
                }
            }
            using (List <ValueTuple <int, List <StuffItem> > > .Enumerator enumerator = valueTupleList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ValueTuple <int, List <StuffItem> > current = enumerator.Current;
                    int num = (int)current.Item1;
                    List <StuffItem> self = (List <StuffItem>)current.Item2;
                    for (int index = 0; index < stuffItemList1.Count; ++index)
                    {
                        StuffItem element = stuffItemList1.GetElement <StuffItem>(index);
                        if (element == null || element.Count <= 0)
                        {
                            stuffItemList1.RemoveAt(index);
                            --index;
                        }
                        else
                        {
                            StuffItem itemInstance = CraftPoint.GetItemInstance();
                            CraftPoint.CopyItem(element, itemInstance);
                            int possible = 0;
                            StuffItemExtensions.CanAddItem((IReadOnlyCollection <StuffItem>)self, num, itemInstance, out possible);
                            if (0 < possible)
                            {
                                possible = Mathf.Min(possible, itemInstance.Count);
                                self.AddItem(itemInstance, possible, num);
                            }
                            element.Count -= possible;
                            if (element.Count <= 0)
                            {
                                stuffItemList1.RemoveAt(index);
                                --index;
                            }
                        }
                    }
                }
            }
            stuffItemList1.RemoveAll((Predicate <StuffItem>)(x => x == null || x.Count <= 0));
            bool flag = stuffItemList1.IsNullOrEmpty <StuffItem>();

            if (flag)
            {
                using (List <ValueTuple <int, List <StuffItem> > > .Enumerator enumerator = inventoryList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ValueTuple <int, List <StuffItem> > current = enumerator.Current;
                        int slotMax = (int)current.Item1;
                        List <StuffItem> receiver = (List <StuffItem>)current.Item2;
                        instance.SendItemListToList(slotMax, recyclingData.DecidedItemList, receiver);
                        instance.SendItemListToList(slotMax, recyclingData.CreatedItemList, receiver);
                    }
                }
            }
            using (List <ValueTuple <int, List <StuffItem> > > .Enumerator enumerator = valueTupleList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ValueTuple <int, List <StuffItem> > current = enumerator.Current;
                    if (current.Item2 != null)
                    {
                        foreach (StuffItem stuffItem in (List <StuffItem>)current.Item2)
                        {
                            CraftPoint.ReturnItemInstance(stuffItem);
                        }
                        ListPool <StuffItem> .Release((List <StuffItem>) current.Item2);
                    }
                }
            }
            foreach (StuffItem stuffItem in stuffItemList1)
            {
                CraftPoint.ReturnItemInstance(stuffItem);
            }
            ListPool <StuffItem> .Release(stuffItemList1);

            instance.ReturnInventoryList(inventoryList);
            return(flag);
        }
Beispiel #11
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            this._agent = this.Agent;
            this._agent.RuntimeMotivationInPhoto = this._agent.AgentData.StatsTable[5];
            this._prevStateType   = this._agent.StateType;
            this._agent.StateType = AIProject.Definitions.State.Type.Immobility;
            this._poseIDList      = ListPool <int> .Get();

            NavMeshAgent navMeshAgent = this._agent.NavMeshAgent;

            navMeshAgent.set_isStopped(true);
            this._prevPriority = navMeshAgent.get_avoidancePriority();
            navMeshAgent.set_avoidancePriority(Singleton <Resources> .Instance.AgentProfile.AvoidancePriorityStationary);
            this._player          = Singleton <Manager.Map> .Instance.Player;
            this._playerCameraCon = this._player.CameraControl;
            this._prevShotType    = this._playerCameraCon.ShotType;
            this._isFadeOut       = false;
            this._poseStateTable  = (ReadOnlyDictionary <int, ValueTuple <PoseKeyPair, bool> >)null;
            this._poseInfo        = new ValueTuple <PoseKeyPair, bool>(new PoseKeyPair(), false);
            Dictionary <int, ValueTuple <PoseKeyPair, bool> > source;

            if (Singleton <Resources> .Instance.Animation.AgentGravurePoseTable.TryGetValue(this._agent.ChaControl.fileParam.personality, out source) && !source.IsNullOrEmpty <int, ValueTuple <PoseKeyPair, bool> >())
            {
                this._poseStateTable = new ReadOnlyDictionary <int, ValueTuple <PoseKeyPair, bool> >((IDictionary <int, ValueTuple <PoseKeyPair, bool> >)source);
                this._poseIDList.AddRange((IEnumerable <int>) this._poseStateTable.get_Keys());
                this._lastPoseID = this._poseIDList[Random.Range(0, this._poseIDList.Count)];
                this._poseStateTable.TryGetValue(this._lastPoseID, ref this._poseInfo);
            }
            this._poseOutAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseOutAnimAction, (Component)this._agent), 1), (System.Action <M0>)(_ =>
            {
                this._isFadeOut = true;
                this.PlayOutAnimation(this._poseInfo);
                this._isWait = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingOutAnimation);
            }));
            this._poseReplayAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseReplayAnimAction, (Component)this._agent), (System.Action <M0>)(_ =>
            {
                if (this._poseIDList.IsNullOrEmpty <int>())
                {
                    this._poseOutAnimAction.OnNext(Unit.get_Default());
                }
                else
                {
                    if (this._poseIDList.Count == 1)
                    {
                        this._agent.ClearItems();
                        this.PlayInAnimation(this._poseInfo);
                    }
                    else
                    {
                        List <int> toRelease = ListPool <int> .Get();
                        toRelease.AddRange((IEnumerable <int>) this._poseIDList);
                        toRelease.Remove(this._lastPoseID);
                        this._lastPoseID = toRelease[Random.Range(0, toRelease.Count)];
                        ListPool <int> .Release(toRelease);
                        this._poseStateTable.TryGetValue(this._lastPoseID, ref this._poseInfo);
                        this._agent.ClearItems();
                        this.PlayInAnimation(this._poseInfo);
                    }
                    this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingInAnimation);
                    this._onEndAction = (Subject <Unit>)null;
                }
            }));
            this._poseLoopEndAnimAction = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>) this._poseLoopEndAnimAction, (Component)this._agent), (System.Action <M0>)(_ =>
            {
                this.PlayOutAnimation(this._poseInfo);
                this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingOutAnimation);
                this._onEndAction = this._poseReplayAnimAction;
            }));
            this.PlayInAnimation(this._poseInfo);
            this._isWait      = (Func <AgentActor, bool>)(actor => actor.Animation.PlayingInAnimation);
            this._onEndAction = (Subject <Unit>)null;
        }
Beispiel #12
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            this.Agent.StopNavMeshAgent();
            this.Agent.AnimalFovAngleOffsetY = 0.0f;
            int       id         = this.Agent.AgentData.SickState.ID;
            PlayState playState1 = new PlayState();
            Dictionary <int, Dictionary <int, PlayState> > agentActionAnimTable = Singleton <Resources> .Instance.Animation.AgentActionAnimTable;

            AgentProfile.PoseIDCollection poseIdTable = Singleton <Resources> .Instance.AgentProfile.PoseIDTable;
            this.isSick = -1 < id;
            this.isCold = false;
            PlayState playState2;

            if (this.isSick)
            {
                if (id == 0)
                {
                    this.isCold = true;
                    PoseKeyPair coughId = poseIdTable.CoughID;
                    playState2 = agentActionAnimTable[coughId.postureID][coughId.poseID];
                }
                else
                {
                    PoseKeyPair[] normalIdList = poseIdTable.NormalIDList;
                    PoseKeyPair   element      = normalIdList.GetElement <PoseKeyPair>(Random.Range(0, normalIdList.Length));
                    playState2 = agentActionAnimTable[element.postureID][element.poseID];
                }
            }
            else
            {
                List <PoseKeyPair> poseKeyPairList = ListPool <PoseKeyPair> .Get();

                poseKeyPairList.AddRange((IEnumerable <PoseKeyPair>)poseIdTable.NormalIDList);
                switch (Singleton <Manager.Map> .Instance.Simulator.Weather)
                {
                case Weather.Clear:
                case Weather.Cloud1:
                    poseKeyPairList.Add(poseIdTable.ClearPoseID);
                    break;
                }
                PoseKeyPair element = poseKeyPairList.GetElement <PoseKeyPair>(Random.Range(0, poseKeyPairList.Count));
                ListPool <PoseKeyPair> .Release(poseKeyPairList);

                playState2 = agentActionAnimTable[element.postureID][element.poseID];
            }
            this.layer        = playState2.Layer;
            this.inEnableFade = playState2.MainStateInfo.InStateInfo.EnableFade;
            this.inFadeTime   = playState2.MainStateInfo.InStateInfo.FadeSecond;
            this.Agent.Animation.OnceActionStates.Clear();
            if (!playState2.MainStateInfo.InStateInfo.StateInfos.IsNullOrEmpty <PlayState.Info>())
            {
                foreach (PlayState.Info stateInfo in playState2.MainStateInfo.InStateInfo.StateInfos)
                {
                    this.Agent.Animation.OnceActionStates.Add(stateInfo);
                }
            }
            this.Agent.Animation.OutStates.Clear();
            if (!playState2.MainStateInfo.OutStateInfo.StateInfos.IsNullOrEmpty <PlayState.Info>())
            {
                foreach (PlayState.Info stateInfo in playState2.MainStateInfo.OutStateInfo.StateInfos)
                {
                    this.Agent.Animation.OutStates.Enqueue(stateInfo);
                }
            }
            this.duration   = Singleton <Resources> .Instance.AgentProfile.StandDurationMinMax.RandomValue;
            this.onEndEvent = new Subject <Unit>();
            ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>((IObservable <M0>) this.onEndEvent, 1), (Action <M0>)(_ => this.Agent.Animation.PlayOutAnimation(this.outEnableFade, this.outFadeTime, this.layer)));
            this.onStartEvent = (Action)(() => this.Agent.Animation.PlayOnceActionAnimation(this.inEnableFade, this.inFadeTime, this.layer));
        }
        public void RefreshTemperatureValue()
        {
            if (!Singleton <Resources> .IsInstance())
            {
                return;
            }
            Dictionary <int, Dictionary <int, Dictionary <int, List <ValueTuple <int, int> > > > > tempRangeTable = Singleton <Resources> .Instance.Map.TempRangeTable;

            if (tempRangeTable.IsNullOrEmpty <int, Dictionary <int, Dictionary <int, List <ValueTuple <int, int> > > > >())
            {
                return;
            }
            Dictionary <int, Dictionary <int, List <ValueTuple <int, int> > > > source1;

            if (!tempRangeTable.TryGetValue(this.MapID, out source1) || source1.IsNullOrEmpty <int, Dictionary <int, List <ValueTuple <int, int> > > >())
            {
                if (this.MapID != 0)
                {
                    tempRangeTable.TryGetValue(0, out source1);
                }
                if (source1.IsNullOrEmpty <int, Dictionary <int, List <ValueTuple <int, int> > > >())
                {
                    return;
                }
            }
            int key;
            Dictionary <int, List <ValueTuple <int, int> > > source2;
            List <ValueTuple <int, int> > source3;

            if (!AIProject.Definitions.Environment.TimeZoneIDTable.TryGetValue(this._tempTimeZone, ref key) || !source1.TryGetValue(key, out source2) || (source2.IsNullOrEmpty <int, List <ValueTuple <int, int> > >() || !source2.TryGetValue((int)this._weather, out source3)) || source3.IsNullOrEmpty <ValueTuple <int, int> >())
            {
                return;
            }
            List <ValueTuple <int, int> > toRelease = ListPool <ValueTuple <int, int> > .Get();

            toRelease.AddRange((IEnumerable <ValueTuple <int, int> >)source3);
            int num1 = 0;

            using (List <ValueTuple <int, int> > .Enumerator enumerator = toRelease.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ValueTuple <int, int> current = enumerator.Current;
                    num1 += (int)current.Item2;
                }
            }
            int num2 = Random.Range(0, num1);

            while (0 < toRelease.Count)
            {
                ValueTuple <int, int> valueTuple = ((IList <ValueTuple <int, int> >)toRelease).PopFront <ValueTuple <int, int> >();
                if (num2 < valueTuple.Item2)
                {
                    this.TemperatureValue = (float)valueTuple.Item1;
                    ListPool <ValueTuple <int, int> > .Release(toRelease);

                    return;
                }
                num2 -= (int)valueTuple.Item2;
            }
            ListPool <ValueTuple <int, int> > .Release(toRelease);
        }
Beispiel #14
0
        public void Show()
        {
            if (!((UIBehaviour)this).IsActive() || !this.IsInteractable() || Object.op_Inequality((Object)this._dropdown, (Object)null) && this._dropdown.get_activeSelf())
            {
                return;
            }
            if (!this._validTemplate)
            {
                this.SetupTemplate();
                if (!this._validTemplate)
                {
                    return;
                }
            }
            List <Canvas> toRelease = ListPool <Canvas> .Get();

            ((Component)this).GetComponentsInParent <Canvas>(false, (List <M0>)toRelease);
            if (toRelease.Count <= 0)
            {
                return;
            }
            Canvas rootCanvas = toRelease[0];

            ListPool <Canvas> .Release(toRelease);

            ((Component)this._template).get_gameObject().SetActive(true);
            if (Object.op_Equality((Object)this._dropdown, (Object)null))
            {
                this._dropdown = (GameObject)Object.Instantiate <GameObject>((M0)((Component)this._template).get_gameObject());
                ((Object)this._dropdown).set_name("Dropdown List");
                ((Component)this._dropdown.GetComponentInChildren <OptimizedDropdown.DropdownItem>()).get_gameObject().SetActive(false);
                this._scrollRect = (ScrollRect)this._dropdown.GetComponent <ScrollRect>();
            }
            this._dropdown.SetActive(true);
            RectTransform transform1 = this._dropdown.get_transform() as RectTransform;

            ((Transform)transform1).SetParent(((Component)this._template).get_transform().get_parent(), false);
            OptimizedDropdown.DropdownItem componentInChildren = (OptimizedDropdown.DropdownItem)((Component)this._template).GetComponentInChildren <OptimizedDropdown.DropdownItem>();
            GameObject    gameObject = ((Component)((Component)this._dropdown.GetComponentInChildren <OptimizedDropdown.DropdownItem>(true)).get_transform().get_parent()).get_gameObject();
            RectTransform transform2 = gameObject.get_transform() as RectTransform;

            ((Component)componentInChildren.RectTransform).get_gameObject().SetActive(true);
            if (!this._rect.HasValue)
            {
                this._rect = new Rect?(transform2.get_rect());
            }
            Rect    rect1     = componentInChildren.RectTransform.get_rect();
            Vector2 min1      = ((Rect) ref rect1).get_min();
            Rect    rect2     = this._rect.Value;
            Vector2 min2      = ((Rect) ref rect2).get_min();
            Vector2 vector2_1 = Vector2.op_Addition(Vector2.op_Subtraction(min1, min2), Vector2.op_Implicit(((Transform)componentInChildren.RectTransform).get_localPosition()));
            Vector2 max1      = ((Rect) ref rect1).get_max();
            Rect    rect3     = this._rect.Value;
            Vector2 max2      = ((Rect) ref rect3).get_max();
            Vector2 vector2_2 = Vector2.op_Addition(Vector2.op_Subtraction(max1, max2), Vector2.op_Implicit(((Transform)componentInChildren.RectTransform).get_localPosition()));
            Vector2 size      = ((Rect) ref rect1).get_size();

            this._items.Clear();
            Toggle toggle = (Toggle)null;

            for (int index = 0; index < this.Options.Count; ++index)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                OptimizedDropdown.\u003CShow\u003Ec__AnonStorey0 showCAnonStorey0 = new OptimizedDropdown.\u003CShow\u003Ec__AnonStorey0();
                // ISSUE: reference to a compiler-generated field
                showCAnonStorey0.\u0024this = this;
                // ISSUE: reference to a compiler-generated field
                showCAnonStorey0.index = index;
                OptimizedDropdown.DropdownItem dropdownItem = this.AddItem(this.Options[index], gameObject.get_transform(), this._items);
                if (Object.op_Inequality((Object)dropdownItem, (Object)null))
                {
                    dropdownItem.Toggle.set_isOn(this.Value == index);
                    // ISSUE: method pointer
                    ((UnityEvent <bool>)dropdownItem.Toggle.onValueChanged).AddListener(new UnityAction <bool>((object)showCAnonStorey0, __methodptr(\u003C\u003Em__0)));
                    if (Object.op_Inequality((Object)toggle, (Object)null))
                    {
                        Navigation navigation1 = ((Selectable)toggle).get_navigation();
                        Navigation navigation2 = ((Selectable)dropdownItem.Toggle).get_navigation();
                        ((Navigation) ref navigation1).set_mode((Navigation.Mode) 4);
                        ((Navigation) ref navigation2).set_mode((Navigation.Mode) 4);
                        ((Navigation) ref navigation1).set_selectOnDown((Selectable)dropdownItem.Toggle);
                        ((Navigation) ref navigation1).set_selectOnRight((Selectable)dropdownItem.Toggle);
                        ((Navigation) ref navigation2).set_selectOnLeft((Selectable)toggle);
                        ((Navigation) ref navigation2).set_selectOnUp((Selectable)toggle);
                        ((Selectable)toggle).set_navigation(navigation1);
                        ((Selectable)dropdownItem.Toggle).set_navigation(navigation2);
                    }
                    toggle = dropdownItem.Toggle;
                }
            }
            Vector2 sizeDelta = transform2.get_sizeDelta();

            sizeDelta.y = (__Null)(size.y * (double)this._items.Count + vector2_1.y - vector2_2.y);
            transform2.set_sizeDelta(sizeDelta);
            Rect   rect4   = transform1.get_rect();
            double height1 = (double)((Rect) ref rect4).get_height();
            Rect   rect5   = transform2.get_rect();
            double height2 = (double)((Rect) ref rect5).get_height();
            float  num1    = (float)(height1 - height2);

            if ((double)num1 > 0.0)
            {
                transform1.set_sizeDelta(new Vector2((float)transform1.get_sizeDelta().x, (float)transform1.get_sizeDelta().y - num1));
            }
            Vector3[] vector3Array = new Vector3[4];
            transform1.GetWorldCorners(vector3Array);
            RectTransform transform3 = ((Component)rootCanvas).get_transform() as RectTransform;
            Rect          rect6      = transform3.get_rect();

            for (int index1 = 0; index1 < 2; ++index1)
            {
                bool flag = false;
                for (int index2 = 0; index2 < 4; ++index2)
                {
                    Vector3 vector3 = ((Transform)transform3).InverseTransformPoint(vector3Array[index2]);
                    double  num2    = (double)((Vector3) ref vector3).get_Item(index1);
                    Vector2 min3    = ((Rect) ref rect6).get_min();
                    double  num3    = (double)((Vector2) ref min3).get_Item(index1);
                    int     num4;
                    if (num2 >= num3)
                    {
                        double  num5 = (double)((Vector3) ref vector3).get_Item(index1);
                        Vector2 max3 = ((Rect) ref rect6).get_max();
                        double  num6 = (double)((Vector2) ref max3).get_Item(index1);
                        num4 = num5 > num6 ? 1 : 0;
                    }
                    else
                    {
                        num4 = 1;
                    }
                    if (num4 != 0)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    RectTransformUtility.FlipLayoutOnAxis(transform1, index1, false, false);
                }
            }
            for (int index = 0; index < this._items.Count; ++index)
            {
                RectTransform rectTransform = this._items[index].RectTransform;
                rectTransform.set_anchorMin(new Vector2((float)rectTransform.get_anchorMin().x, 0.0f));
                rectTransform.set_anchorMax(new Vector2((float)rectTransform.get_anchorMax().x, 0.0f));
                rectTransform.set_anchoredPosition(new Vector2((float)rectTransform.get_anchoredPosition().x, (float)(vector2_1.y + size.y * (double)(this._items.Count - 1 - index) + size.y * rectTransform.get_pivot().y)));
                rectTransform.set_sizeDelta(new Vector2((float)rectTransform.get_sizeDelta().x, (float)size.y));
            }
            this.AlphaFadeList(0.15f, 0.0f, 1f, (Action)(() => {}));
            ((Component)this._template).get_gameObject().SetActive(false);
            this._blocker = this.CreateBlocker(rootCanvas);
            if (!this._focusedSelectedItem)
            {
                return;
            }
            RectTransform transform4 = ((Component)((IEnumerable <Toggle>)((Component)this._scrollRect.get_content()).GetComponentsInChildren <Toggle>()).FirstOrDefault <Toggle>((Func <Toggle, bool>)(x => x.get_isOn()))).get_transform() as RectTransform;
            Rect          rect7      = this._scrollRect.get_content().get_rect();
            double        height3    = (double)((Rect) ref rect7).get_height();
            Rect          rect8      = this._scrollRect.get_viewport().get_rect();
            double        height4    = (double)((Rect) ref rect8).get_height();
            float         num7       = (float)(height3 - height4);
            // ISSUE: variable of the null type
            __Null y      = transform4.get_anchoredPosition().y;
            Rect   rect9  = transform4.get_rect();
            double num8   = (double)((Rect) ref rect9).get_height() / 2.0;
            double num9   = y - num8;
            Rect   rect10 = this._scrollRect.get_viewport().get_rect();
            double num10  = (double)((Rect) ref rect10).get_height() / 2.0;
            float  num11  = (float)(num9 - num10);

            this._scrollRect.get_verticalScrollbar().set_value(Mathf.InverseLerp(0.0f, num7, Mathf.Clamp(num11, 0.0f, num7)));
        }
        public void LoadFromExcelData(ExcelData data)
        {
            if (Object.op_Equality((Object)data, (Object)null) || data.MaxCell <= 1)
            {
                return;
            }
            List <ReverbSetting.ReverbInfo> toRelease1 = ListPool <ReverbSetting.ReverbInfo> .Get();

            for (int index1 = 1; index1 < data.MaxCell; ++index1)
            {
                List <string> list = data.list[index1].list;
                if (!list.IsNullOrEmpty <string>())
                {
                    int           num1    = 0;
                    List <string> source1 = list;
                    int           index2  = num1;
                    int           num2    = index2 + 1;
                    string        s       = source1.GetElement <string>(index2) ?? string.Empty;
                    if (!(s == "end"))
                    {
                        float result1;
                        if (float.TryParse(s, out result1))
                        {
                            List <string> source2 = list;
                            int           index3  = num2;
                            int           num3    = index3 + 1;
                            float         result2;
                            if (float.TryParse(source2.GetElement <string>(index3) ?? string.Empty, out result2))
                            {
                                List <string> source3 = list;
                                int           index4  = num3;
                                int           num4    = index4 + 1;
                                int           result3;
                                if (int.TryParse(source3.GetElement <string>(index4) ?? string.Empty, out result3))
                                {
                                    if (result3 < 0 || 27 < result3)
                                    {
                                        result3 = 1;
                                    }
                                    AudioReverbPreset audioReverbPreset = (AudioReverbPreset)result3;
                                    if (audioReverbPreset != 27)
                                    {
                                        ReverbSetting.ReverbInfo reverbInfo = new ReverbSetting.ReverbInfo()
                                        {
                                            MinDistance  = result1,
                                            MaxDistance  = result2,
                                            ReverbPreset = audioReverbPreset
                                        };
                                        toRelease1.Add(reverbInfo);
                                    }
                                    else
                                    {
                                        List <string> source4 = list;
                                        int           index5  = num4;
                                        int           num5    = index5 + 1;
                                        int           result4;
                                        if (!int.TryParse(source4.GetElement <string>(index5) ?? string.Empty, out result4))
                                        {
                                            result4 = -1000;
                                        }
                                        List <string> source5 = list;
                                        int           index6  = num5;
                                        int           num6    = index6 + 1;
                                        int           result5;
                                        if (!int.TryParse(source5.GetElement <string>(index6) ?? string.Empty, out result5))
                                        {
                                            result5 = -100;
                                        }
                                        List <string> source6 = list;
                                        int           index7  = num6;
                                        int           num7    = index7 + 1;
                                        int           result6;
                                        if (!int.TryParse(source6.GetElement <string>(index7) ?? string.Empty, out result6))
                                        {
                                            result6 = 0;
                                        }
                                        List <string> source7 = list;
                                        int           index8  = num7;
                                        int           num8    = index8 + 1;
                                        float         result7;
                                        if (!float.TryParse(source7.GetElement <string>(index8) ?? string.Empty, out result7))
                                        {
                                            result7 = 1.49f;
                                        }
                                        List <string> source8 = list;
                                        int           index9  = num8;
                                        int           num9    = index9 + 1;
                                        float         result8;
                                        if (!float.TryParse(source8.GetElement <string>(index9) ?? string.Empty, out result8))
                                        {
                                            result8 = 0.83f;
                                        }
                                        List <string> source9 = list;
                                        int           index10 = num9;
                                        int           num10   = index10 + 1;
                                        int           result9;
                                        if (!int.TryParse(source9.GetElement <string>(index10) ?? string.Empty, out result9))
                                        {
                                            result9 = -2602;
                                        }
                                        List <string> source10 = list;
                                        int           index11  = num10;
                                        int           num11    = index11 + 1;
                                        float         result10;
                                        if (!float.TryParse(source10.GetElement <string>(index11) ?? string.Empty, out result10))
                                        {
                                            result10 = 0.007f;
                                        }
                                        List <string> source11 = list;
                                        int           index12  = num11;
                                        int           num12    = index12 + 1;
                                        int           result11;
                                        if (!int.TryParse(source11.GetElement <string>(index12) ?? string.Empty, out result11))
                                        {
                                            result11 = 200;
                                        }
                                        List <string> source12 = list;
                                        int           index13  = num12;
                                        int           num13    = index13 + 1;
                                        float         result12;
                                        if (!float.TryParse(source12.GetElement <string>(index13) ?? string.Empty, out result12))
                                        {
                                            result12 = 11f / 1000f;
                                        }
                                        List <string> source13 = list;
                                        int           index14  = num13;
                                        int           num14    = index14 + 1;
                                        int           result13;
                                        if (!int.TryParse(source13.GetElement <string>(index14) ?? string.Empty, out result13))
                                        {
                                            result13 = 5000;
                                        }
                                        List <string> source14 = list;
                                        int           index15  = num14;
                                        int           num15    = index15 + 1;
                                        int           result14;
                                        if (!int.TryParse(source14.GetElement <string>(index15) ?? string.Empty, out result14))
                                        {
                                            result14 = 250;
                                        }
                                        List <string> source15 = list;
                                        int           index16  = num15;
                                        int           num16    = index16 + 1;
                                        float         result15;
                                        if (!float.TryParse(source15.GetElement <string>(index16) ?? string.Empty, out result15))
                                        {
                                            result15 = 100f;
                                        }
                                        List <string> source16 = list;
                                        int           index17  = num16;
                                        int           num17    = index17 + 1;
                                        float         result16;
                                        if (!float.TryParse(source16.GetElement <string>(index17) ?? string.Empty, out result16))
                                        {
                                            result16 = 100f;
                                        }
                                        ReverbSetting.ReverbInfo reverbInfo = new ReverbSetting.ReverbInfo()
                                        {
                                            MinDistance      = result1,
                                            MaxDistance      = result2,
                                            ReverbPreset     = audioReverbPreset,
                                            Room             = result4,
                                            RoomHF           = result5,
                                            RoomLF           = result6,
                                            DecayTime        = result7,
                                            DecayHFRatio     = result8,
                                            Reflections      = result9,
                                            ReflectionsDelay = result10,
                                            Reverb           = result11,
                                            ReverbDelay      = result12,
                                            HFReference      = result13,
                                            LFReference      = result14,
                                            Diffusion        = result15,
                                            Density          = result16
                                        };
                                        toRelease1.Add(reverbInfo);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            List <AudioReverbZone> toRelease2 = ListPool <AudioReverbZone> .Get();

            AudioReverbZone[] componentsInChildren = (AudioReverbZone[])((Component)this).GetComponentsInChildren <AudioReverbZone>(true);
            toRelease2.AddRange((IEnumerable <AudioReverbZone>)componentsInChildren);
            int num   = toRelease1.Count - toRelease2.Count;
            int count = toRelease2.Count;

            for (int index = 0; index < num; ++index)
            {
                Transform transform = new GameObject(string.Format("Reverb Zone {0:00}", (object)count++)).get_transform();
                transform.SetParent(((Component)this).get_transform(), false);
                toRelease2.Add(((Component)transform).GetOrAddComponent <AudioReverbZone>());
            }
            for (int index = 0; index < toRelease1.Count; ++index)
            {
                AudioReverbZone          audioReverbZone = toRelease2[index];
                ReverbSetting.ReverbInfo reverbInfo      = toRelease1[index];
                audioReverbZone.set_minDistance(reverbInfo.MinDistance);
                audioReverbZone.set_maxDistance(reverbInfo.MaxDistance);
                audioReverbZone.set_reverbPreset(reverbInfo.ReverbPreset);
                if (reverbInfo.ReverbPreset == 27)
                {
                    audioReverbZone.set_room(reverbInfo.Room);
                    audioReverbZone.set_roomHF(reverbInfo.RoomHF);
                    audioReverbZone.set_roomLF(reverbInfo.RoomLF);
                    audioReverbZone.set_decayTime(reverbInfo.DecayTime);
                    audioReverbZone.set_decayHFRatio(reverbInfo.DecayHFRatio);
                    audioReverbZone.set_reflections(reverbInfo.Reflections);
                    audioReverbZone.set_reflectionsDelay(reverbInfo.ReflectionsDelay);
                    audioReverbZone.set_reverb(reverbInfo.Reverb);
                    audioReverbZone.set_reverbDelay(reverbInfo.ReverbDelay);
                    audioReverbZone.set_HFReference((float)reverbInfo.HFReference);
                    audioReverbZone.set_LFReference((float)reverbInfo.LFReference);
                    audioReverbZone.set_diffusion(reverbInfo.Diffusion);
                    audioReverbZone.set_density(reverbInfo.Density);
                }
            }
            ListPool <AudioReverbZone> .Release(toRelease2);

            ListPool <ReverbSetting.ReverbInfo> .Release(toRelease1);
        }
Beispiel #16
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;
        }
        private void LoadTimeRelationObjects()
        {
            if (!Singleton <Manager.Map> .IsInstance() || !Singleton <Resources> .IsInstance())
            {
                return;
            }
            Resources instance1 = Singleton <Resources> .Instance;

            Manager.Map instance2 = Singleton <Manager.Map> .Instance;
            string      str1      = "_EmissionColor";
            Dictionary <int, Dictionary <int, Dictionary <bool, Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> > > > relationObjectTable = instance2.TimeRelationObjectTable;
            Dictionary <int, Dictionary <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > > objectStateTable = instance1.Map.TimeRelationObjectStateTable;

            relationObjectTable.Clear();
            if (objectStateTable.IsNullOrEmpty <int, Dictionary <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > >())
            {
                return;
            }
            using (Dictionary <int, Dictionary <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > > .Enumerator enumerator1 = objectStateTable.GetEnumerator())
            {
                while (enumerator1.MoveNext())
                {
                    KeyValuePair <int, Dictionary <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > > current1 = enumerator1.Current;
                    if (!current1.Value.IsNullOrEmpty <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > >())
                    {
                        int key1 = current1.Key;
                        using (Dictionary <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > .Enumerator enumerator2 = current1.Value.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                KeyValuePair <int, Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > > current2 = enumerator2.Current;
                                if (!current2.Value.IsNullOrEmpty <bool, Dictionary <int, List <ValueTuple <string, float> > > >())
                                {
                                    int key2 = current2.Key;
                                    using (Dictionary <bool, Dictionary <int, List <ValueTuple <string, float> > > > .Enumerator enumerator3 = current2.Value.GetEnumerator())
                                    {
                                        while (enumerator3.MoveNext())
                                        {
                                            KeyValuePair <bool, Dictionary <int, List <ValueTuple <string, float> > > > current3 = enumerator3.Current;
                                            if (!current3.Value.IsNullOrEmpty <int, List <ValueTuple <string, float> > >())
                                            {
                                                bool key3 = current3.Key;
                                                using (Dictionary <int, List <ValueTuple <string, float> > > .Enumerator enumerator4 = current3.Value.GetEnumerator())
                                                {
                                                    while (enumerator4.MoveNext())
                                                    {
                                                        KeyValuePair <int, List <ValueTuple <string, float> > > current4 = enumerator4.Current;
                                                        if (!current4.Value.IsNullOrEmpty <ValueTuple <string, float> >())
                                                        {
                                                            int key4 = current4.Key;
                                                            ValueTuple <GameObject, Material, float, Color>[] valueTupleArray = (ValueTuple <GameObject, Material, float, Color>[])null;
                                                            switch (key2)
                                                            {
                                                            case 0:
                                                                List <GameObject> gameObjectList = ListPool <GameObject> .Get();

                                                                using (List <ValueTuple <string, float> > .Enumerator enumerator5 = current4.Value.GetEnumerator())
                                                                {
                                                                    while (enumerator5.MoveNext())
                                                                    {
                                                                        string str2 = (string)enumerator5.Current.Item1;
                                                                        if (!str2.IsNullOrEmpty())
                                                                        {
                                                                            GameObject loop = ((Component)this).get_transform().FindLoop(str2);
                                                                            if (!Object.op_Equality((Object)loop, (Object)null))
                                                                            {
                                                                                gameObjectList.Add(loop);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                if (!gameObjectList.IsNullOrEmpty <GameObject>())
                                                                {
                                                                    valueTupleArray = new ValueTuple <GameObject, Material, float, Color> [gameObjectList.Count];
                                                                    for (int index = 0; index < valueTupleArray.Length; ++index)
                                                                    {
                                                                        valueTupleArray[index] = new ValueTuple <GameObject, Material, float, Color>(gameObjectList[index], (Material)null, 0.0f, Color.get_white());
                                                                    }
                                                                }
                                                                ListPool <GameObject> .Release(gameObjectList);

                                                                break;

                                                            case 1:
                                                                List <ValueTuple <GameObject, Material, float, Color> > valueTupleList = ListPool <ValueTuple <GameObject, Material, float, Color> > .Get();

                                                                using (List <ValueTuple <string, float> > .Enumerator enumerator5 = current4.Value.GetEnumerator())
                                                                {
                                                                    while (enumerator5.MoveNext())
                                                                    {
                                                                        ValueTuple <string, float> current5 = enumerator5.Current;
                                                                        string str2 = (string)current5.Item1;
                                                                        if (!str2.IsNullOrEmpty())
                                                                        {
                                                                            GameObject loop = ((Component)this).get_transform().FindLoop(str2);
                                                                            if (!Object.op_Equality((Object)loop, (Object)null))
                                                                            {
                                                                                Renderer componentInChildren = (Renderer)loop.GetComponentInChildren <Renderer>(true);
                                                                                if (!Object.op_Equality((Object)componentInChildren?.get_material()?.get_shader(), (Object)null))
                                                                                {
                                                                                    Color color = Color.get_white();
                                                                                    if (componentInChildren.get_material().HasProperty(str1))
                                                                                    {
                                                                                        color = componentInChildren.get_material().GetColor(str1);
                                                                                        if (1.0 < color.r)
                                                                                        {
                                                                                            color.r = (__Null)(double)Mathf.Repeat((float)color.r, 1f);
                                                                                        }
                                                                                        if (1.0 < color.g)
                                                                                        {
                                                                                            color.g = (__Null)(double)Mathf.Repeat((float)color.g, 1f);
                                                                                        }
                                                                                        if (1.0 < color.b)
                                                                                        {
                                                                                            color.b = (__Null)(double)Mathf.Repeat((float)color.b, 1f);
                                                                                        }
                                                                                        if (1.0 < color.a)
                                                                                        {
                                                                                            color.a = (__Null)(double)Mathf.Repeat((float)color.a, 1f);
                                                                                        }
                                                                                    }
                                                                                    valueTupleList.Add(new ValueTuple <GameObject, Material, float, Color>(loop, componentInChildren.get_material(), (float)current5.Item2, color));
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                if (!valueTupleList.IsNullOrEmpty <ValueTuple <GameObject, Material, float, Color> >())
                                                                {
                                                                    valueTupleArray = new ValueTuple <GameObject, Material, float, Color> [valueTupleList.Count];
                                                                    for (int index = 0; index < valueTupleArray.Length; ++index)
                                                                    {
                                                                        valueTupleArray[index] = new ValueTuple <GameObject, Material, float, Color>((GameObject)valueTupleList[index].Item1, (Material)valueTupleList[index].Item2, (float)valueTupleList[index].Item3, (Color)valueTupleList[index].Item4);
                                                                    }
                                                                }
                                                                ListPool <ValueTuple <GameObject, Material, float, Color> > .Release(valueTupleList);

                                                                break;
                                                            }
                                                            if (valueTupleArray == null)
                                                            {
                                                                valueTupleArray = new ValueTuple <GameObject, Material, float, Color> [0];
                                                            }
                                                            Dictionary <int, Dictionary <bool, Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> > > dictionary1;
                                                            if (!relationObjectTable.TryGetValue(key1, out dictionary1))
                                                            {
                                                                relationObjectTable[key1] = dictionary1 = new Dictionary <int, Dictionary <bool, Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> > >();
                                                            }
                                                            Dictionary <bool, Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> > dictionary2;
                                                            if (!dictionary1.TryGetValue(key2, out dictionary2))
                                                            {
                                                                dictionary1[key2] = dictionary2 = new Dictionary <bool, Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> >();
                                                            }
                                                            Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]> dictionary3;
                                                            if (!dictionary2.TryGetValue(key3, out dictionary3))
                                                            {
                                                                dictionary2[key3] = dictionary3 = new Dictionary <int, ValueTuple <GameObject, Material, float, Color>[]>();
                                                            }
                                                            dictionary3[key4] = valueTupleArray;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            instance2.RefreshActiveTimeRelationObjects();
        }
Beispiel #18
0
        public virtual void OnStart()
        {
            AgentActor agent = this.Agent;

            agent.EventKey = EventType.Cook;
            Resources instance = Singleton <Resources> .Instance;
            Dictionary <int, Dictionary <int, Dictionary <int, FoodParameterPacket> > > foodParameterTable = instance.GameInfo.FoodParameterTable;
            List <StuffItem> itemListInPantry = Singleton <Game> .Instance.Environment.ItemListInPantry;
            List <StuffItem> stuffItemList    = ListPool <StuffItem> .Get();

            foreach (StuffItem stuffItem in itemListInPantry)
            {
                Dictionary <int, Dictionary <int, FoodParameterPacket> > dictionary;
                if (foodParameterTable.TryGetValue(stuffItem.CategoryID, out dictionary) && dictionary.TryGetValue(stuffItem.ID, out Dictionary <int, FoodParameterPacket> _))
                {
                    this._existsFoods = true;
                    stuffItemList.Add(stuffItem);
                }
            }
            if (!this._existsFoods)
            {
                ListPool <StuffItem> .Release(stuffItemList);
            }
            else
            {
                StuffItem element = stuffItemList.GetElement <StuffItem>(Random.Range(0, stuffItemList.Count));
                ListPool <StuffItem> .Release(stuffItemList);

                if (element == null)
                {
                    this._existsFoods = false;
                }
                else
                {
                    agent.AgentData.CarryingItem = new StuffItem(element.CategoryID, element.ID, 1);
                    agent.CurrentPoint           = agent.TargetInSightActionPoint;
                    agent.SetActiveOnEquipedItem(false);
                    agent.ChaControl.setAllLayerWeight(0.0f);
                    agent.ElectNextPoint();
                    agent.CurrentPoint.SetActiveMapItemObjs(false);
                    PoseKeyPair snitchFoodId = instance.AgentProfile.PoseIDTable.SnitchFoodID;
                    agent.ActionID = snitchFoodId.postureID;
                    agent.PoseID   = snitchFoodId.poseID;
                    Transform t = ((Component)agent.CurrentPoint).get_transform().FindLoop(instance.DefinePack.MapDefines.StealPivotName)?.get_transform() ?? ((Component)agent.CurrentPoint).get_transform();
                    agent.Animation.RecoveryPoint = (Transform)null;
                    PlayState     info     = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[snitchFoodId.postureID][snitchFoodId.poseID];
                    ActorAnimInfo animInfo = agent.Animation.LoadActionState(snitchFoodId.postureID, snitchFoodId.poseID, info);
                    agent.LoadActionFlag(snitchFoodId.postureID, snitchFoodId.poseID);
                    agent.DeactivateNavMeshAgent();
                    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>)(_ => 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, "盗み食い", animInfo.loopMinTime, animInfo.loopMaxTime, animInfo.hasAction, false);
                }
            }
        }
Beispiel #19
0
        protected override void Start()
        {
            CommonDefine.CommonIconGroup icon       = Singleton <Resources> .Instance.CommonDefine.Icon;
            DefinePack.MapGroup          mapDefines = Singleton <Resources> .Instance.DefinePack.MapDefines;
            if (Object.op_Equality((Object)this._commandBasePoint, (Object)null))
            {
                this._commandBasePoint = ((Component)this).get_transform().FindLoop(Singleton <Resources> .Instance.DefinePack.MapDefines.CommandTargetName)?.get_transform() ?? ((Component)this).get_transform();
            }
            base.Start();
            this.NavMeshPoints.Add(((Component)this).get_transform());
            List <GameObject> gameObjectList = ListPool <GameObject> .Get();

            ((Component)this).get_transform().FindLoopPrefix(gameObjectList, mapDefines.NavMeshTargetName);
            if (!gameObjectList.IsNullOrEmpty <GameObject>())
            {
                using (List <GameObject> .Enumerator enumerator = gameObjectList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        this.NavMeshPoints.Add(enumerator.Current.get_transform());
                    }
                }
            }
            ListPool <GameObject> .Release(gameObjectList);

            Sprite sprite1;

            Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(Singleton <Resources> .Instance.CommonDefine.Icon.FarmIconID, out sprite1);

            Sprite sprite2;

            Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(Singleton <Resources> .Instance.CommonDefine.Icon.ChickenCoopIconID, out sprite2);

            Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(Singleton <Resources> .Instance.CommonDefine.Icon.WellIconID, out Sprite _);

            Transform transform = ((Component)this).get_transform().FindLoop(mapDefines.FarmPointLabelTargetName)?.get_transform() ?? ((Component)this).get_transform();

            if (this._farmKind == FarmPoint.FarmKind.Plant)
            {
                this._labels = new CommandLabel.CommandInfo[1]
                {
                    new CommandLabel.CommandInfo()
                    {
                        Text             = "畑",
                        Icon             = sprite1,
                        IsHold           = true,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = transform,
                        Condition        = (Func <PlayerActor, bool>)(x => this._farmKind == FarmPoint.FarmKind.Plant),
                        Event            = (Action)(() =>
                        {
                            MapUIContainer.SetCommandLabelAcception(CommandLabel.AcceptionState.None);
                            List <AIProject.SaveData.Environment.PlantInfo> plantInfoList1;
                            if (!Singleton <Game> .Instance.Environment.FarmlandTable.TryGetValue(this._id, out plantInfoList1))
                            {
                                List <AIProject.SaveData.Environment.PlantInfo> plantInfoList2 = new List <AIProject.SaveData.Environment.PlantInfo>();
                                Singleton <Game> .Instance.Environment.FarmlandTable[this._id] = plantInfoList2;
                                plantInfoList1 = plantInfoList2;
                                foreach (FarmSection harvestSection in this._harvestSections)
                                {
                                    plantInfoList1.Add((AIProject.SaveData.Environment.PlantInfo)null);
                                }
                            }
                            MapUIContainer.FarmlandUI.currentPlant = plantInfoList1;
                            MapUIContainer.SetActiveFarmlandUI(true);
                            Singleton <Manager.Map> .Instance.Player.Controller.ChangeState("Harvest");
                        })
                    }
                }
            }
            ;
            else if (this._farmKind == FarmPoint.FarmKind.ChickenCoop)
            {
                this._labels = new CommandLabel.CommandInfo[1]
                {
                    new CommandLabel.CommandInfo()
                    {
                        Text             = "鶏小屋",
                        Icon             = sprite2,
                        IsHold           = true,
                        TargetSpriteInfo = icon.ActionSpriteInfo,
                        Transform        = transform,
                        Condition        = (Func <PlayerActor, bool>)(x => this._farmKind == FarmPoint.FarmKind.ChickenCoop),
                        Event            = (Action)(() =>
                        {
                            PlayerActor playerActor = !Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player;
                            if (!Object.op_Inequality((Object)playerActor, (Object)null))
                            {
                                return;
                            }
                            playerActor.CurrentFarmPoint = this;
                            playerActor.PlayerController.ChangeState("ChickenCoopMenu");
                        })
                    }
                }
            }
            ;
            else if (this._farmKind != FarmPoint.FarmKind.Well)
            {
                ;
            }
        }