//FIXME this is a copy from NPCHandler move this out to the entity Manager !!
public Entity createPCComponents(EntityData e, VisibleModel visible) {
EntityManager em = Singleton.get().getEntityManager();
final Entity ent = em.createEntity(e.getObjectId());
PositioningComponent pos = new PositioningComponent();
L2JComponent l2j = new L2JComponent();
VisualComponent vis = new VisualComponent();
EnvironmentComponent env = new EnvironmentComponent();
TargetComponent tgt = new TargetComponent();
LoggingComponent log = new LoggingComponent();
em.addComponent(ent.getId(), env);
em.addComponent(ent.getId(), l2j);
em.addComponent(ent.getId(), pos);
em.addComponent(ent.getId(), vis);
em.addComponent(ent.getId(), tgt);
em.addComponent(ent.getId(), log);
//done here extra as in update values will be left untouched
pos.startPos.set(e.getX(), e.getY(), e.getZ());
pos.position.set(pos.startPos);
pos.goalPos.set(pos.position);
pos.walkSpeed = e.getWalkSpeed();
pos.runSpeed = e.getRunSpeed();
pos.running = e.isRunning();
pos.heading = e.getHeading();
pos.targetHeading = pos.heading;
pos.teleport = true;
vis.vis = visible;
visible.attachVisuals();
l2j.isPlayer = true;
em.setPlayerId(ent.getId());
l2j.l2jEntity = e;
ent.setLocalTranslation(pos.position);
ent.setLocalRotation(new Quaternion().fromAngleAxis(e.getHeading(), Vector3f.UNIT_Y));
ent.attachChild(visible);
//hook up of the terrain swapping @see SimpleTerrainManager
ent.addControl(new AbstractControl(){
@Override
public Control cloneForSpatial(Spatial spatial) {
return null;
}
@Override
protected void controlUpdate(float tpf) {
Singleton.get().getTerrainManager().update(ent.getLocalTranslation());
}
@Override
protected void controlRender(RenderManager rm, ViewPort vp) {
}}