use of org.terasology.engine.telemetry.GamePlayStatsComponent in project Terasology by MovingBlocks.
the class BlockPlacedMetric 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.blockPlacedMap);
return telemetryFieldToValue;
} else {
return telemetryFieldToValue;
}
}
use of org.terasology.engine.telemetry.GamePlayStatsComponent in project Terasology by MovingBlocks.
the class EntityDestructionAuthoritySystem method recordDestroyed.
private void recordDestroyed(DestroyEvent event, EntityRef entityRef) {
EntityRef instigator = event.getInstigator();
if (instigator != null) {
if (entityRef.hasComponent(BlockComponent.class)) {
BlockComponent blockComponent = entityRef.getComponent(BlockComponent.class);
String blockName = blockComponent.getBlock().getDisplayName();
if (instigator.hasComponent(GamePlayStatsComponent.class)) {
GamePlayStatsComponent gamePlayStatsComponent = instigator.getComponent(GamePlayStatsComponent.class);
Map<String, Integer> blockDestroyedMap = gamePlayStatsComponent.blockDestroyedMap;
if (blockDestroyedMap.containsKey(blockName)) {
blockDestroyedMap.put(blockName, blockDestroyedMap.get(blockName) + 1);
} else {
blockDestroyedMap.put(blockName, 1);
}
instigator.saveComponent(gamePlayStatsComponent);
} else {
GamePlayStatsComponent gamePlayStatsComponent = new GamePlayStatsComponent();
Map<String, Integer> blockDestroyedMap = gamePlayStatsComponent.blockDestroyedMap;
blockDestroyedMap.put(blockName, 1);
instigator.addOrSaveComponent(gamePlayStatsComponent);
}
} else if (entityRef.hasComponent(CharacterComponent.class)) {
String creatureName = entityRef.getParentPrefab().getName();
if (instigator.hasComponent(GamePlayStatsComponent.class)) {
GamePlayStatsComponent gamePlayStatsComponent = instigator.getComponent(GamePlayStatsComponent.class);
Map<String, Integer> creatureKilled = gamePlayStatsComponent.creatureKilled;
if (creatureKilled.containsKey(creatureName)) {
creatureKilled.put(creatureName, creatureKilled.get(creatureName) + 1);
} else {
creatureKilled.put(creatureName, 1);
}
instigator.saveComponent(gamePlayStatsComponent);
} else {
GamePlayStatsComponent gamePlayStatsComponent = new GamePlayStatsComponent();
Map<String, Integer> creatureKilled = gamePlayStatsComponent.creatureKilled;
creatureKilled.put(creatureName, 1);
instigator.addOrSaveComponent(gamePlayStatsComponent);
}
}
}
}
use of org.terasology.engine.telemetry.GamePlayStatsComponent in project Terasology by MovingBlocks.
the class BlockDestroyedMetric 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.blockDestroyedMap);
return telemetryFieldToValue;
} else {
return telemetryFieldToValue;
}
}
use of org.terasology.engine.telemetry.GamePlayStatsComponent 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;
}
}
use of org.terasology.engine.telemetry.GamePlayStatsComponent in project Terasology by MovingBlocks.
the class GamePlayMetric 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);
distanceTraveled = gamePlayStatsComponent.distanceTraveled;
playTimeMinute = (long) gamePlayStatsComponent.playTimeMinute;
return super.createTelemetryFieldToValue();
} else {
return super.createTelemetryFieldToValue();
}
}
Aggregations