NPC despawning

Every NPC that doesn't belong to Town NPCs will despawn in time.

Every player has two rectangles centered around themselves which is related to whether a despawnable NPC will despawn. These are the Active rectangle (greatly larger than screen), and Timer rectangle (not very large).

When a despawnable NPC is inside one of the Timer rectangles of players, it won't despawn at all. When it is outside all player's Timer rectangles, its dying timer will be started until it goes inside a Timer rectangle and resets the timer. The timer counts down from 12.5s (750 ticks, each tick being 1/60 second)

When a despawnable NPC is inside a player's Active rectangle, it is counted as active for the player and it will be counted when the game spawning NPCs.

On following occasions will a despawnable NPC despawn:


 * The NPC is not active for any player and it is not a part of a larger Monster (such as boss with multiple parts, the worms' parts, etc.)


 * The timer has counted to zero. (Which causes a bug that makes a boss with multiple sections will sometimes partly despawn, such as Skeletron)

The information of rectangles' sizes:


 * Active rectangle: 504*283.5 blocks (the 1920*1080 screen multiplied with 4.2*4.2) (much larger than the spawning rectangle, which is 168*94)


 * Timer rectangle: 120*67.5 blocks (the 1920*1080 screen plus the monster's size, a bit smaller than safe zone in spawning mechanics)