public void draw() { // Clear The Screen And The Depth Buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); if (camera != null) { camera.updatePosition(); } else { camera = (Camera) object_list.getItem(Camera.CAMERA_NAME); if (camera != null) { camera.updatePosition(); } else { System.out.println("WARNING: Tried to draw without camera set..."); return; } } // Draw the 3d stuff for (Entity ent : object_list.getEntitiesAndSubEntities()) { Boolean should_draw = (Boolean) ent.getProperty(Entity.SHOULD_DRAW); if (should_draw == null) should_draw = false; if (should_draw) ent.drawProgrammablePipe(); } // Draw the window manager stuff if (window_manager != null) window_manager.draw(); Display.update(); }
public List<Npc> getNpcsWithId(int id) { List<Npc> npcs = new ArrayList<Npc>(); for (Entity e : entitiesOnLevel) { if (e.getClass() == Npc.class && e.Id() == id) { npcs.add((Npc) e); } } return npcs; }
public Npc getNpcWithId(int id) { Npc npc = null; for (Entity e : entitiesOnLevel) { if (e.getClass() == Npc.class && e.Id() == id) { npc = (Npc) e; } } return npc; }
public List<Mob> getMobsWithId(int id) { List<Mob> mobs = new ArrayList<Mob>(); for (Entity e : entitiesOnLevel) { if (e.getClass() == Mob.class && e.Id() == id) { mobs.add((Mob) e); } } return mobs; }
public Player getPlayerNamed(String name) throws PlayerNotOnLevelException { Player player = null; for (Entity e : entitiesOnLevel) { if (e.getClass() == Player.class && e.Name() == name) { player = (Player) e; } } if (player == null) throw new PlayerNotOnLevelException(this.getName(), name); return player; }
private void removeRenderItem(Entity e) { if (e.keyExists("name")) { // TODO: Check to make sure actually is a Model class Model ent_model = (Model) e.getProperty("model"); if (ent_model != null) { ent_model.destroyVBO(); } else { System.out.println("Trying to delete render object of NULL model"); } } else { System.out.println("Trying to delete render object of unnamed entity"); } }
// Add an item to the entity List private void addRenderItem(Entity e) { if (e.keyExists("name")) { if (e.keyExists("model")) { // TODO: Check to make sure actually is a Model class Model ent_model = (Model) e.getProperty("model"); if (ent_model != null) { ent_model.verify(); ent_model.createVBO(); ent_model.reduceHull(); e.setCollisionShape(ent_model.getCollisionShape()); } else { System.out.println("Trying to add/update render object of NULL model"); } } } else { System.out.println("Trying to add/update render object of unnamed entity"); } }
@SuppressWarnings("unchecked") public void createPropertyMenu() { if (ent != null) { DialogLayout dialog_layout = new DialogLayout(); dialog_layout.setTheme("dialoglayout"); dialog_layout.setHorizontalGroup(dialog_layout.createParallelGroup()); dialog_layout.setVerticalGroup(dialog_layout.createSequentialGroup()); Widget field; CollapsiblePanel cp; for (String prop : Entity.reqKeys) { if (ent.getProperty(prop).getClass() == float.class || ent.getProperty(prop).getClass() == Float.class) { field = new ValueAdjusterFloat(); ((ValueAdjusterFloat) field).setModel(new FloatModelWithEntCallbacks(0, 100, ent, prop)); ((ValueAdjusterInt) field).setTheme("valueadjuster"); } else if (ent.getProperty(prop).getClass() == int.class || ent.getProperty(prop).getClass() == Integer.class) { field = new ValueAdjusterInt(); ((ValueAdjusterInt) field).setModel(new IntegerModelWithEntCallbacks(0, 100, ent, prop)); ((ValueAdjusterInt) field).setTheme("valueadjuster"); } else if (ent.getProperty(prop).getClass() == String.class) { field = new EditField(); ((EditField) field).setModel(new StringModelWithEntCallbacks(ent, prop)); ((EditField) field).setTheme("editfield"); ((EditField) field).setForwardUnhandledKeysToCallback(true); ((EditField) field) .addCallback( new Callback() { @Override public void callback(int key) { createEntityList(); } }); } else if (ent.getProperty(prop).getClass() == boolean.class || ent.getProperty(prop).getClass() == Boolean.class) { field = new ToggleButton(); ((ToggleButton) field).setModel(new BooleanModelWithEntCallbacks(ent, prop)); ((ToggleButton) field).setTheme("togglebutton"); } else if (ent.getProperty(prop).getClass() == Vector3f.class) { field = new XYZAdjuster(prop); ((XYZAdjuster) field).setValue((Vector3f) ent.getProperty(prop)); ((XYZAdjuster) field).setTheme("xyzadjuster"); } else if (ent.getProperty(prop).getClass() == Vector4f.class) { field = new RGBAAdjuster(prop); ((RGBAAdjuster) field).setValue((Vector4f) ent.getProperty(prop)); ((RGBAAdjuster) field).setTheme("rgbaadjuster"); } else if (ent.getProperty(prop).getClass() == engine.render.Model.class) { field = new ComboBox<String>(); for (ResourceItem item : engine.resource_manager.getResourcesInCategory("models")) { ((ComboBox<String>) field).addItem(item.name); } ((ComboBox<String>) field).setTheme("combobox"); } else if (ent.getProperty(prop).getClass() == HashMap.class) { field = new ComboBox<String>(); for (String item : ((HashMap<String, Object>) ent.getProperty(prop)).keySet()) { ((ComboBox<String>) field).addItem(item); } ((ComboBox<String>) field).setTheme("combobox"); } else { field = new Label(); ((Label) field).setText((String) ent.getProperty(prop)); ((Label) field).setTheme("label"); } cp = new CollapsiblePanel(Direction.VERTICAL, prop, field, new SimpleBooleanModel()); cp.setTheme("collapsiblepanel"); dialog_layout.getHorizontalGroup().addWidget(cp); dialog_layout.getVerticalGroup().addWidget(cp); } property_editor.setContent(dialog_layout); } }
public void createEntityList() { tree.removeAllNodes(); for (Entity e : engine.getEntityList()) { tree.createNode((String) e.getProperty("name"), e, tree.getBase()); } }
public void entityRemoved(Entity ent) { render_queue.add(new QueueItem(ent, QueueItem.REMOVE)); ent.removeListener(this); }
public void entityAdded(Entity ent) { render_queue.add(new QueueItem(ent, QueueItem.ADD)); ent.addListener(this); }