Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ProvideUIElement()

UIElement Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.ProvideUIElement ( BestiaryUICollectionInfo info)
inline

Implements Terraria.GameContent.Bestiary.IBestiaryInfoElement.

Definition at line 61 of file NPCStatsReportInfoElement.cs.

62 {
63 if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
64 {
65 return null;
66 }
67 RefreshStats(Main.GameModeInfo, _instance);
68 UIElement uIElement = new UIElement
69 {
70 Width = new StyleDimension(0f, 1f),
71 Height = new StyleDimension(109f, 0f)
72 };
73 int num = 99;
74 int num2 = 35;
75 int num3 = 3;
76 int num4 = 0;
77 UIImage uIImage = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_HP", (AssetRequestMode)1))
78 {
79 Top = new StyleDimension(num4, 0f),
80 Left = new StyleDimension(num3, 0f)
81 };
82 UIImage uIImage2 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Attack", (AssetRequestMode)1))
83 {
84 Top = new StyleDimension(num4 + num2, 0f),
85 Left = new StyleDimension(num3, 0f)
86 };
87 UIImage uIImage3 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Defense", (AssetRequestMode)1))
88 {
89 Top = new StyleDimension(num4 + num2, 0f),
90 Left = new StyleDimension(num3 + num, 0f)
91 };
92 UIImage uIImage4 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Knockback", (AssetRequestMode)1))
93 {
94 Top = new StyleDimension(num4, 0f),
95 Left = new StyleDimension(num3 + num, 0f)
96 };
97 uIElement.Append(uIImage);
98 uIElement.Append(uIImage2);
99 uIElement.Append(uIImage3);
100 uIElement.Append(uIImage4);
101 int num5 = -10;
102 int num6 = 0;
103 int num7 = (int)MonetaryValue;
104 string text = Utils.Clamp(num7 / 1000000, 0, 999).ToString();
105 string text2 = Utils.Clamp(num7 % 1000000 / 10000, 0, 99).ToString();
106 string text3 = Utils.Clamp(num7 % 10000 / 100, 0, 99).ToString();
107 string text4 = Utils.Clamp(num7 % 100 / 1, 0, 99).ToString();
108 if (num7 / 1000000 < 1)
109 {
110 text = "-";
111 }
112 if (num7 / 10000 < 1)
113 {
114 text2 = "-";
115 }
116 if (num7 / 100 < 1)
117 {
118 text3 = "-";
119 }
120 if (num7 < 1)
121 {
122 text4 = "-";
123 }
124 string text5 = LifeMax.ToString();
125 string text6 = Damage.ToString();
126 string text7 = Defense.ToString();
127 string text8 = ((KnockbackResist > 0.8f) ? Language.GetText("BestiaryInfo.KnockbackHigh").Value : ((KnockbackResist > 0.4f) ? Language.GetText("BestiaryInfo.KnockbackMedium").Value : ((!(KnockbackResist > 0f)) ? Language.GetText("BestiaryInfo.KnockbackNone").Value : Language.GetText("BestiaryInfo.KnockbackLow").Value)));
128 if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
129 {
130 text = (text2 = (text3 = (text4 = "?")));
131 text5 = (text6 = (text7 = (text8 = "???")));
132 }
133 UIText element = new UIText(text5)
134 {
135 HAlign = 1f,
136 VAlign = 0.5f,
137 Left = new StyleDimension(num5, 0f),
138 Top = new StyleDimension(num6, 0f),
139 IgnoresMouseInteraction = true
140 };
141 UIText element2 = new UIText(text8)
142 {
143 HAlign = 1f,
144 VAlign = 0.5f,
145 Left = new StyleDimension(num5, 0f),
146 Top = new StyleDimension(num6, 0f),
147 IgnoresMouseInteraction = true
148 };
149 UIText element3 = new UIText(text6)
150 {
151 HAlign = 1f,
152 VAlign = 0.5f,
153 Left = new StyleDimension(num5, 0f),
154 Top = new StyleDimension(num6, 0f),
155 IgnoresMouseInteraction = true
156 };
157 UIText element4 = new UIText(text7)
158 {
159 HAlign = 1f,
160 VAlign = 0.5f,
161 Left = new StyleDimension(num5, 0f),
162 Top = new StyleDimension(num6, 0f),
163 IgnoresMouseInteraction = true
164 };
165 uIImage.Append(element);
166 uIImage2.Append(element3);
167 uIImage3.Append(element4);
168 uIImage4.Append(element2);
169 int num8 = 66;
170 if (num7 > 0)
171 {
173 {
174 Width = StyleDimension.FromPixelsAndPercent(0f, 1f),
175 Color = new Color(89, 116, 213, 255) * 0.9f,
176 Left = new StyleDimension(0f, 0f),
177 Top = new StyleDimension(num6 + num2 * 2, 0f)
178 };
179 uIElement.Append(element5);
180 num8 += 4;
181 int num9 = num3;
182 int num10 = num8 + 8;
183 int num11 = 49;
184 UIImage uIImage5 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Platinum", (AssetRequestMode)1))
185 {
186 Top = new StyleDimension(num10, 0f),
187 Left = new StyleDimension(num9, 0f)
188 };
189 UIImage uIImage6 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Gold", (AssetRequestMode)1))
190 {
191 Top = new StyleDimension(num10, 0f),
192 Left = new StyleDimension(num9 + num11, 0f)
193 };
194 UIImage uIImage7 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Silver", (AssetRequestMode)1))
195 {
196 Top = new StyleDimension(num10, 0f),
197 Left = new StyleDimension(num9 + num11 * 2 + 1, 0f)
198 };
199 UIImage uIImage8 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Copper", (AssetRequestMode)1))
200 {
201 Top = new StyleDimension(num10, 0f),
202 Left = new StyleDimension(num9 + num11 * 3 + 1, 0f)
203 };
204 if (text != "-")
205 {
206 uIElement.Append(uIImage5);
207 }
208 if (text2 != "-")
209 {
210 uIElement.Append(uIImage6);
211 }
212 if (text3 != "-")
213 {
214 uIElement.Append(uIImage7);
215 }
216 if (text4 != "-")
217 {
218 uIElement.Append(uIImage8);
219 }
220 int num12 = num5 + 3;
221 float textScale = 0.85f;
222 UIText element6 = new UIText(text, textScale)
223 {
224 HAlign = 1f,
225 VAlign = 0.5f,
226 Left = new StyleDimension(num12, 0f),
227 Top = new StyleDimension(num6, 0f)
228 };
229 UIText element7 = new UIText(text2, textScale)
230 {
231 HAlign = 1f,
232 VAlign = 0.5f,
233 Left = new StyleDimension(num12, 0f),
234 Top = new StyleDimension(num6, 0f)
235 };
236 UIText element8 = new UIText(text3, textScale)
237 {
238 HAlign = 1f,
239 VAlign = 0.5f,
240 Left = new StyleDimension(num12, 0f),
241 Top = new StyleDimension(num6, 0f)
242 };
243 UIText element9 = new UIText(text4, textScale)
244 {
245 HAlign = 1f,
246 VAlign = 0.5f,
247 Left = new StyleDimension(num12, 0f),
248 Top = new StyleDimension(num6, 0f)
249 };
250 uIImage5.Append(element6);
251 uIImage6.Append(element7);
252 uIImage7.Append(element8);
253 uIImage8.Append(element9);
254 num8 += 34;
255 }
256 num8 += 4;
257 uIElement.Height.Pixels = num8;
258 uIImage2.OnUpdate += ShowStats_Attack;
259 uIImage3.OnUpdate += ShowStats_Defense;
260 uIImage.OnUpdate += ShowStats_Life;
261 uIImage4.OnUpdate += ShowStats_Knockback;
262 return uIElement;
263 }
void RefreshStats(GameModeData gameModeFound, NPC instance)
static LocalizedText GetText(string key)
Definition Language.cs:10
void Append(UIElement element)
Definition UIElement.cs:166
static StyleDimension FromPixelsAndPercent(float pixels, float percent)

References Terraria.GameContent.Bestiary.NPCStatsReportInfoElement._instance, Terraria.UI.UIElement.Append(), Terraria.Main.Assets, Microsoft.Xna.Framework.Graphics.Color, Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.Damage, Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.Defense, Terraria.UI.StyleDimension.FromPixelsAndPercent(), Terraria.Main.GameModeInfo, Terraria.Localization.Language.GetText(), Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.KnockbackResist, Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.LifeMax, Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.MonetaryValue, Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.RefreshStats(), Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.ShowStats_Attack(), Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.ShowStats_Defense(), Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.ShowStats_Knockback(), and Terraria.GameContent.Bestiary.NPCStatsReportInfoElement.ShowStats_Life().