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

◆ FindOwner()

void Terraria.Item.FindOwner ( int whoAmI)
inline

Definition at line 51681 of file Item.cs.

51682 {
51683 if (Main.netMode == 1 && shimmerTime > 0f)
51684 {
51685 keepTime = 0;
51686 }
51687 if (keepTime > 0)
51688 {
51689 return;
51690 }
51693 bool flag = true;
51694 if (type == 267 && ownIgnore != -1)
51695 {
51696 flag = false;
51697 }
51698 if (shimmerTime > 0f)
51699 {
51701 }
51702 else if (flag)
51703 {
51704 float num2 = NPC.sWidth;
51705 for (int i = 0; i < 255; i++)
51706 {
51707 if (ownIgnore == i)
51708 {
51709 continue;
51710 }
51711 Player player = Main.player[i];
51712 if (!player.active)
51713 {
51714 continue;
51715 }
51716 Player.ItemSpaceStatus status = player.ItemSpace(Main.item[whoAmI]);
51717 if (ItemLoader.CanPickup(Main.item[whoAmI], player) && player.CanPullItem(Main.item[whoAmI], status))
51718 {
51719 float num3 = Math.Abs(player.position.X + (float)(player.width / 2) - position.X - (float)(width / 2)) + Math.Abs(player.position.Y + (float)(player.height / 2) - position.Y - (float)height);
51720 num3 -= (float)player.GetItemGrabRange(Main.item[whoAmI]);
51721 if (num2 > num3)
51722 {
51723 num2 = num3;
51725 }
51726 }
51727 }
51728 }
51729 if (playerIndexTheItemIsReservedFor != num && ((num == Main.myPlayer && Main.netMode == 1) || (num == 255 && Main.netMode == 2) || (num != 255 && !Main.player[num].active)))
51730 {
51731 NetMessage.SendData(21, -1, -1, null, whoAmI);
51732 if (active)
51733 {
51734 NetMessage.SendData(22, -1, -1, null, whoAmI);
51735 }
51736 }
51737 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
Vector2 position
The position of this Entity in world coordinates.
Definition Entity.cs:28
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
bool active
If true, the Entity actually exists within the game world. Within the specific entity array,...
Definition Entity.cs:21
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
int playerIndexTheItemIsReservedFor
Definition Item.cs:578
float shimmerTime
Definition Item.cs:781
int ownIgnore
Definition Item.cs:334
int keepTime
Definition Item.cs:338
int type
The Item ID of this item. The Item ID is a unique number assigned to each Item loaded into the game....
Definition Item.cs:345
static bool CanPickup(Item item, Player player)
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26

References Terraria.Entity.active, Terraria.ModLoader.ItemLoader.CanPickup(), Terraria.Player.CanPullItem(), Terraria.Player.GetItemGrabRange(), Terraria.Entity.height, Terraria.Main.item, Terraria.Player.ItemSpace(), Terraria.Item.keepTime, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Item.ownIgnore, Terraria.Main.player, Terraria.Item.playerIndexTheItemIsReservedFor, Terraria.Entity.position, Terraria.NetMessage.SendData(), Terraria.Item.shimmerTime, Terraria.NPC.sWidth, Terraria.Item.type, Terraria.Entity.whoAmI, and Terraria.Entity.width.

+ Here is the call graph for this function: