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

◆ Transform()

void Terraria.NPC.Transform ( int newType)
inline

Definition at line 77913 of file NPC.cs.

77914 {
77915 if (Main.netMode != 1)
77916 {
77917 int num = extraValue;
77918 bool flag = false;
77919 if (value == 0f)
77920 {
77921 flag = true;
77922 }
77923 int[] array = new int[maxBuffs];
77924 int[] array2 = new int[maxBuffs];
77925 for (int i = 0; i < maxBuffs; i++)
77926 {
77927 array[i] = buffType[i];
77928 array2[i] = buffTime[i];
77929 }
77930 float num2 = shimmerTransparency;
77931 _ = height;
77932 int oldType = type;
77933 int num3 = life;
77934 int num4 = lifeMax;
77936 position.Y += height;
77937 int num5 = spriteDirection;
77942 TargetClosest();
77943 velocity = vector;
77944 position.Y -= height;
77945 for (int j = 0; j < maxBuffs; j++)
77946 {
77947 buffType[j] = array[j];
77948 buffTime[j] = array2[j];
77949 }
77950 if (flag)
77951 {
77952 value = 0f;
77953 }
77954 if (lifeMax == num4)
77955 {
77956 life = num3;
77957 }
77959 switch (newType)
77960 {
77961 case 107:
77962 case 108:
77963 case 124:
77964 case 353:
77965 case 369:
77966 case 550:
77967 case 588:
77968 case 679:
77969 case 680:
77970 case 683:
77971 case 684:
77972 UpdateHomeTileState(homeless: true, (int)(position.X + (float)(width / 2)) / 16, (int)(position.Y + (float)height) / 16);
77973 break;
77974 }
77975 extraValue = num;
77976 if (Main.netMode == 2)
77977 {
77978 netUpdate = true;
77979 NetMessage.SendData(23, -1, -1, null, whoAmI);
77980 NetMessage.SendData(54, -1, -1, null, whoAmI);
77981 }
77984 if (townNPC)
77985 {
77986 homeless = true;
77987 WorldGen.CheckAchievement_RealEstateAndTownSlimes();
77988 }
77989 altTexture = 0;
77990 }
77991 }
Vector2 velocity
Definition Entity.cs:16
Vector2 position
Definition Entity.cs:14
static void GiveTownUniqueDataToNPCsThatNeedIt(int Type, int nextNPC)
Definition NPC.cs:77728
int spriteDirection
Definition NPC.cs:517
static readonly int maxBuffs
Definition NPC.cs:211
int lifeMax
Definition NPC.cs:479
void TargetClosest(bool faceTarget=true)
Definition NPC.cs:69934
void UpdateHomeTileState(bool homeless, int x, int y)
Definition NPC.cs:46195
int[] buffTime
Definition NPC.cs:215
bool SpawnedFromStatue
Definition NPC.cs:85
int extraValue
Definition NPC.cs:525
float value
Definition NPC.cs:523
void SetDefaultsKeepPlayerInteraction(int Type)
Definition NPC.cs:2488
int type
Definition NPC.cs:445
int altTexture
Definition NPC.cs:99
void TransformVisuals(int oldType, int newType)
Definition NPC.cs:77816
float shimmerTransparency
Definition NPC.cs:207
bool homeless
Definition NPC.cs:541
int life
Definition NPC.cs:477
int[] buffType
Definition NPC.cs:213
bool netUpdate
Definition NPC.cs:507
bool townNPC
Definition NPC.cs:537

References System.array, Terraria.WorldGen.CheckAchievement_RealEstateAndTownSlimes(), Terraria.Main.netMode, Terraria.NetMessage.SendData(), System.type, and System.value.

Referenced by Terraria.NPC.AI(), Terraria.NPC.AI_000_TransformBoundNPC(), Terraria.NPC.AI_003_Fighters(), and Terraria.NPC.AI_007_TownEntities().