AyraHikari
Terrarian
Hello, how to change texture file at AI() code?
For example, when NPC walk the texture is NPC_walk.png
But when NPC is become something for example offensive mode in AI() code,
They should change texture to NPC_attack.png.
But since Texture code is read only, i can't change that.
I tried with this code, but it not override the current texture
The AI() code should be like this, and i expect work, but it got error Texture is read only
For example, when NPC walk the texture is NPC_walk.png
C#:
public override string Texture => "NPCs/NPC_walk";
But when NPC is become something for example offensive mode in AI() code,
They should change texture to NPC_attack.png.
But since Texture code is read only, i can't change that.
I tried with this code, but it not override the current texture
C#:
texture = mod.GetTexture("NPCs/NPC_attack");
spriteBatch.Draw(texture, npc.Center, null, Color.White, 0f, new Vector2(16f, 16f), 1f, SpriteEffects.None, 0f);
The AI() code should be like this, and i expect work, but it got error Texture is read only
C:
public override bool AI() {
if (npc.ai[0] == 0) {
Texture = "NPCs/NPC_walk";
Main.npcFrameCount[npc.type] = 9;
}
else if (npc.ai[0] == 1) {
Texture = "NPCs/NPC_attack";
Main.npcFrameCount[npc.type] = 6;
}
else if (npc.ai[0] == 2) {
Texture = "NPCs/NPC_magic";
Main.npcFrameCount[npc.type] = 7;
}
else if (npc.ai[0] == 3) {
Texture = "NPCs/NPC_defense";
Main.npcFrameCount[npc.type] = 4;
}
return true;
}
Last edited: