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

◆ CombineWithNearbyItems()

void Terraria.Item.CombineWithNearbyItems ( int myItemIndex)
inlineprivate

Definition at line 49142 of file Item.cs.

49143 {
49145 {
49146 return;
49147 }
49148 for (int i = myItemIndex + 1; i < 400; i++)
49149 {
49150 Item item = Main.item[i];
49151 if (!item.active || item.type != type || item.shimmered != shimmered || item.stack <= 0 || item.playerIndexTheItemIsReservedFor != playerIndexTheItemIsReservedFor)
49152 {
49153 continue;
49154 }
49155 float num = 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)));
49156 int num2 = 30;
49157 if ((double)numberOfNewItems > 40.0)
49158 {
49159 num2 *= 2;
49160 }
49161 if ((double)numberOfNewItems > 80.0)
49162 {
49163 num2 *= 2;
49164 }
49165 if ((double)numberOfNewItems > 120.0)
49166 {
49167 num2 *= 2;
49168 }
49169 if ((double)numberOfNewItems > 160.0)
49170 {
49171 num2 *= 2;
49172 }
49173 if ((double)numberOfNewItems > 200.0)
49174 {
49175 num2 *= 2;
49176 }
49177 if ((double)numberOfNewItems > 240.0)
49178 {
49179 num2 *= 2;
49180 }
49181 if (num < (float)num2)
49182 {
49183 position = (position + item.position) / 2f;
49184 velocity = (velocity + item.velocity) / 2f;
49185 int num3 = item.stack;
49186 if (num3 > maxStack - stack)
49187 {
49188 num3 = maxStack - stack;
49189 }
49190 item.stack -= num3;
49191 stack += num3;
49192 if (item.stack <= 0)
49193 {
49194 item.SetDefaults();
49195 item.active = false;
49196 }
49197 if (Main.netMode != 0 && playerIndexTheItemIsReservedFor == Main.myPlayer)
49198 {
49199 NetMessage.SendData(21, -1, -1, null, myItemIndex);
49200 NetMessage.SendData(21, -1, -1, null, i);
49201 }
49202 }
49203 }
49204 }
static double Abs(double value)
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static int numberOfNewItems
Definition Item.cs:320
int stack
Definition Item.cs:149
int maxStack
Definition Item.cs:151
bool CanCombineStackInWorld()
Definition Item.cs:49206
int playerIndexTheItemIsReservedFor
Definition Item.cs:231
bool shimmered
Definition Item.cs:322

References System.Math.Abs(), Terraria.Item.CanCombineStackInWorld(), Terraria.Entity.height, System.item, 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.shimmered, Terraria.Item.stack, Terraria.Item.type, Terraria.Entity.velocity, Terraria.Entity.width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.Item.TryCombiningIntoNearbyItems().