public void RemoveUser() { this.SaveData.AnimalData = (AIProject.SaveData.AnimalData)null; if (this.User == null) { return; } this.User.Release(); this.User = (IPetAnimal)null; }
private void NameChanged(string petName) { this._elementText.set_text(petName); IPetAnimal petAnimal = this._currentPetHomePoint != null ? this._currentPetHomePoint.User : (IPetAnimal)null; if (petAnimal == null) { return; } petAnimal.Nickname = petName; }
public void SetUser(IPetAnimal animal) { if (animal == null) { return; } if (this.User != null) { this.User.Release(); } this.User = animal; this.SaveData.AnimalData = animal.AnimalData; animal.Initialize(this); }
public void SetRootPoint(int pointID, IPetAnimal animal) { if (animal == null) { return; } Transform element = this._rootPoints.GetElement <Transform>(pointID); Transform transform = !Object.op_Inequality((Object)element, (Object)null) ? ((Component)this).get_transform() : element; if (Object.op_Equality((Object)transform, (Object)null)) { return; } animal.Position = transform.get_position(); animal.Rotation = transform.get_rotation(); }
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); }
public decimal GetFoodPrice(string petType) { IPetAnimal petAnimal = null; if (petType == "Dog") { petAnimal = new Dog(); } else if (petType == "Cat") { petAnimal = new Cat(); } else { MessageBox.Show("This animal is not supported yet."); return(0M); } return(petAnimal.GetFoodPrice()); }
public void DestroyChicken() { if (this._farmKind != FarmPoint.FarmKind.ChickenCoop) { return; } if (this.ChickenList != null) { this.ChickenList.RemoveAll((Predicate <PetChicken>)(x => Object.op_Equality((Object)x, (Object)null))); foreach (PetChicken chicken in this.ChickenList) { IPetAnimal petAnimal = (IPetAnimal)chicken; if (petAnimal != null) { petAnimal.Release(); } else { chicken.Release(); } } ListPool <PetChicken> .Release(this.ChickenList); this.ChickenList = (List <PetChicken>)null; } AIProject.SaveData.Environment environment = !Singleton <Game> .IsInstance() ? (AIProject.SaveData.Environment)null : Singleton <Game> .Instance.Environment; if (environment == null) { return; } Dictionary <int, List <AIProject.SaveData.Environment.ChickenInfo> > chickenTable = environment.ChickenTable; if (!chickenTable.TryGetValue(this.RegisterID, out List <AIProject.SaveData.Environment.ChickenInfo> _)) { return; } chickenTable.Remove(this.RegisterID); }
private void Send(int currentID, ItemNodeUI currentOption) { if (Object.op_Equality((Object)this._currentPetHomePoint, (Object)null)) { return; } Dictionary <int, List <ValueTuple <ItemIDKeyPair, int> > > dictionary1 = !Singleton <Manager.Resources> .IsInstance() ? (Dictionary <int, List <ValueTuple <ItemIDKeyPair, int> > >)null : Singleton <Manager.Resources> .Instance.AnimalTable.PetItemInfoTable; if (((IReadOnlyDictionary <int, List <ValueTuple <ItemIDKeyPair, int> > >)dictionary1).IsNullOrEmpty <int, List <ValueTuple <ItemIDKeyPair, int> > >()) { return; } int kind = (int)this._currentPetHomePoint.Kind; List <ValueTuple <ItemIDKeyPair, int> > valueTupleList; if (!dictionary1.TryGetValue(kind, out valueTupleList) || ((IReadOnlyList <ValueTuple <ItemIDKeyPair, int> >)valueTupleList).IsNullOrEmpty <ValueTuple <ItemIDKeyPair, int> >()) { return; } StuffItem item = currentOption.Item; int index; // ISSUE: cast to a reference type // ISSUE: explicit reference operation // ISSUE: cast to a reference type // ISSUE: explicit reference operation if ((index = valueTupleList.FindIndex((Predicate <ValueTuple <ItemIDKeyPair, int> >)(x => (^ (ItemIDKeyPair&)ref x.Item1).categoryID == item.CategoryID && (^ (ItemIDKeyPair&)ref x.Item1).itemID == item.ID))) < 0) { return; } ValueTuple <ItemIDKeyPair, int> valueTuple = valueTupleList[index]; 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(); string name = Singleton <Manager.Resources> .Instance.GameInfo.GetItem(item.CategoryID, item.ID).Name; IPetAnimal animal = (IPetAnimal)null; int pointID = 0; switch (this._currentPetHomePoint.Kind) { case PetHomePoint.HomeKind.PetMat: animal = Singleton <AnimalManager> .Instance.CreateBase((int)valueTuple.Item2, 1) as IPetAnimal; break; case PetHomePoint.HomeKind.FishTank: Dictionary <int, Dictionary <int, FishInfo> > dictionary2 = !Singleton <Manager.Resources> .IsInstance() ? (Dictionary <int, Dictionary <int, FishInfo> >)null : Singleton <Manager.Resources> .Instance.Fishing.FishInfoTable; Dictionary <int, FishInfo> dictionary3; FishInfo fishInfo; if (dictionary2 != null && dictionary2.TryGetValue(item.CategoryID, out dictionary3) && (!((IReadOnlyDictionary <int, FishInfo>)dictionary3).IsNullOrEmpty <int, FishInfo>() && dictionary3.TryGetValue(item.ID, out fishInfo))) { animal = Singleton <AnimalManager> .Instance.CreateBase((int)valueTuple.Item2, 1) as IPetAnimal; pointID = fishInfo.TankPointID; break; } break; } this._elementText.set_text(name ?? this._noneNameStr); this.SetActive((Component)this._nameChangeButton, animal != null); if (animal != null) { this._inventoryUI.Visible = false; this.SetInteractable((Selectable)this._escapeButton, true); animal.AnimalData = new AIProject.SaveData.AnimalData() { First = true, AnimalID = animal.AnimalID, RegisterID = this._currentPetHomePoint.RegisterID, AnimalType = (AnimalTypes)(1 << valueTuple.Item2), AnimalTypeID = (int)valueTuple.Item2, InitAnimalTypeID = true, BreedingType = BreedingTypes.Pet, ItemCategoryID = item.CategoryID, ItemID = item.ID, ModelID = this.GetPetAnimalModelID((int)valueTuple.Item2), Position = this._currentPetHomePoint.Position, Rotation = this._currentPetHomePoint.Rotation }; animal.Nickname = name; if (animal is IGroundPet) { (animal as IGroundPet).ChaseActor = this._currentPetHomePoint.SaveData.ChaseActor; } this._currentPetHomePoint.SetUser(animal); this._currentPetHomePoint.SetRootPoint(pointID, animal); } this.PlaySystemSE(SoundPack.SystemSE.OK_L); }