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

◆ DrawItem()

void Terraria.Main.DrawItem ( Item item,
int whoami )
inlineprotected

Definition at line 35252 of file Main.cs.

35253 {
35254 if (!item.active || item.IsAir)
35255 {
35256 return;
35257 }
35258 instance.LoadItem(item.type);
35260 Vector2 vector = frame.Size() / 2f;
35261 Vector2 vector2 = new Vector2((float)(item.width / 2) - vector.X, item.height - frame.Height);
35262 Vector2 vector3 = item.position - screenPosition + vector + vector2;
35263 float num = item.velocity.X * 0.2f;
35264 if (item.shimmered)
35265 {
35266 num = 0f;
35267 }
35268 float scale = 1f;
35269 Microsoft.Xna.Framework.Color color = Lighting.GetColor(item.Center.ToTileCoordinates());
35271 if (item.shimmered)
35272 {
35273 currentColor.R = (byte)(255f * (1f - item.shimmerTime));
35274 currentColor.G = (byte)(255f * (1f - item.shimmerTime));
35275 currentColor.B = (byte)(255f * (1f - item.shimmerTime));
35276 currentColor.A = (byte)(255f * (1f - item.shimmerTime));
35277 }
35278 else if (item.shimmerTime > 0f)
35279 {
35280 currentColor.R = (byte)((float)(int)currentColor.R * (1f - item.shimmerTime));
35281 currentColor.G = (byte)((float)(int)currentColor.G * (1f - item.shimmerTime));
35282 currentColor.B = (byte)((float)(int)currentColor.B * (1f - item.shimmerTime));
35283 currentColor.A = (byte)((float)(int)currentColor.A * (1f - item.shimmerTime));
35284 }
35286 int num2 = item.glowMask;
35287 if (!gamePaused && base.IsActive && (item.IsACoin || item.type == 58 || item.type == 109) && color.R > 60 && (float)rand.Next(500) - (Math.Abs(item.velocity.X) + Math.Abs(item.velocity.Y)) * 10f < (float)(color.R / 50))
35288 {
35289 int type = 43;
35291 int alpha = 254;
35292 float scale2 = 0.5f;
35293 if (item.IsACoin)
35294 {
35296 alpha = 0;
35297 scale2 = 1f;
35298 }
35299 switch (item.type)
35300 {
35301 case 71:
35302 type = 244;
35303 break;
35304 case 72:
35305 type = 245;
35306 break;
35307 case 73:
35308 type = 246;
35309 break;
35310 case 74:
35311 type = 247;
35312 break;
35313 }
35314 int num3 = Dust.NewDust(item.position, item.width, item.height, type, 0f, 0f, alpha, newColor, scale2);
35315 dust[num3].velocity *= 0f;
35316 }
35317 if (ItemID.Sets.BossBag[item.type])
35318 {
35319 float num4 = (float)item.timeSinceItemSpawned / 240f + GlobalTimeWrappedHourly * 0.04f;
35323 if (globalTimeWrappedHourly >= 1f)
35324 {
35326 }
35328 for (float num5 = 0f; num5 < 1f; num5 += 0.25f)
35329 {
35330 spriteBatch.Draw(texture, vector3 + new Vector2(0f, 8f).RotatedBy((num5 + num4) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly, frame, new Microsoft.Xna.Framework.Color(90, 70, 255, 50), num, vector, scale, SpriteEffects.None, 0f);
35331 }
35332 for (float num6 = 0f; num6 < 1f; num6 += 0.34f)
35333 {
35334 spriteBatch.Draw(texture, vector3 + new Vector2(0f, 4f).RotatedBy((num6 + num4) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly, frame, new Microsoft.Xna.Framework.Color(140, 120, 255, 77), num, vector, scale, SpriteEffects.None, 0f);
35335 }
35336 }
35337 else if (item.type == 75)
35338 {
35339 float num7 = (float)item.timeSinceItemSpawned / 240f + GlobalTimeWrappedHourly * 0.04f;
35343 if (globalTimeWrappedHourly2 >= 1f)
35344 {
35346 }
35348 for (float num8 = 0f; num8 < 1f; num8 += 0.25f)
35349 {
35350 spriteBatch.Draw(TextureAssets.Item[item.type].Value, vector3 + new Vector2(0f, 8f).RotatedBy((num8 + num7) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly2, frame, new Microsoft.Xna.Framework.Color(50, 50, 255, 50), num, vector, scale, SpriteEffects.None, 0f);
35351 }
35352 for (float num9 = 0f; num9 < 1f; num9 += 0.34f)
35353 {
35354 spriteBatch.Draw(TextureAssets.Item[item.type].Value, vector3 + new Vector2(0f, 4f).RotatedBy((num9 + num7) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly2, frame, new Microsoft.Xna.Framework.Color(120, 120, 255, 127), num, vector, scale, SpriteEffects.None, 0f);
35355 }
35356 }
35357 else if (item.type == 4143)
35358 {
35359 float num10 = (float)item.timeSinceItemSpawned / 240f + GlobalTimeWrappedHourly * 0.04f;
35363 if (globalTimeWrappedHourly3 >= 1f)
35364 {
35366 }
35368 for (float num11 = 0f; num11 < 1f; num11 += 0.34f)
35369 {
35370 spriteBatch.Draw(TextureAssets.Item[item.type].Value, vector3 + new Vector2(0f, 8f).RotatedBy((num11 + num10) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly3, frame, new Microsoft.Xna.Framework.Color(30, 30, 155, 60), num, vector, scale, SpriteEffects.None, 0f);
35371 }
35372 for (float num12 = 0f; num12 < 1f; num12 += 0.34f)
35373 {
35374 spriteBatch.Draw(TextureAssets.Item[item.type].Value, vector3 + new Vector2(0f, 4f).RotatedBy((num12 + num10) * ((float)Math.PI * 2f)) * globalTimeWrappedHourly3, frame, new Microsoft.Xna.Framework.Color(60, 60, 127, 57), num, vector, scale, SpriteEffects.None, 0f);
35375 }
35376 spriteBatch.Draw(texture, vector3, frame, new Microsoft.Xna.Framework.Color(255, 255, 255, 128), num, vector, scale, SpriteEffects.None, 0f);
35377 }
35378 if ((item.type >= 1522 && item.type <= 1527) || item.type == 3643)
35379 {
35380 currentColor = ((!(item.shimmerTime > 0f)) ? new Microsoft.Xna.Framework.Color(250, 250, 250, mouseTextColor / 2) : new Microsoft.Xna.Framework.Color((int)(250f * (1f - item.shimmerTime)), (int)(250f * (1f - item.shimmerTime)), (int)(250f * (1f - item.shimmerTime)), (int)((float)(mouseTextColor / 2) * (1f - item.shimmerTime))));
35381 scale = (float)(int)mouseTextColor / 1000f + 0.8f;
35382 }
35383 if (item.type == 3779)
35384 {
35385 num2 = -1;
35386 }
35387 spriteBatch.Draw(texture, vector3, frame, currentColor, num, vector, scale, SpriteEffects.None, 0f);
35388 if (item.shimmered)
35389 {
35390 spriteBatch.Draw(texture, vector3, frame, new Microsoft.Xna.Framework.Color(currentColor.R, currentColor.G, currentColor.B, 0), num, vector, scale, SpriteEffects.None, 0f);
35391 }
35393 {
35394 spriteBatch.Draw(texture, vector3, frame, item.GetColor(color), num, vector, scale, SpriteEffects.None, 0f);
35395 }
35396 if (num2 != -1)
35397 {
35399 int type2 = item.type;
35400 if (type2 == 5146)
35401 {
35403 }
35404 spriteBatch.Draw(TextureAssets.GlowMask[num2].Value, vector3, frame, color2, num, vector, scale, SpriteEffects.None, 0f);
35405 }
35406 if (ItemID.Sets.TrapSigned[item.type])
35407 {
35408 spriteBatch.Draw(TextureAssets.Wire.Value, vector3 + frame.Size().RotatedBy(num) * 0.45f * item.scale, new Microsoft.Xna.Framework.Rectangle(4, 58, 8, 8), currentColor, 0f, new Vector2(4f), 1f, SpriteEffects.None, 0f);
35409 }
35410 if (item.type == 3858)
35411 {
35412 spriteBatch.Draw(TextureAssets.GlowMask[233].Value, vector3, glowmaskFrame, new Microsoft.Xna.Framework.Color(255, 255, 255, 63) * 0.75f, num, glowmaskFrame.Size() / 2f, scale, SpriteEffects.None, 0f);
35413 }
35415 {
35416 Vector2 vector4 = new Vector2(-4f, -4f) * scale;
35417 Texture2D value = TextureAssets.Extra[258].Value;
35419 spriteBatch.Draw(value, vector3 + vector4 + frame.Size().RotatedBy(num) * 0.45f * item.scale, rectangle, currentColor, num, rectangle.Size() / 2f, 1f, SpriteEffects.None, 0f);
35420 }
35421 }
static double Abs(double value)
const double PI
Definition Math.cs:16
static Asset< Texture2D >[] GlowMask
static Asset< Texture2D >[] Item
static Asset< Texture2D >[] Extra
static Asset< Texture2D > Wire
static bool[] BossBag
Definition ItemID.cs:1123
static bool[] TrapSigned
Definition ItemID.cs:1040
static bool[] DrawUnsafeIndicator
Definition ItemID.cs:59
void DrawItem_GetBasics(Item item, int slot, out Texture2D texture, out Microsoft.Xna.Framework.Rectangle frame, out Microsoft.Xna.Framework.Rectangle glowmaskFrame)
Definition Main.cs:35184
static Item[] item
Definition Main.cs:1681
static SpriteBatch spriteBatch
Definition Main.cs:974
static int DiscoR
Definition Main.cs:1062
static Main instance
Definition Main.cs:283
static Vector2 screenPosition
Definition Main.cs:1715
static byte mouseTextColor
Definition Main.cs:1751
static int DiscoG
Definition Main.cs:1066
static int DiscoB
Definition Main.cs:1064
static UnifiedRandom rand
Definition Main.cs:1387
static bool gamePaused
Definition Main.cs:1072
static float GlobalTimeWrappedHourly
Definition Main.cs:405
static Dust[] dust
Definition Main.cs:1677
static void GetItemLight(ref Color currentColor, Item item, bool outInTheWorld=false)
Definition ItemSlot.cs:2899
static Color Transparent
Definition Color.cs:76

References System.Math.Abs(), Terraria.ID.ItemID.Sets.BossBag, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Terraria.Main.DrawItem_GetBasics(), Terraria.ID.ItemID.Sets.DrawUnsafeIndicator, Terraria.Main.dust, Terraria.GameContent.TextureAssets.Extra, Terraria.Main.gamePaused, Terraria.Lighting.GetColor(), Terraria.UI.ItemSlot.GetItemLight(), Terraria.Main.GlobalTimeWrappedHourly, Terraria.GameContent.TextureAssets.GlowMask, Terraria.Main.instance, Terraria.GameContent.TextureAssets.Item, Terraria.Main.item, Terraria.Main.mouseTextColor, Terraria.Dust.NewDust(), System.Math.PI, Terraria.Main.rand, Terraria.Main.screenPosition, Terraria.Main.spriteBatch, Microsoft.Xna.Framework.Color.Transparent, Terraria.ID.ItemID.Sets.TrapSigned, System.type, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Color.White, and Terraria.GameContent.TextureAssets.Wire.

Referenced by Terraria.Main.DrawItems().