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

◆ ItemCheck_ApplyHoldStyle()

void Terraria.Player.ItemCheck_ApplyHoldStyle ( float mountOffset,
Item sItem,
Rectangle heldItemFrame )
inlineprivate

Definition at line 47352 of file Player.cs.

47353 {
47354 if (isPettingAnimal)
47355 {
47356 int num = miscCounter % 14 / 7;
47357 CompositeArmStretchAmount stretch = CompositeArmStretchAmount.ThreeQuarters;
47358 if (num == 1)
47359 {
47360 stretch = CompositeArmStretchAmount.Full;
47361 }
47362 float num2 = 0.3f;
47364 {
47365 num2 = 0.2f;
47366 }
47367 SetCompositeArmBack(enabled: true, stretch, (float)Math.PI * -2f * num2 * (float)direction);
47368 }
47370 {
47371 return;
47372 }
47373 if (sItem.holdStyle == 1 && !pulley)
47374 {
47375 if (Main.dedServ)
47376 {
47377 itemLocation.X = position.X + (float)width * 0.5f + 20f * (float)direction;
47378 }
47379 else if (sItem.type == 930)
47380 {
47381 itemLocation.X = position.X + (float)(width / 2) * 0.5f - 12f - (float)(2 * direction);
47382 float x = position.X + (float)(width / 2) + (float)(38 * direction);
47383 if (direction == 1)
47384 {
47385 x -= 10f;
47386 }
47387 float y = MountedCenter.Y - 4f * gravDir;
47388 if (gravDir == -1f)
47389 {
47390 y -= 8f;
47391 }
47393 int num3 = 0;
47394 for (int i = 54; i < 58; i++)
47395 {
47396 if (inventory[i].stack > 0 && inventory[i].ammo == 931)
47397 {
47398 num3 = inventory[i].type;
47399 break;
47400 }
47401 }
47402 if (num3 == 0)
47403 {
47404 for (int j = 0; j < 54; j++)
47405 {
47406 if (inventory[j].stack > 0 && inventory[j].ammo == 931)
47407 {
47408 num3 = inventory[j].type;
47409 break;
47410 }
47411 }
47412 }
47413 switch (num3)
47414 {
47415 case 931:
47416 num3 = 127;
47417 break;
47418 case 1614:
47419 num3 = 187;
47420 break;
47421 case 5377:
47422 num3 = 169;
47423 break;
47424 case 5378:
47425 num3 = 75;
47426 break;
47427 case 5379:
47428 num3 = 66;
47429 break;
47430 case 5380:
47431 num3 = 310;
47432 break;
47433 }
47434 if (num3 > 0)
47435 {
47436 int num4 = Dust.NewDust(new Vector2(x, y + gfxOffY), 6, 6, num3, 0f, 0f, 100, default(Color), 1.6f);
47437 Main.dust[num4].noGravity = true;
47438 Main.dust[num4].velocity.Y -= 4f * gravDir;
47439 if (num3 == 66)
47440 {
47441 Main.dust[num4].color = Main.hslToRgb(Main.GlobalTimeWrappedHourly * 0.6f % 1f, 1f, 0.5f);
47442 Main.dust[num4].scale *= 0.5f;
47443 Main.dust[num4].velocity *= 0.75f;
47444 }
47445 }
47446 }
47447 else if (sItem.type == 968)
47448 {
47449 itemLocation.X = position.X + (float)width * 0.5f + (float)(8 * direction);
47450 if (whoAmI == Main.myPlayer)
47451 {
47452 int num5 = (int)(itemLocation.X + (float)heldItemFrame.Width * 0.8f * (float)direction) / 16;
47453 int num6 = (int)(itemLocation.Y + mountOffset + (float)(heldItemFrame.Height / 2)) / 16;
47454 if (Main.tile[num5, num6] == null)
47455 {
47456 Main.tile[num5, num6] = new Tile();
47457 }
47458 if (Main.tile[num5, num6].active() && Main.tile[num5, num6].type == 215 && Main.tile[num5, num6].frameY < 54)
47459 {
47460 miscTimer++;
47461 if (Main.rand.Next(5) == 0)
47462 {
47463 miscTimer++;
47464 }
47465 if (miscTimer > 900)
47466 {
47467 miscTimer = 0;
47468 sItem.SetDefaults(969);
47469 if (selectedItem == 58)
47470 {
47471 Main.mouseItem.SetDefaults(969);
47472 }
47473 for (int k = 0; k < 58; k++)
47474 {
47475 if (inventory[k].type == sItem.type && k != selectedItem && inventory[k].stack < inventory[k].maxStack)
47476 {
47478 inventory[k].stack++;
47479 sItem.SetDefaults();
47480 if (selectedItem == 58)
47481 {
47482 Main.mouseItem.SetDefaults();
47483 }
47484 }
47485 }
47486 }
47487 }
47488 else
47489 {
47490 miscTimer = 0;
47491 }
47492 }
47493 }
47494 else if (sItem.type == 856)
47495 {
47496 itemLocation.X = position.X + (float)width * 0.5f + (float)(4 * direction);
47497 }
47498 else if (sItem.fishingPole > 0)
47499 {
47500 itemLocation.X = position.X + (float)width * 0.5f + (float)heldItemFrame.Width * 0.18f * (float)direction;
47501 }
47502 else
47503 {
47504 itemLocation.X = position.X + (float)width * 0.5f + ((float)heldItemFrame.Width * 0.5f + 2f) * (float)direction;
47505 if (sItem.type == 282 || sItem.type == 286 || sItem.type == 3112 || sItem.type == 4776)
47506 {
47507 itemLocation.X -= direction * 2;
47508 itemLocation.Y += 4f;
47509 }
47510 else if (sItem.type == 3002)
47511 {
47512 itemLocation.X -= 4 * direction;
47513 itemLocation.Y += 2f;
47514 }
47515 }
47516 itemLocation.Y = position.Y + 24f + mountOffset;
47517 if (sItem.type == 856)
47518 {
47519 itemLocation.Y = position.Y + 34f + mountOffset;
47520 }
47521 if (sItem.type == 930)
47522 {
47523 itemLocation.Y = position.Y + 9f + mountOffset;
47524 }
47525 if (sItem.fishingPole > 0)
47526 {
47527 itemLocation.Y += 4f;
47528 }
47529 else if (sItem.type == 3476)
47530 {
47531 itemLocation.X = base.Center.X + (float)(14 * direction);
47532 itemLocation.Y = MountedCenter.Y;
47533 }
47534 else if (sItem.type == 3779)
47535 {
47536 itemLocation.X = base.Center.X + (float)(6 * direction);
47537 itemLocation.Y = MountedCenter.Y + 6f;
47538 }
47539 else if (sItem.type == 4952)
47540 {
47541 itemLocation.X = base.Center.X + (float)(2 * direction);
47542 itemLocation.Y = MountedCenter.Y + 26f;
47543 }
47544 else if (sItem.type == 353)
47545 {
47546 itemLocation.X = base.Center.X + (float)(6 * direction);
47547 itemLocation.Y = MountedCenter.Y + 11f;
47548 }
47549 else if (ItemID.Sets.IsFood[sItem.type])
47550 {
47551 itemLocation.X = base.Center.X + (float)(4 * direction);
47552 itemLocation.Y = MountedCenter.Y + (float)(heldItemFrame.Height / 2);
47553 }
47554 else if (sItem.type == 4049 && Main.rand.Next(4) == 0)
47555 {
47556 Dust dust = Dust.NewDustPerfect(base.Center + new Vector2(direction * 23, gravDir * 6f), 31, Vector2.Zero, 127, default(Color), 0.7f);
47557 dust.noGravity = true;
47558 dust.velocity = Main.rand.NextVector2Circular(1f, 1f) + new Vector2(0f, -1f);
47559 }
47560 itemRotation = 0f;
47561 if (gravDir == -1f)
47562 {
47564 itemLocation.Y = position.Y + (float)height + (position.Y - itemLocation.Y) + mountOffset;
47565 if (sItem.type == 930)
47566 {
47567 itemLocation.Y -= 24f;
47568 }
47569 }
47570 }
47571 else if (sItem.holdStyle == 2 && !pulley)
47572 {
47573 if (sItem.type == 946 || sItem.type == 4707)
47574 {
47575 itemRotation = 0f;
47576 itemLocation.X = position.X + (float)width * 0.5f - (float)(16 * direction);
47577 itemLocation.Y = position.Y + 22f + mountOffset;
47578 fallStart = (int)(position.Y / 16f);
47579 if (gravDir == -1f)
47580 {
47582 itemLocation.Y = position.Y + (float)height + (position.Y - itemLocation.Y);
47583 if (velocity.Y < -2f && !controlDown)
47584 {
47585 velocity.Y = -2f;
47586 }
47587 }
47588 else if (velocity.Y > 2f && !controlDown)
47589 {
47590 velocity.Y = 2f;
47591 }
47592 }
47593 else
47594 {
47595 itemLocation.X = position.X + (float)width * 0.5f + (float)(6 * direction);
47596 itemLocation.Y = position.Y + 16f + mountOffset;
47597 itemRotation = 0.79f * (float)(-direction);
47598 if (gravDir == -1f)
47599 {
47601 itemLocation.Y = position.Y + (float)height + (position.Y - itemLocation.Y);
47602 }
47603 }
47604 }
47605 else if (sItem.holdStyle == 3 && !pulley)
47606 {
47607 if (!Main.dedServ)
47608 {
47609 itemLocation.X = position.X + (float)width * 0.5f - (float)heldItemFrame.Width * 0.5f - (float)(direction * 2);
47610 itemLocation.Y = MountedCenter.Y - (float)heldItemFrame.Height * 0.5f;
47611 itemRotation = 0f;
47612 }
47613 }
47614 else if (sItem.holdStyle == 4)
47615 {
47616 if (!Main.dedServ)
47617 {
47618 float num7 = new Vector2(10 * direction, 10f).ToRotation() + (float)Math.PI / 4f;
47620 if (direction == -1)
47621 {
47622 itemRotation += (float)Math.PI / 2f;
47623 }
47624 CompositeArmStretchAmount stretch2 = CompositeArmStretchAmount.Full;
47625 CompositeArmStretchAmount stretch3 = CompositeArmStretchAmount.ThreeQuarters;
47626 float num8 = -(float)Math.PI / 10f;
47627 if (direction == -1)
47628 {
47629 num8 *= -1f;
47630 }
47631 float num9 = itemRotation - (float)Math.PI / 4f + (float)Math.PI;
47632 if (direction == 1)
47633 {
47634 num9 += (float)Math.PI / 2f;
47635 }
47636 float rotation = num9 + num8;
47637 float rotation2 = num9 - num8;
47638 Vector2 vector = (num9 + (float)Math.PI / 2f).ToRotationVector2() * 2f;
47639 itemLocation = MountedCenter.Floor() + vector;
47640 SetCompositeArmFront(enabled: true, stretch2, rotation);
47643 }
47644 }
47645 else if (sItem.holdStyle == 5 && !pulley)
47646 {
47647 if (!Main.dedServ)
47648 {
47649 itemRotation = 0f;
47650 itemLocation.X = base.Center.X - (float)(8 * direction);
47651 itemLocation.Y = position.Y + 40f + mountOffset;
47652 Vector2 vector2 = Main.OffsetsPlayerHeadgear[bodyFrame.Y / 56];
47654 CompositeArmStretchAmount stretch4 = CompositeArmStretchAmount.Quarter;
47655 SetCompositeArmBack(enabled: true, stretch4, -(float)Math.PI / 4f * (float)direction);
47656 CompositeArmStretchAmount stretch5 = CompositeArmStretchAmount.Full;
47657 SetCompositeArmFront(enabled: true, stretch5, -0.39269912f * (float)direction);
47659 }
47660 }
47661 else if (sItem.holdStyle == 6 && !pulley && !Main.dedServ)
47662 {
47663 itemRotation = 0f;
47664 itemLocation.X = base.Center.X + (float)(8 * direction);
47665 itemLocation.Y = position.Y + 40f + mountOffset - 2f;
47666 Vector2 vector3 = Main.OffsetsPlayerHeadgear[bodyFrame.Y / 56];
47668 CompositeArmStretchAmount stretch6 = CompositeArmStretchAmount.ThreeQuarters;
47669 SetCompositeArmBack(enabled: true, stretch6, (float)Math.PI * -3f / 5f * (float)direction);
47671 }
47672 }
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static bool[] IsFood
Definition ItemID.cs:233
int stack
Definition Item.cs:149
int maxStack
Definition Item.cs:151
void RotateRelativePoint(ref float x, ref float y)
Definition Player.cs:3602
float itemRotation
Definition Player.cs:1177
void SetCompositeArmBack(bool enabled, CompositeArmStretchAmount stretch, float rotation)
Definition Player.cs:3716
Vector2 MountedCenter
Definition Player.cs:2853
bool isPettingAnimal
Definition Player.cs:2459
void FlipItemLocationAndRotationForGravity()
Definition Player.cs:48454
void SetCompositeArmFront(bool enabled, CompositeArmStretchAmount stretch, float rotation)
Definition Player.cs:3707
bool isTheAnimalBeingPetSmall
Definition Player.cs:2461
Vector2 itemLocation
Definition Player.cs:1183
Item[] inventory
Definition Player.cs:1257
bool CanVisuallyHoldItem(Item item)
Definition Player.cs:47316

References Terraria.Main.dedServ, Terraria.Main.dust, Terraria.Main.GlobalTimeWrappedHourly, Terraria.Main.hslToRgb(), Terraria.ID.ItemID.Sets.IsFood, Terraria.Item.maxStack, Terraria.Main.mouseItem, Terraria.Main.myPlayer, Terraria.Dust.NewDust(), Terraria.Dust.NewDustPerfect(), Terraria.Main.OffsetsPlayerHeadgear, System.Math.PI, Terraria.Audio.SoundEngine.PlaySound(), Terraria.Main.rand, Terraria.Item.stack, Terraria.DataStructures.Tile, Terraria.Main.tile, System.type, Terraria.Item.type, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.