public static List <NPCDropInfo> GetNPCDropInfoList() { List <NPCDropInfo> result = new List <NPCDropInfo>(); var rand = Main.rand; bool expertMode = Main.expertMode; Main.rand = new LootUnifiedRandom(); Main.expertMode = false; for (int netID = -65; netID < NPCLoader.NPCCount; netID++) //int netID = 1; { NPC npc = new NPC(); npc.SetDefaults(netID); for (int i = 0; i < 100; i++) { try { LootUnifiedRandom.NextLoop(i); npc.NPCLoot(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"{netID}: {ex.Message}"); } } var info = new NPCDropInfo(npc); foreach (var a in LootUnifiedRandom.list) { foreach (var b in a.list.Where(x => 0 < x.items.Count)) { var list = new DropItemList(); list.rate = b.maxValue; list.expert = Main.expertMode; foreach (var c in b.items) { if (!info.list.Any(x => x.items.Any(y => y.id == c.Value.netID)) && !list.items.Any(x => x.id == c.Value.netID)) { list.items.Add(new DropItem(c.Value)); } } if (0 < list.items.Count) { info.list.Add(list); } } } if (0 < info.list.Count) { result.Add(info); } } Main.rand = rand; Main.expertMode = expertMode; return(result); }
internal override void TooltipDraw() { if (visible && ModContent.GetInstance <NPCInfoConfig>().isDisplayDropInfo&& !string.IsNullOrEmpty(tooltip) && targetNPC != null && listDropInfo != null && NPCInfoUI.instance.ViewMode == ViewMode.CombatNPC) { var dropInfo = listDropInfo.Where(x => { NPCDropInfo result = null; if (targetNPC.modNPC == null) { if (targetNPC.type == x.id) { result = x; } } else { if (targetNPC.modNPC.mod.Name == x.mod && targetNPC.FullName == x.name) { result = x; } } return(result != null); }).ToArray(); if (0 < dropInfo.Length) { SpriteBatch spriteBatch = Main.spriteBatch; Vector2 pos = Main.MouseScreen; pos.Y += Main.fontMouseText.MeasureString(tooltip).Y + 20; Texture2D texture = null; foreach (var list in dropInfo[0].list) { foreach (var item in list.items) { try { texture = null; if (string.IsNullOrEmpty(item.mod)) { texture = Main.itemTexture[item.id]; } else { if (dicModItemNameToType.ContainsKey(item.mod) && dicModItemNameToType[item.mod].ContainsKey(item.name)) { texture = Main.itemTexture[dicModItemNameToType[item.mod][item.name]]; } } if (texture != null) { spriteBatch.Draw(texture, pos, new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)), Color.White, 0, new Vector2(), 1.0f, SpriteEffects.None, 0f); string name = string.IsNullOrEmpty(item.mod) ? Lang.GetItemName(item.id).Value : item.name; if (!noRate.Contains(item.id)) { string rate = 5 < list.rate.ToString().Length ? (100f / list.rate).ToString("0." + new string('#', list.rate.ToString().Length - 3)) : (100f / list.rate).ToString("0.##"); name += $" ({rate}%)"; } Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, name, pos.X + texture.Width + 4, pos.Y, Color.White, Color.Black, Vector2.Zero, 1f); pos.Y += texture.Height + 4; } } catch { } } } } Main.hoverItemName = tooltip; } else if (visible && !string.IsNullOrEmpty(tooltip) && targetNPC != null && NPCInfoUI.instance.ViewMode == ViewMode.SpawnNPC) { Vector2 pos = Main.MouseScreen; var defaultX = pos.X + 16; pos.X = defaultX; Main.hoverItemName = tooltip; pos.Y += Main.fontMouseText.MeasureString(tooltip).Y + 20; //スポーンNPCの価値を表示する(おおよそ) if (ModContent.GetInstance <NPCInfoConfig>().isDisplaySpawnValue) { Item item = new Item(); item.value = (int)targetNPC.value; item.buy = true; item.stack = 1; var price = NPCInfoUtils.GetPriceTooltipLine(item, false); pos.X = NPCInfoUtils.GetScreenContainsTextPositionX(defaultX, price.text); Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, price.text, pos.X, pos.Y, price.overrideColor ?? Color.White, Color.Black, Vector2.Zero, 1f); pos.Y += Main.fontMouseText.MeasureString(price.text).Y + 4; } string[] texts = { $"{targetNPC.lifeMax}", $"{targetNPC.defDamage}", $"{targetNPC.defDefense}", $"{targetNPC.knockBackResist:0.##}" }; int maxWidth = UICombatNPCSlot.textures.Sum(x => x.Width) + texts.Sum(x => (int)Main.fontMouseText.MeasureString(x).X) + 46; if (Main.screenWidth < pos.X + maxWidth) { pos.X = Main.screenWidth - maxWidth; } for (int i = 0; i < UICombatNPCSlot.textures.Length; i++) { Main.spriteBatch.Draw(UICombatNPCSlot.textures[i], pos, Color.White); pos.X += UICombatNPCSlot.textures[i].Width + 4; Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, texts[i], pos.X, pos.Y, Color.White, Color.Black, Vector2.Zero, 1f); pos.X += Main.fontMouseText.MeasureString(texts[i]).X + 8; } var nearNPC = NPCInfoUtils.GetActiveNearNPC(targetNPC.netID); if (nearNPC != null) { pos.X = Main.MouseScreen.X + 16; pos.Y += UICombatNPCSlot.textures.Max(x => x.Height) + 4; var nearPos = (Main.LocalPlayer.Center - nearNPC.Center) / 16; var text = $"Near distance: {Math.Abs((int)nearPos.X)} x {Math.Abs((int)nearPos.Y)}"; pos.X = NPCInfoUtils.GetScreenContainsTextPositionX(defaultX, text); Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, pos.X, pos.Y, Color.White, Color.Black, Vector2.Zero, 1f); } } else if (visible && !string.IsNullOrEmpty(tooltip) && NPCInfoUI.instance.ViewMode == ViewMode.DropItem) { Main.hoverItemName = tooltip; if (targetItem != null) { Vector2 pos = Main.MouseScreen; var defaultX = pos.X + 16; pos.Y += Main.fontMouseText.MeasureString(tooltip).Y + 20; //ドロップアイテムの価値を表示する if (ModContent.GetInstance <NPCInfoConfig>().isDisplayDropItemValue) { var price = NPCInfoUtils.GetPriceTooltipLine(targetItem); pos.X = NPCInfoUtils.GetScreenContainsTextPositionX(defaultX, price.text); Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, price.text, pos.X, pos.Y, price.overrideColor ?? Color.White, Color.Black, Vector2.Zero, 1f); pos.Y += Main.fontMouseText.MeasureString(price.text).Y + 4; } int count = Main.item.Count(x => x.active && x.netID == targetItem.netID); string text = $"Count: {count}"; pos.X = NPCInfoUtils.GetScreenContainsTextPositionX(defaultX, text); Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, pos.X, pos.Y, Color.White, Color.Black, Vector2.Zero, 1f); var nearItem = NPCInfoUtils.GetActiveNearItem(targetItem.netID); if (nearItem != null) { pos.Y += Main.fontMouseText.MeasureString(text).Y + 4; var nearPos = (Main.LocalPlayer.Center - nearItem.Center) / 16; text = $"Near distance: {Math.Abs((int)nearPos.X)} x {Math.Abs((int)nearPos.Y)}"; pos.X = NPCInfoUtils.GetScreenContainsTextPositionX(defaultX, text); Utils.DrawBorderStringFourWay(Main.spriteBatch, Main.fontMouseText, text, pos.X, pos.Y, Color.White, Color.Black, Vector2.Zero, 1f); } } } else if (visible && !string.IsNullOrEmpty(tooltip)) { Main.hoverItemName = tooltip; } }