use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class InspectionScreen method initialise.
@Override
public void initialise() {
fullDescriptionLabel = find("fullDescriptionLabel", UIText.class);
entityIdField = find("entityIdField", UIText.class);
setEntityIdButton = find("setEntityIdButton", UIButton.class);
setEntityIdButton.subscribe(widget -> {
String text = entityIdField.getText();
EntityRef interactionTarget = getInteractionTarget();
InspectionToolComponent inspectorComponent = interactionTarget.getComponent(InspectionToolComponent.class);
if (text.equals("this")) {
inspectorComponent.inspectedEntity = interactionTarget;
} else {
try {
int id1 = Integer.parseInt(text);
inspectorComponent.inspectedEntity = CoreRegistry.get(EntityManager.class).getEntity(id1);
} catch (NumberFormatException e) {
fullDescriptionLabel.setText("Please specify a valid number");
}
}
updateFields(interactionTarget);
});
}
use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class OnlinePlayersOverlay method determinePlayerAndPing.
private String determinePlayerAndPing(PingStockComponent pingStockComponent) {
Iterable<EntityRef> allClients = entityManager.getEntitiesWith(ClientComponent.class);
Map<EntityRef, Long> pingMap = pingStockComponent.getValues();
StringBuilder sb = new StringBuilder();
boolean first = true;
for (EntityRef clientEntity : allClients) {
if (!first) {
sb.append("\n");
}
ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
sb.append(PlayerUtil.getColoredPlayerName(clientComp.clientInfo));
sb.append(" ");
Long pingValue = pingMap.get(clientEntity);
if (pingValue == null) {
sb.append("-");
} else {
sb.append(pingValue.toString());
sb.append("ms");
}
first = false;
}
return sb.toString();
}
use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class BlockSelectionRenderSystem method renderOverlay.
@Override
public void renderOverlay() {
for (EntityRef entity : entityManager.getEntitiesWith(BlockSelectionComponent.class)) {
BlockSelectionComponent blockSelectionComponent = entity.getComponent(BlockSelectionComponent.class);
if (blockSelectionComponent.shouldRender) {
Texture texture = blockSelectionComponent.texture;
if (null == texture) {
texture = Assets.getTexture("engine:selection").get();
}
Vector2i textureDimensions = new Vector2i(texture.getWidth(), texture.getHeight());
BlockSelectionRenderer selectionRenderer = cachedBlockSelectionRendererByTextureDimensionsMap.get(textureDimensions);
if (null == selectionRenderer) {
selectionRenderer = new BlockSelectionRenderer(texture);
cachedBlockSelectionRendererByTextureDimensionsMap.put(textureDimensions, selectionRenderer);
} else {
selectionRenderer.setEffectsTexture(texture);
}
renderOverlayForOneBlockSelection(blockSelectionComponent, selectionRenderer);
}
}
}
use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class ClientViewDistanceSystem method onChangeViewDistanceChange.
public void onChangeViewDistanceChange() {
ViewDistance viewDistance = config.getRendering().getViewDistance();
if (worldRenderer != null) {
worldRenderer.setViewDistance(viewDistance);
}
EntityRef clientEntity = localPlayer.getClientEntity();
clientEntity.send(new ViewDistanceChangedEvent(viewDistance));
}
use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class CreatureKilledMetric method createTelemetryFieldToValue.
@Override
public Map<String, ?> createTelemetryFieldToValue() {
localPlayer = CoreRegistry.get(LocalPlayer.class);
EntityRef playerEntity = localPlayer.getCharacterEntity();
if (playerEntity.hasComponent(GamePlayStatsComponent.class)) {
GamePlayStatsComponent gamePlayStatsComponent = playerEntity.getComponent(GamePlayStatsComponent.class);
telemetryFieldToValue.clear();
telemetryFieldToValue.putAll(gamePlayStatsComponent.creatureKilled);
return telemetryFieldToValue;
} else {
return telemetryFieldToValue;
}
}
Aggregations