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

◆ UseGasTrapInChest()

static void Terraria.Projectile.UseGasTrapInChest ( int chestIndex,
Chest theChest,
int gasTrapIndex,
int gasOffsetX,
int gasOffsetY )
inlinestatic

Definition at line 42048 of file Projectile.cs.

42049 {
42050 //IL_0167: Unknown result type (might be due to invalid IL or missing references)
42051 //IL_0169: Unknown result type (might be due to invalid IL or missing references)
42052 if (Main.netMode == 1)
42053 {
42054 return;
42055 }
42056 bool flag = false;
42057 int num = -1;
42058 for (int i = 0; i < 40; i++)
42059 {
42060 Item item = theChest.item[i];
42061 if (item == null)
42062 {
42063 continue;
42064 }
42065 if (item.IsAir)
42066 {
42067 if (num == -1)
42068 {
42069 num = i;
42070 }
42071 }
42072 else if (item.type == 5356 && item.stack < item.maxStack)
42073 {
42074 flag = true;
42075 item.stack++;
42076 if (Main.netMode != 0)
42077 {
42078 NetMessage.SendData(32, -1, -1, null, chestIndex, i);
42079 }
42080 break;
42081 }
42082 }
42083 theChest.item[gasTrapIndex].stack--;
42084 if (theChest.item[gasTrapIndex].stack <= 0)
42085 {
42086 if (flag)
42087 {
42088 theChest.item[gasTrapIndex].TurnToAir();
42089 }
42090 else
42091 {
42092 flag = true;
42093 theChest.item[gasTrapIndex].ChangeItemType(5356);
42094 }
42095 }
42096 if (Main.netMode != 0)
42097 {
42098 NetMessage.SendData(32, -1, -1, null, chestIndex, gasTrapIndex);
42099 }
42100 if (!flag && num > -1)
42101 {
42102 flag = true;
42103 theChest.item[num].ChangeItemType(5356);
42104 if (Main.netMode != 0)
42105 {
42106 NetMessage.SendData(32, -1, -1, null, chestIndex, num);
42107 }
42108 }
42109 if (!flag)
42110 {
42111 Vector2 pos = default(Vector2);
42112 ((Vector2)(ref pos))._002Ector((float)(theChest.x * 16 + gasOffsetX), (float)(theChest.y * 16 + gasOffsetY));
42113 Item.NewItem(new EntitySource_OverfullChest(theChest.x, theChest.y, theChest, "GasTrap"), pos, Vector2.One, 5356);
42114 }
42115 }
Used when attempting to add an item to a chest, but the chest is full so it spills into the world....

References Terraria.Item.IsAir, Terraria.Item.maxStack, Terraria.Main.netMode, Terraria.Item.NewItem(), Terraria.NetMessage.SendData(), Terraria.Item.stack, and Terraria.Item.type.

+ Here is the call graph for this function: