private void CalculateButton_OnClick(UIMouseEvent evt, UIElement listeningElement) { Player player = Main.LocalPlayer; if (!FishingTool.ValidateSpawnPosition(player, out Vector2 spawnPosition)) { return; } Main.NewText("Calculating...."); FishingTool.CalculateCatches(spawnPosition, player.HeldItem.shoot, out int poolSize, out bool lava, out bool honey); checklistList.Clear(); float total = 0; foreach (var catchPair in FishingTool.catches) { total += catchPair.Value; } if (total > 0) { foreach (var catchPair in FishingTool.catches) { UIFishingCatchesInfo spawnInfo = new UIFishingCatchesInfo(catchPair.Key, catchPair.Value / total); checklistList.Add(spawnInfo); } } // Helpful message string liquidName = "water"; if (lava) { liquidName = "lava"; } else if (honey) { liquidName = "honey"; } int fishingPower = player.FishingLevel(); Main.NewText($"Tested {total} fishing cases with {fishingPower} fishing power in a pool of {liquidName} with size {poolSize}"); }
public override int CompareTo(object obj) { UIFishingCatchesInfo other = obj as UIFishingCatchesInfo; return(-1 * percent.CompareTo(other.percent)); }