Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NPCKillCounterInfoElement.cs
Go to the documentation of this file.
1using System;
8using Terraria.UI;
9
11
13{
14 private NPC _instance;
15
16 public NPCKillCounterInfoElement(int npcNetId)
17 {
18 _instance = new NPC();
20 {
21 gameModeData = GameModeData.NormalMode,
22 strengthMultiplierOverride = null
23 });
24 }
25
27 {
28 int? killCount = GetKillCount();
29 if (!killCount.HasValue || killCount.Value < 1)
30 {
31 return null;
32 }
34 {
35 Width = new StyleDimension(0f, 1f),
36 Height = new StyleDimension(109f, 0f)
37 };
38 if (killCount.HasValue)
39 {
40 _ = killCount.Value > 0;
41 }
42 else
43 _ = 0;
44 _ = 3;
45 int num = 0;
46 int num2 = 30;
47 int num3 = num2;
48 string text = killCount.Value.ToString();
49 _ = text.Length;
50 int num4 = Math.Max(0, -48 + 8 * text.Length);
51 float num5 = 0.5f;
52 _ = 0;
53 num4 = -3;
54 num5 = 1f;
55 int num6 = 8;
56 UIElement uIElement = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode)1), null, 12, 7)
57 {
58 Width = new StyleDimension(-8 + num4, num5),
59 Height = new StyleDimension(num2, 0f),
60 BackgroundColor = new Color(43, 56, 101),
61 BorderColor = Color.Transparent,
62 Top = new StyleDimension(num, 0f),
63 Left = new StyleDimension(-num6, 0f),
64 HAlign = 1f
65 };
66 uIElement.SetPadding(0f);
67 uIElement.PaddingRight = 5f;
68 obj.Append(uIElement);
69 uIElement.OnUpdate += ShowDescription;
70 float textScale = 0.85f;
71 UIText element = new UIText(text, textScale)
72 {
73 HAlign = 1f,
74 VAlign = 0.5f,
75 Left = new StyleDimension(-3f, 0f),
76 Top = new StyleDimension(0f, 0f)
77 };
78 Item item = new Item();
79 item.SetDefaults(321);
80 item.scale = 0.8f;
81 UIItemIcon element2 = new UIItemIcon(item, blackedOut: false)
82 {
83 IgnoresMouseInteraction = true,
84 HAlign = 0f,
85 Left = new StyleDimension(-1f, 0f)
86 };
87 obj.Height.Pixels = num3;
88 uIElement.Append(element2);
89 uIElement.Append(element);
90 return obj;
91 }
92
93 private void ShowDescription(UIElement element)
94 {
95 if (element.IsMouseHovering)
96 {
97 Main.instance.MouseText(Language.GetTextValue("BestiaryInfo.Slain"), 0, 0);
98 }
99 }
100
101 private int? GetKillCount()
102 {
103 return Main.BestiaryTracker.Kills.GetKillCount(_instance);
104 }
105}
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static readonly GameModeData NormalMode
static string GetTextValue(string key)
Definition Language.cs:15
static Main instance
Definition Main.cs:283
static BestiaryUnlocksTracker BestiaryTracker
Definition Main.cs:1868
static IAssetRepository Assets
Definition Main.cs:209
void SetDefaults(int Type, NPCSpawnParams spawnparams=default(NPCSpawnParams))
Definition NPC.cs:2523
void Append(UIElement element)
Definition UIElement.cs:166
void SetPadding(float pixels)
Definition UIElement.cs:361
static Color Transparent
Definition Color.cs:76