Terraria v1.4.4.9
Terraria 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 33465 of file Projectile.cs.

33466 {
33467 if (Main.netMode == 1)
33468 {
33469 return;
33470 }
33471 bool flag = false;
33472 int num = -1;
33473 for (int i = 0; i < 40; i++)
33474 {
33475 Item item = theChest.item[i];
33476 if (item == null)
33477 {
33478 continue;
33479 }
33480 if (item.IsAir)
33481 {
33482 if (num == -1)
33483 {
33484 num = i;
33485 }
33486 }
33487 else if (item.type == 5356 && item.stack < item.maxStack)
33488 {
33489 flag = true;
33490 item.stack++;
33491 if (Main.netMode != 0)
33492 {
33493 NetMessage.SendData(32, -1, -1, null, chestIndex, i);
33494 }
33495 break;
33496 }
33497 }
33498 theChest.item[gasTrapIndex].stack--;
33499 if (theChest.item[gasTrapIndex].stack <= 0)
33500 {
33501 if (flag)
33502 {
33503 theChest.item[gasTrapIndex].TurnToAir();
33504 }
33505 else
33506 {
33507 flag = true;
33508 theChest.item[gasTrapIndex].ChangeItemType(5356);
33509 }
33510 }
33511 if (Main.netMode != 0)
33512 {
33513 NetMessage.SendData(32, -1, -1, null, chestIndex, gasTrapIndex);
33514 }
33515 if (!flag && num > -1)
33516 {
33517 flag = true;
33518 theChest.item[num].ChangeItemType(5356);
33519 if (Main.netMode != 0)
33520 {
33521 NetMessage.SendData(32, -1, -1, null, chestIndex, num);
33522 }
33523 }
33524 if (!flag)
33525 {
33527 }
33528 }

References System.item, Terraria.Main.netMode, Terraria.Item.NewItem(), Microsoft.Xna.Framework.Vector2.One, Terraria.NetMessage.SendData(), and System.source.