TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ AI_007_TownEntities_TeleportToHome()

void Terraria.NPC.AI_007_TownEntities_TeleportToHome ( int homeFloorX,
int homeFloorY )
inlineprivate

Definition at line 59222 of file NPC.cs.

59223 {
59224 bool flag = false;
59225 for (int i = 0; i < 3; i++)
59226 {
59227 int num2 = homeFloorX + i switch
59228 {
59229 1 => -1,
59230 0 => 0,
59231 _ => 1,
59232 };
59233 if (type == 37 || !Collision.SolidTiles(num2 - 1, num2 + 1, homeFloorY - 3, homeFloorY - 1))
59234 {
59235 velocity.X = 0f;
59236 velocity.Y = 0f;
59237 position.X = num2 * 16 + 8 - width / 2;
59238 position.Y = (float)(homeFloorY * 16 - height) - 0.1f;
59239 netUpdate = true;
59241 flag = true;
59242 break;
59243 }
59244 }
59245 if (!flag)
59246 {
59247 homeless = true;
59248 WorldGen.QuickFindHome(whoAmI);
59249 }
59250 }
int whoAmI
The index of this Entity within its specific array. These arrays track the entities in the world....
Definition Entity.cs:16
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
int type
The NPC ID of this NPC. The NPC ID is a unique number assigned to each NPC loaded into the game....
Definition NPC.cs:990
bool homeless
Definition NPC.cs:1178
bool netUpdate
Definition NPC.cs:1130
void AI_007_TryForcingSitting(int homeFloorX, int homeFloorY)
Definition NPC.cs:56168

References Terraria.NPC.AI_007_TryForcingSitting(), Terraria.Entity.height, Terraria.NPC.homeless, Terraria.NPC.netUpdate, Terraria.WorldGen.QuickFindHome(), Terraria.Collision.SolidTiles(), Terraria.NPC.type, Terraria.Entity.whoAmI, and Terraria.Entity.width.

Referenced by Terraria.NPC.AI_007_TownEntities().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: