public FishItem(int id, FishModel fish) : base(id, 1, false, -1, fish.quality) { if (syncObject == null) { syncObject = new PySync(this); syncObject.init(); } this.Name += " "; this.Id = id; this.Description = base.getDescription(); this.FishStack.Add(fish); }
public static void GiveFish() { int fishId = 1; // anchovy string fishName = ModEntryInstance.fp.AllFish[fishId].Item2; // get the list of fish in the Population with that name List <FishModel> fishOfType; ModEntryInstance.population.TryGetValue(fishName, out fishOfType); // get a random fish of that type from the population int numFishOfType = fishOfType.Count; int selectedFishIndex = ModEntry.rand.Next(0, numFishOfType); FishModel selectedFish = fishOfType[selectedFishIndex]; // store a new custom fish item Item customFish = (Item) new FishItem(ModEntryInstance.fp.AllFish[fishId].Item1, selectedFish); FishItem.itemToAdd = customFish as FishItem; ((FishItem)customFish).AddToInventory(); ModEntryInstance.FishCaught = customFish; List <FishModel> fishToDelete; ModEntryInstance.population.TryGetValue(fishName, out fishToDelete); int maxLength = 0; int sf = 0; for (int i = 0; i < fishToDelete.Count; i++) { if (fishToDelete[i].length > maxLength) { sf = i; maxLength = (int)fishToDelete[i].length; } } fishOfType.RemoveAt(sf); fishOfType.Add(fishToDelete[fishToDelete.Count - 1].MakeBaby()); ModEntryInstance.population[fishName] = fishToDelete; if (ModEntryInstance.fp.IsAverageFishBelowValue(fishName)) { } }