[Elvarg/MistPS] Npc facing
I'm spawning npcs in the npc spawns json but is there a way to get them to face a certain way?
Code:
package com.elvarg.definitions;
import com.elvarg.GameConstants;
import com.elvarg.util.JsonLoader;
import com.elvarg.world.World;
import com.elvarg.world.entity.impl.npc.NPC;
import com.elvarg.world.entity.impl.npc.bots.NPCBotHandler;
import com.elvarg.world.entity.impl.npc.bots.impl.RuneMainBot;
import com.elvarg.world.model.Position;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
/**
* Represents Npc spawns.
* @author Professor Oak
*
*/
public class NpcSpawnsDefinition {
/**
* Parses the npc spawns
* @return
*/
public static JsonLoader parse() {
return new JsonLoader() {
@Override
public void load(JsonObject reader, Gson builder) {
int npcId = reader.get("npcId").getAsInt();
int x = reader.get("x").getAsInt();
int y = reader.get("y").getAsInt();
int z = 0;
int face = 0;
if(reader.has("z")) {
z = reader.get("z").getAsInt();
}
if(reader.has("face")) {
face = reader.get("face").getAsInt();
}
//Spawn npc
World.getNpcAddQueue().add(new NPC(npcId, new Position(x, y, z), face));
}
@Override
public String filePath() {
return GameConstants.DEFINITIONS_DIRECTORY + "npc_spawns.json";
}
};
}
}
Code:
private int face;
/**
* Gets the NPC's current face direction.
* @return face.
*/
public int getFace() {
return face;
}
public void setFace(int face) {
this.face = face;
}
This is in the NPC class
Code:
public NPC(int id, Position position, int face) {
super(position);
this.id = id;
this.spawnPosition = position;
this.face = face;
setHitpoints(getDefinition().getHitpoints());
NPCBotHandler.assignBotHandler(this);
CombatFactory.assignCombatMethod(this);
}
Code:
{
"npcId": 1,
"x": 3200,
"y": 3200,
"face": 2
},
{
"npcId": 1,
"x": 3600,
"y": 3600,
"face": 1
},
What am I missing?