@Override public void update(float delta) { int processed = 0; PerformanceMonitor.startActivity("BlockChangedEventQueue"); BlockChangedEvent event = eventQueue.poll(); while (event != null) { logger.finer( String.format( "%s: %s -> %s", event.getBlockPosition(), event.getOldType().getBlockFamily(), event.getNewType().getBlockFamily())); getOrCreateEntityAt(event.getBlockPosition()).send(event); if (processed++ >= 4) { break; } event = eventQueue.poll(); } PerformanceMonitor.endActivity(); PerformanceMonitor.startActivity("Temp Blocks Cleanup"); for (EntityRef entity : tempBlocks) { BlockComponent blockComp = entity.getComponent(BlockComponent.class); if (blockComp == null || !blockComp.temporary) continue; HealthComponent healthComp = entity.getComponent(HealthComponent.class); if (healthComp == null || healthComp.currentHealth == healthComp.maxHealth) { entity.destroy(); } } tempBlocks.clear(); PerformanceMonitor.endActivity(); }
public void render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); if (_worldRenderer != null) { _worldRenderer.render(); } /* UI */ PerformanceMonitor.startActivity("Render and Update UI"); renderUserInterface(); PerformanceMonitor.endActivity(); }
public void render() { PerformanceMonitor.startActivity("Render UIText"); ShaderManager.getInstance().enableDefaultTextured(); // TODO HACK: Workaround because the internal Slick texture mechanism is never used _workaroundTexture.bind(); if (_shadowed) _font.drawString(_shadowOffset.x, _shadowOffset.y, _text, _shadowColor); _font.drawString(0, 0, _text, _color); // TODO: Also ugly.. glDisable(GL11.GL_TEXTURE_2D); PerformanceMonitor.endActivity(); }
public void update(float delta) { /* GUI */ updateUserInterface(); for (UpdateSubscriberSystem updater : _componentSystemManager.iterateUpdateSubscribers()) { PerformanceMonitor.startActivity(updater.getClass().getSimpleName()); updater.update(delta); } if (_worldRenderer != null && shouldUpdateWorld()) _worldRenderer.update(delta); if (!screenHasFocus()) _localPlayerSys.updateInput(); if (screenHasFocus() || !shouldUpdateWorld()) { if (Mouse.isGrabbed()) { Mouse.setGrabbed(false); Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2); } } else { if (!Mouse.isGrabbed()) Mouse.setGrabbed(true); } // TODO: This seems a little off - plus is more of a UI than single player game state concern. // Move somewhere // more appropriate? boolean dead = true; for (EntityRef entity : _entityManager.iteratorEntities(LocalPlayerComponent.class)) { dead = entity.getComponent(LocalPlayerComponent.class).isDead; } if (dead) { _statusScreen.setVisible(true); _statusScreen.updateStatus("Sorry! Seems like you have died. :-("); } else { _statusScreen.setVisible(false); } }