Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TileEntitiesManager.cs
Go to the documentation of this file.
3
5
7{
8 private int _nextEntityID;
9
11
12 private int AssignNewID()
13 {
14 return _nextEntityID++;
15 }
16
17 private bool InvalidEntityID(int id)
18 {
19 if (id >= 0)
20 {
21 return id >= _nextEntityID;
22 }
23 return true;
24 }
25
26 public void RegisterAll()
27 {
29 Register(new TEItemFrame());
33 Register(new TEHatRack());
36 }
37
38 public void Register(TileEntity entity)
39 {
40 int num = AssignNewID();
41 _types[num] = entity;
42 entity.RegisterTileEntityID(num);
43 }
44
45 public bool CheckValidTile(int id, int x, int y)
46 {
47 if (InvalidEntityID(id))
48 {
49 return false;
50 }
51 return _types[id].IsTileValidForEntity(x, y);
52 }
53
54 public void NetPlaceEntity(int id, int x, int y)
55 {
56 if (!InvalidEntityID(id) && _types[id].IsTileValidForEntity(x, y))
57 {
58 _types[id].NetPlaceEntityAttempt(x, y);
59 }
60 }
61
63 {
64 if (InvalidEntityID(id))
65 {
66 return null;
67 }
68 return _types[id].GenerateInstance();
69 }
70}
virtual void RegisterTileEntityID(int assignedID)