-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileMod.cs
More file actions
86 lines (83 loc) · 3.65 KB
/
Copy pathTileMod.cs
File metadata and controls
86 lines (83 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Terraria.ModLoader;
using Terraria;
using Terraria.ID;
using Microsoft.Xna.Framework;
namespace CastleGenerator
{
public class TileMod : GlobalTile
{
public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
{
if (WorldMod.IsCastle)
return false;
return base.CanKillTile(i, j, type, ref blockDamaged);
}
public override void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
{
if (WorldMod.IsCastle)
noItem = true;
}
public override void RightClick(int i, int j, int type)
{
if (!WorldMod.IsCastle)
return;
Tile tile = Main.tile[i, j];
switch (type)
{
case TileID.Containers:
case TileID.Containers2:
if(tile.TileFrameY < 36)
{
PlayerMod player = Main.LocalPlayer.GetModPlayer<PlayerMod>();
Point TileBottom = new Point(i, j);
if (tile.TileFrameX % (1f / 18) == 0)
TileBottom.X++;
if (tile.TileFrameY % (1f / 18) == 0)
TileBottom.Y++;
if (!player.pwi.TreasuresGot.Contains(TileBottom))
{
bool HasInventorySpace = false;
for(int e = 0; e < 50; e++)
{
if(player.Player.inventory[e].type == 0)
{
HasInventorySpace = true;
break;
}
}
if (!HasInventorySpace)
{
CombatText.NewText(player.Player.getRect(), Color.Red, "Inventory is full!");
}
else
{
RoomInfo room = player.MyRoom;
if (room == null) return;
Room baseRoom = room.GetRoom;
foreach (RoomInfo.TreasureSlot treasure in room.Treasures)
{
int TreasureX = room.RoomX + baseRoom.TreasureSpawnPosition[treasure.Slot].PositionX - baseRoom.RoomTileStartX;
int TreasureY = room.RoomY + baseRoom.TreasureSpawnPosition[treasure.Slot].PositionY - baseRoom.RoomTileStartY;
if (TreasureX == TileBottom.X && TreasureY == TileBottom.Y)
{
Item.NewItem(Item.GetSource_NaturalSpawn(), player.Player.Center, treasure.ItemID);
break;
}
}
player.pwi.TreasuresGot.Add(TileBottom);
}
}
}
break;
case TileID.Beds:
if (!Player.IsHoveringOverABottomSideOfABed(i, j))
{
int SpawnX = ((tile.TileFrameX % 72) - 36) / 18 + i,
SpawnY = (36 - (tile.TileFrameY % 36)) / 18 + j - 2;
Main.LocalPlayer.ChangeSpawn(SpawnX, SpawnY);
}
break;
}
}
}
}