Exemplo n.º 1
0
        private void Send(int currentID, ItemNodeUI currentOption)
        {
            StuffItem item      = currentOption.Item;
            StuffItem stuffItem = this._inventoryUI.itemList.Find((Predicate <StuffItem>)(x => x == item));

            --stuffItem.Count;
            if (stuffItem.Count <= 0)
            {
                this._inventoryUI.itemList.Remove(stuffItem);
                this._inventoryUI.itemListUI.RemoveItemNode(currentID);
                this._inventoryUI.itemListUI.ForceSetNonSelect();
            }
            this._inventoryUI.itemListUI.Refresh();
            int currentIndex = this._chickenCoopListUI.currentIndex;

            while (this.currentChickens.Count <= currentIndex)
            {
                this.currentChickens.Add((AIProject.SaveData.Environment.ChickenInfo)null);
            }
            AIProject.SaveData.Environment.ChickenInfo info = new AIProject.SaveData.Environment.ChickenInfo();
            info.name = "ニワトリ";
            ValueTuple <AIProject.SaveData.AnimalData, PetChicken> chicken = this.CreateChicken(info);

            info.AnimalData = (AIProject.SaveData.AnimalData)chicken.Item1;
            if (Object.op_Inequality((Object)this._currentFarmPoint, (Object)null))
            {
                this._currentFarmPoint.AddChicken(currentIndex, (PetChicken)chicken.Item2);
            }
            this.currentChickens[currentIndex] = info;
            this._chickenCoopListUI.Refresh(currentIndex);
            this._inventoryUI.Visible = false;
        }
Exemplo n.º 2
0
 public void Set(string noneStr, AIProject.SaveData.Environment.ChickenInfo info)
 {
     this._info = info;
     ((Behaviour)this._icon).set_enabled(this.isActive);
     this._name.set_text(info?.name ?? noneStr);
     ((Component)this._nameChange).get_gameObject().SetActive(this.isActive);
 }
Exemplo n.º 3
0
        private void NameChanged(AIProject.SaveData.Environment.ChickenInfo info)
        {
            if (info == null || info.AnimalData == null)
            {
                return;
            }
            AIProject.SaveData.AnimalData        animalData = info.AnimalData;
            ReadOnlyDictionary <int, AnimalBase> source     = !Singleton <AnimalManager> .IsInstance() ? (ReadOnlyDictionary <int, AnimalBase>)null : Singleton <AnimalManager> .Instance.AnimalTable;

            AnimalBase animalBase;

            if (source.IsNullOrEmpty <int, AnimalBase>() || !source.TryGetValue(animalData.AnimalID, ref animalBase) || !(animalBase is PetChicken))
            {
                return;
            }
            (animalBase as PetChicken).Nickname = info.name;
        }
Exemplo n.º 4
0
        private void RemoveChicken(int index, AIProject.SaveData.Environment.ChickenInfo info)
        {
            AnimalBase animalBase;

            if (info == null || info.AnimalData == null || (!Singleton <AnimalManager> .IsInstance() || !Singleton <AnimalManager> .Instance.AnimalTable.TryGetValue(info.AnimalData.AnimalID, ref animalBase)) || !Object.op_Inequality((Object)animalBase, (Object)null))
            {
                return;
            }
            if (Object.op_Inequality((Object)this._currentFarmPoint, (Object)null))
            {
                this._currentFarmPoint.RemoveChicken(index, animalBase as PetChicken);
            }
            if (!(animalBase is IPetAnimal))
            {
                return;
            }
            (animalBase as IPetAnimal).Release();
        }
