Пример #1
0
        protected override void Start()
        {
            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();
            CommonDefine.CommonIconGroup icon       = Singleton <Resources> .Instance.CommonDefine.Icon;
            DefinePack.MapGroup          mapDefines = Singleton <Resources> .Instance.DefinePack.MapDefines;
            string empty = string.Empty;
            int    key   = -1;
            string str;

            switch (this._kind)
            {
            case CraftPoint.CraftKind.Medicine:
                key = Singleton <Resources> .Instance.CommonDefine.Icon.MedicineCraftIconID;
                str = "薬台";
                break;

            case CraftPoint.CraftKind.Pet:
                key = Singleton <Resources> .Instance.CommonDefine.Icon.PetCraftIcon;
                str = "ペット合成装置";
                break;

            case CraftPoint.CraftKind.Recycling:
                key = Singleton <Resources> .Instance.CommonDefine.Icon.RecyclingCraftIcon;
                str = "リサイクル装置";
                break;

            default:
                str = "????";
                break;
            }
            Sprite sprite;

            Singleton <Resources> .Instance.itemIconTables.ActionIconTable.TryGetValue(key, out sprite);

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

            this._labels = new CommandLabel.CommandInfo[1]
            {
                new CommandLabel.CommandInfo()
                {
                    Text             = str,
                    Icon             = sprite,
                    IsHold           = true,
                    TargetSpriteInfo = icon.ActionSpriteInfo,
                    Transform        = transform,
                    Condition        = (Func <PlayerActor, bool>)null,
                    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.CurrentCraftPoint = this;
                        playerActor.PlayerController.ChangeState("Craft");
                    })
                }
            };
            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>())
            {
                return;
            }
            using (List <GameObject> .Enumerator enumerator = gameObjectList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    this.NavMeshPoints.Add(enumerator.Current.get_transform());
                }
            }
        }
Пример #2
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);
        }
Пример #3
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;
        }
        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);
        }
Пример #5
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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void CreateChicken()
        {
            if (this._farmKind != FarmPoint.FarmKind.ChickenCoop)
            {
                return;
            }
            if (this.ChickenList != null)
            {
                this.ChickenList.RemoveAll((Predicate <PetChicken>)(x => Object.op_Equality((Object)x, (Object)null)));
            }
            else
            {
                if (!Singleton <Game> .IsInstance() || !Singleton <AnimalManager> .IsInstance())
                {
                    return;
                }
                AIProject.SaveData.Environment environment = Singleton <Game> .Instance.Environment;
                if (environment == null)
                {
                    return;
                }
                this.ChickenList = ListPool <PetChicken> .Get();

                Dictionary <int, List <AIProject.SaveData.Environment.ChickenInfo> > chickenTable = environment.ChickenTable;
                if (chickenTable == null)
                {
                    return;
                }
                List <AIProject.SaveData.Environment.ChickenInfo> source1 = (List <AIProject.SaveData.Environment.ChickenInfo>)null;
                if (!chickenTable.TryGetValue(this.RegisterID, out source1) || source1.IsNullOrEmpty <AIProject.SaveData.Environment.ChickenInfo>())
                {
                    if (Singleton <Manager.Map> .IsInstance())
                    {
                        int mapId = Singleton <Manager.Map> .Instance.MapID;
                        int areaIdOnHousingArea = this.AreaIDOnHousingArea;
                        Dictionary <int, Dictionary <int, AIProject.SaveData.AnimalData> > source2;
                        Dictionary <int, AIProject.SaveData.AnimalData> source3;
                        if (!environment.HousingChickenDataTable.TryGetValue(mapId, out source2) || source2.IsNullOrEmpty <int, Dictionary <int, AIProject.SaveData.AnimalData> >() || (!source2.TryGetValue(areaIdOnHousingArea, out source3) || source3.IsNullOrEmpty <int, AIProject.SaveData.AnimalData>()))
                        {
                            return;
                        }
                        int num = source3.Keys.Max();
                        if (source1 == null)
                        {
                            chickenTable[this.RegisterID] = source1 = new List <AIProject.SaveData.Environment.ChickenInfo>();
                        }
                        while (source1.Count <= num)
                        {
                            source1.Add((AIProject.SaveData.Environment.ChickenInfo)null);
                        }
                        for (int index = 0; index < source1.Count; ++index)
                        {
                            source1[index] = (AIProject.SaveData.Environment.ChickenInfo)null;
                        }
                        foreach (KeyValuePair <int, AIProject.SaveData.AnimalData> keyValuePair in source3)
                        {
                            int key = keyValuePair.Key;
                            AIProject.SaveData.AnimalData animalData = keyValuePair.Value;
                            if (animalData == null)
                            {
                                source1[key] = (AIProject.SaveData.Environment.ChickenInfo)null;
                            }
                            else
                            {
                                source1[key] = new AIProject.SaveData.Environment.ChickenInfo()
                                {
                                    name       = animalData.Nickname,
                                    AnimalData = animalData
                                }
                            };
                        }
                    }
                    if (source1.IsNullOrEmpty <AIProject.SaveData.Environment.ChickenInfo>())
                    {
                        return;
                    }
                }
                for (int index = 0; index < source1.Count; ++index)
                {
                    AIProject.SaveData.AnimalData animalData = source1.GetElement <AIProject.SaveData.Environment.ChickenInfo>(index)?.AnimalData;
                    if (animalData != null)
                    {
                        if (!animalData.InitAnimalTypeID || animalData.AnimalTypeID < 0)
                        {
                            animalData.AnimalTypeID     = AIProject.Animal.AnimalData.GetAnimalTypeID(animalData.AnimalType);
                            animalData.InitAnimalTypeID = true;
                        }
                        AnimalBase animalBase = Singleton <AnimalManager> .Instance.CreateBase(animalData.AnimalTypeID, (int)animalData.BreedingType);

                        if (!Object.op_Equality((Object)animalBase, (Object)null))
                        {
                            ((Component)animalBase).get_transform().SetParent(this.AnimalRoot, true);
                            animalData.AnimalID = animalBase.AnimalID;
                            if (animalBase is IPetAnimal petAnimal)
                            {
                                petAnimal.AnimalData = animalData;
                            }
                            PetChicken chicken = animalBase as PetChicken;
                            this.AddChicken(index, chicken);
                            if (Object.op_Inequality((Object)chicken, (Object)null))
                            {
                                chicken.Initialize(this);
                            }
                        }
                    }
                }
            }
        }
Пример #9
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)
            {
                ;
            }
        }