Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TownRoomManager.cs
Go to the documentation of this file.
1using System;
3using System.IO;
5using Terraria.ID;
6
8
9public class TownRoomManager
10{
11 public static object EntityCreationLock = new object();
12
14
15 private bool[] _hasRoom = new bool[NPCID.Count];
16
17 public void AddOccupantsToList(int x, int y, List<int> occupantsList)
18 {
20 }
21
22 public void AddOccupantsToList(Point tilePosition, List<int> occupants)
23 {
25 {
26 if (roomLocationPair.Item2 == tilePosition)
27 {
29 }
30 }
31 }
32
33 public bool HasRoomQuick(int npcID)
34 {
35 return _hasRoom[npcID];
36 }
37
39 {
40 if (!_hasRoom[npcID])
41 {
42 roomPosition = new Point(0, 0);
43 return false;
44 }
46 {
47 if (roomLocationPair.Item1 == npcID)
48 {
50 return true;
51 }
52 }
53 roomPosition = new Point(0, 0);
54 return false;
55 }
56
57 public void SetRoom(int npcID, int x, int y)
58 {
59 _hasRoom[npcID] = true;
60 SetRoom(npcID, new Point(x, y));
61 }
62
63 public void SetRoom(int npcID, Point pt)
64 {
66 {
69 }
70 }
71
72 public void KickOut(NPC n)
73 {
74 KickOut(n.type);
75 _hasRoom[n.type] = false;
76 }
77
78 public void KickOut(int npcType)
79 {
81 {
83 }
84 }
85
86 public void DisplayRooms()
87 {
89 {
90 Dust.QuickDust(roomLocationPair.Item2, Main.hslToRgb((float)roomLocationPair.Item1 * 0.05f % 1f, 1f, 0.5f));
91 }
92 }
93
95 {
97 {
100 {
101 writer.Write(roomLocationPair.Item1);
102 writer.Write(roomLocationPair.Item2.X);
103 writer.Write(roomLocationPair.Item2.Y);
104 }
105 }
106 }
107
108 public void Load(BinaryReader reader)
109 {
110 Clear();
111 int num = reader.ReadInt32();
112 for (int i = 0; i < num; i++)
113 {
114 int num2 = reader.ReadInt32();
115 Point item = new Point(reader.ReadInt32(), reader.ReadInt32());
117 _hasRoom[num2] = true;
118 }
119 }
120
121 public void Clear()
122 {
124 for (int i = 0; i < _hasRoom.Length; i++)
125 {
126 _hasRoom[i] = false;
127 }
128 }
129
131 {
132 byte result = 0;
133 if (n.homeless)
134 {
135 result = 1;
136 }
137 else if (HasRoomQuick(n.type))
138 {
139 result = 2;
140 }
141 return result;
142 }
143
145 {
147 {
148 return true;
149 }
151 }
152
154 {
155 return npc1.housingCategory != npc2.housingCategory;
156 }
157
162}
void Add(TKey key, TValue value)
int RemoveAll(Predicate< T > match)
Definition List.cs:789
virtual int ReadInt32()
static Dust QuickDust(int x, int y, Color color)
Definition Dust.cs:263
void AddOccupantsToList(Point tilePosition, List< int > occupants)
void SetRoom(int npcID, Point pt)
bool CanNPCsLiveWithEachOther(int npc1ByType, NPC npc2)
bool CanNPCsLiveWithEachOther(NPC npc1, NPC npc2)
bool HasRoom(int npcID, out Point roomPosition)
void SetRoom(int npcID, int x, int y)
List< Tuple< int, Point > > _roomLocationPairs
void AddOccupantsToList(int x, int y, List< int > occupantsList)
bool CanNPCsLiveWithEachOther_ShopHelper(NPC npc1, NPC npc2)
static Dictionary< int, NPC > NpcsByNetId
static readonly short Count
Definition NPCID.cs:11744
static Microsoft.Xna.Framework.Color hslToRgb(Vector3 hslVector)
Definition Main.cs:44913