Exemplo n.º 5
0
        private ValueTuple <AIProject.SaveData.AnimalData, PetChicken> CreateChicken(
            AIProject.SaveData.Environment.ChickenInfo info)
        {
            ValueTuple <AIProject.SaveData.AnimalData, PetChicken> valueTuple;

            ((ValueTuple <AIProject.SaveData.AnimalData, PetChicken>) ref valueTuple).\u002Ector((AIProject.SaveData.AnimalData)null, (PetChicken)null);
            if (info == null || !Singleton <AnimalManager> .IsInstance() || Object.op_Equality((Object)this._currentFarmPoint, (Object)null))
            {
                return(valueTuple);
            }
            int        _animalTypeID = 1;
            AnimalBase animalBase    = Singleton <AnimalManager> .Instance.CreateBase(_animalTypeID, 1);

            IPetAnimal petAnimal = animalBase as IPetAnimal;

            if (Object.op_Equality((Object)animalBase, (Object)null))
            {
                return(valueTuple);
            }
            ((Component)animalBase).get_transform().SetParent(this._currentFarmPoint.AnimalRoot, true);
            AIProject.SaveData.AnimalData animalData = new AIProject.SaveData.AnimalData();
            animalData.AnimalID         = animalBase.AnimalID;
            animalData.RegisterID       = this._currentFarmPoint.RegisterID;
            animalData.AnimalType       = AnimalTypes.Chicken;
            animalData.AnimalTypeID     = _animalTypeID;
            animalData.InitAnimalTypeID = true;
            animalData.BreedingType     = BreedingTypes.Pet;
            animalData.Nickname         = info.name;
            ItemIDKeyPair itemId = animalBase.ItemID;

            animalData.ItemCategoryID = itemId.categoryID;
            animalData.ItemID         = itemId.itemID;
            if (petAnimal != null)
            {
                petAnimal.AnimalData = animalData;
                if (animalBase is PetChicken)
                {
                    (animalBase as PetChicken).Initialize(this._currentFarmPoint);
                }
            }
            valueTuple.Item1 = (__Null)animalData;
            valueTuple.Item2 = (__Null)(animalBase as PetChicken);
            return(valueTuple);
        }
Exemplo n.º 6
0
 public virtual void Open(AIProject.SaveData.Environment.ChickenInfo info)
 {
     this.IsActiveControl = true;
     this._info           = info;
     this._nameInputField.set_text(info.name);
 }
