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

◆ CombineWithNearbyItems()

void Terraria.Item.CombineWithNearbyItems ( int myItemIndex)
inlineprivate

Definition at line 50866 of file Item.cs.

50867 {
50868 //IL_0175: Unknown result type (might be due to invalid IL or missing references)
50869 //IL_017b: Unknown result type (might be due to invalid IL or missing references)
50870 //IL_0180: Unknown result type (might be due to invalid IL or missing references)
50871 //IL_018a: Unknown result type (might be due to invalid IL or missing references)
50872 //IL_018f: Unknown result type (might be due to invalid IL or missing references)
50873 //IL_0196: Unknown result type (might be due to invalid IL or missing references)
50874 //IL_019c: Unknown result type (might be due to invalid IL or missing references)
50875 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
50876 //IL_01ab: Unknown result type (might be due to invalid IL or missing references)
50877 //IL_01b0: Unknown result type (might be due to invalid IL or missing references)
50879 {
50880 return;
50881 }
50882 for (int i = myItemIndex + 1; i < 400; i++)
50883 {
50884 Item item = Main.item[i];
50885 if (!item.active || item.type != type || item.shimmered != shimmered || item.stack <= 0 || item.playerIndexTheItemIsReservedFor != playerIndexTheItemIsReservedFor)
50886 {
50887 continue;
50888 }
50889 float num3 = Math.Abs(position.X + (float)(width / 2) - (item.position.X + (float)(item.width / 2))) + Math.Abs(position.Y + (float)(height / 2) - (item.position.Y + (float)(item.height / 2)));
50890 int num2 = 30;
50891 if ((double)numberOfNewItems > 40.0)
50892 {
50893 num2 *= 2;
50894 }
50895 if ((double)numberOfNewItems > 80.0)
50896 {
50897 num2 *= 2;
50898 }
50899 if ((double)numberOfNewItems > 120.0)
50900 {
50901 num2 *= 2;
50902 }
50903 if ((double)numberOfNewItems > 160.0)
50904 {
50905 num2 *= 2;
50906 }
50907 if ((double)numberOfNewItems > 200.0)
50908 {
50909 num2 *= 2;
50910 }
50911 if ((double)numberOfNewItems > 240.0)
50912 {
50913 num2 *= 2;
50914 }
50915 if (num3 < (float)num2 && ItemLoader.CanStack(this, item) && ItemLoader.CanStackInWorld(this, item))
50916 {
50917 position = (position + item.position) / 2f;
50918 velocity = (velocity + item.velocity) / 2f;
50919 ItemLoader.StackItems(this, item, out var _);
50920 if (item.stack <= 0)
50921 {
50922 item.SetDefaults();
50923 item.active = false;
50924 }
50925 if (Main.netMode != 0 && playerIndexTheItemIsReservedFor == Main.myPlayer)
50926 {
50927 NetMessage.SendData(21, -1, -1, null, myItemIndex);
50928 NetMessage.SendData(21, -1, -1, null, i);
50929 }
50930 }
50931 }
50932 }
Vector2 velocity
The velocity of this Entity in world coordinates per tick.
Definition Entity.cs:33
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
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static int numberOfNewItems
Definition Item.cs:777
int stack
The current stack of the item. F:Terraria.Item.maxStack indicates the max possible stack.
Definition Item.cs:396
int maxStack
The maximum number of items that can be contained within a single stack. F:Terraria....
Definition Item.cs:402
bool CanCombineStackInWorld()
Definition Item.cs:50934
int playerIndexTheItemIsReservedFor
Definition Item.cs:578
bool shimmered
Definition Item.cs:779
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 void StackItems(Item destination, Item source, out int numTransferred, bool infiniteSource=false, int? numToTransfer=null)
Stacks destination onto source This method should not be called unless M:Terraria....
static bool CanStackInWorld(Item destination, Item source)
Calls all GlobalItem.CanStackInWorld hooks until one returns false then ModItem.CanStackInWorld....
static bool CanStack(Item destination, Item source)
Returns false if item prefixes don't match. Then calls all GlobalItem.CanStack hooks until one return...
This serves as the central class from which item-related functions are carried out....
Definition ItemLoader.cs:26

References Terraria.Entity.active, Terraria.Item.CanCombineStackInWorld(), Terraria.ModLoader.ItemLoader.CanStack(), Terraria.ModLoader.ItemLoader.CanStackInWorld(), Terraria.Entity.height, Terraria.Main.item, Terraria.Item.maxStack, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Item.numberOfNewItems, Terraria.Item.playerIndexTheItemIsReservedFor, Terraria.Entity.position, Terraria.NetMessage.SendData(), Terraria.Item.SetDefaults(), Terraria.Item.shimmered, Terraria.Item.stack, Terraria.ModLoader.ItemLoader.StackItems(), Terraria.Item.type, Terraria.Entity.velocity, and Terraria.Entity.width.

Referenced by Terraria.Item.TryCombiningIntoNearbyItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: