Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NPCWasNearPlayerTracker.cs
Go to the documentation of this file.
2using System.IO;
5using Terraria.ID;
6using Terraria.Net;
7
9
11{
12 private object _entryCreationLock = new object();
13
15
17
19
21 {
22 }
23
30
31 public void RegisterWasNearby(NPC npc)
32 {
36 {
38 }
39 if (Main.netMode == 2 && flag)
40 {
42 }
43 }
44
45 public void SetWasSeenDirectly(string persistentId)
46 {
48 {
50 }
51 }
52
53 public bool GetWasNearbyBefore(NPC npc)
54 {
57 }
58
63
64 public void Save(BinaryWriter writer)
65 {
67 {
68 writer.Write(_wasNearPlayer.Count);
69 foreach (string item in _wasNearPlayer)
70 {
71 writer.Write(item);
72 }
73 }
74 }
75
77 {
78 int num = reader.ReadInt32();
79 for (int i = 0; i < num; i++)
80 {
81 string item = reader.ReadString();
82 _wasNearPlayer.Add(item);
83 }
84 }
85
87 {
88 int num = reader.ReadInt32();
89 for (int i = 0; i < num; i++)
90 {
91 reader.ReadString();
92 }
93 }
94
101
102 public void ScanWorldForFinds()
103 {
105 for (int i = 0; i < 255; i++)
106 {
107 Player player = Main.player[i];
108 if (player.active)
109 {
111 }
112 }
113 for (int j = 0; j < 200; j++)
114 {
115 NPC nPC = Main.npc[j];
116 if (!nPC.active || !nPC.CountsAsACritter || _wasSeenNearPlayerByNetId.Contains(nPC.netID))
117 {
118 continue;
119 }
120 Rectangle hitbox = nPC.Hitbox;
121 for (int k = 0; k < _playerHitboxesForBestiary.Count; k++)
122 {
124 if (hitbox.Intersects(value))
125 {
128 }
129 }
130 }
131 }
132
134 {
135 foreach (string item in _wasNearPlayer)
136 {
137 if (ContentSamples.NpcNetIdsByPersistentIds.TryGetValue(item, out var value))
138 {
140 }
141 }
142 }
143}
void ICollection< T >. Add(T item)
Definition HashSet.cs:225
virtual string ReadString()
virtual int ReadInt32()
void ValidateWorld(BinaryReader reader, int gameVersionSaveWasMadeOn)
void Load(BinaryReader reader, int gameVersionSaveWasMadeOn)
static Dictionary< string, int > NpcNetIdsByPersistentIds
static int netMode
Definition Main.cs:2095
static NPC[] npc
Definition Main.cs:1685
static Player[] player
Definition Main.cs:1803
string GetBestiaryCreditId()
Definition NPC.cs:91802
int netID
Definition NPC.cs:531
static readonly NetManager Instance
Definition NetManager.cs:18
Rectangle HitboxForBestiaryNearbyCheck
Definition Player.cs:2831