Exemplo n.º 7
0
        protected override void Start()
        {
            ObservableExtensions.Subscribe <bool>((IObservable <M0>) this.OnActiveChangedAsObservable(), (Action <M0>)(x => this.SetActiveControl(x)));
            if (Object.op_Inequality((Object)this._closeButton, (Object)null))
            {
                ObservableExtensions.Subscribe <Unit>((IObservable <M0>)UnityUIComponentExtensions.OnClickAsObservable(this._closeButton), (Action <M0>)(_ =>
                {
                    this.playSE.Play(SoundPack.SystemSE.Cancel);
                    this.OnInputCancel();
                }));
            }
            ObservableExtensions.Subscribe <int>((IObservable <M0>) this._currentIndex, (Action <M0>)(x =>
            {
                bool flag1 = x >= 0;
                ((Component)this._currentCursor).get_gameObject().SetActive(flag1);
                if (flag1)
                {
                    CursorFrame.Set((RectTransform)((Component)this._currentCursor).GetComponent <RectTransform>(), (RectTransform)((Component)this._chickens[x].toggle).GetComponent <RectTransform>(), (RectTransform)null);
                    if (this.IconChanged != null)
                    {
                        this.IconChanged(x);
                    }
                }
                bool flag2 = this.GetChickenInfo(x) != null;
                ((Selectable)this._escapeButton).set_interactable(flag2);
                if (flag2)
                {
                    return;
                }
                this._nameChangeUI.Close();
            }));
            DisposableExtensions.AddTo <CompositeDisposable>((M0)((IEnumerable <Selectable>)((IEnumerable <ChickenCoopListUI.Chicken>) this._chickens).Select <ChickenCoopListUI.Chicken, Toggle>((Func <ChickenCoopListUI.Chicken, Toggle>)(p => p.toggle))).BindToEnter(true, this._selectCursor), (Component)this);
            DisposableExtensions.AddTo <IDisposable>((M0)((IEnumerable <ChickenCoopListUI.Chicken>) this._chickens).Select <ChickenCoopListUI.Chicken, Toggle>((Func <ChickenCoopListUI.Chicken, Toggle>)(p => p.toggle)).BindToGroup((Action <int>)(sel => ((ReactiveProperty <int>) this._currentIndex).set_Value(sel))), (Component)this);
            this._nameChangeUI.OnSubmit += (Action)(() =>
            {
                this.playSE.Play(SoundPack.SystemSE.OK_S);
                AIProject.SaveData.Environment.ChickenInfo chickenInfo = this.GetChickenInfo(this._nameChangeIndex);
                this._chickens[this._nameChangeIndex].name.set_text(chickenInfo?.name ?? string.Empty);
                this.NameChanged(chickenInfo);
            });
            this._nameChangeUI.OnCancel += (Action)(() => this.playSE.Play(SoundPack.SystemSE.Cancel));
            // ISSUE: object of a compiler-generated type is created
            foreach (\u003C\u003E__AnonType18 <ChickenCoopListUI.Chicken, int> anonType18 in ((IEnumerable <ChickenCoopListUI.Chicken>) this._chickens).Select <ChickenCoopListUI.Chicken, \u003C\u003E__AnonType18 <ChickenCoopListUI.Chicken, int> >((Func <ChickenCoopListUI.Chicken, int, \u003C\u003E__AnonType18 <ChickenCoopListUI.Chicken, int> >)((p, i) => new \u003C\u003E__AnonType18 <ChickenCoopListUI.Chicken, int>(p, i))))
            {
                // ISSUE: variable of a compiler-generated type
                \u003C\u003E__AnonType18 <ChickenCoopListUI.Chicken, int> item = anonType18;
                ChickenCoopListUI chickenCoopListUi = this;
                DisposableExtensions.AddTo <IDisposable>((M0)ObservableExtensions.Subscribe <int>((IObservable <M0>)Observable.Select <Unit, int>((IObservable <M0>)item.p.NameChange, (Func <M0, M1>)(_ => item.i)), (Action <M0>)(index =>
                {
                    chickenCoopListUi.playSE.Play(SoundPack.SystemSE.OK_S);
                    chickenCoopListUi._nameChangeIndex = index;
                    chickenCoopListUi._nameChangeUI.Open(chickenCoopListUi.GetChickenInfo(index));
                })), (Component)this);
            }
            ActionIDDownCommand actionIdDownCommand1 = new ActionIDDownCommand()
            {
                ActionID = ActionID.Cancel
            };

            // ISSUE: method pointer
            actionIdDownCommand1.TriggerEvent.AddListener(new UnityAction((object)this, __methodptr(\u003CStart\u003Em__B)));
            this._actionCommands.Add(actionIdDownCommand1);
            ActionIDDownCommand actionIdDownCommand2 = new ActionIDDownCommand()
            {
                ActionID = ActionID.MouseRight
            };

            // ISSUE: method pointer
            actionIdDownCommand2.TriggerEvent.AddListener(new UnityAction((object)this, __methodptr(\u003CStart\u003Em__C)));
            this._actionCommands.Add(actionIdDownCommand2);
            ActionIDDownCommand actionIdDownCommand3 = new ActionIDDownCommand()
            {
                ActionID = ActionID.SquareX
            };

            // ISSUE: method pointer
            actionIdDownCommand3.TriggerEvent.AddListener(new UnityAction((object)this, __methodptr(\u003CStart\u003Em__D)));
            this._actionCommands.Add(actionIdDownCommand3);
            ActionIDDownCommand actionIdDownCommand4 = new ActionIDDownCommand()
            {
                ActionID = ActionID.Submit
            };

            // ISSUE: method pointer
            actionIdDownCommand4.TriggerEvent.AddListener(new UnityAction((object)this, __methodptr(\u003CStart\u003Em__E)));
            this._actionCommands.Add(actionIdDownCommand4);
            base.Start();
        }
Exemplo n.º 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);
                            }
                        }
                    }
                }
            }
        }