Search in sources :

Example 1 with GamePlayStatsComponent

use of org.terasology.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;
    }
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) GamePlayStatsComponent(org.terasology.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 2 with GamePlayStatsComponent

use of org.terasology.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();
    }
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) GamePlayStatsComponent(org.terasology.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 3 with GamePlayStatsComponent

use of org.terasology.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;
    }
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) GamePlayStatsComponent(org.terasology.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 4 with GamePlayStatsComponent

use of org.terasology.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;
    }
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) GamePlayStatsComponent(org.terasology.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 5 with GamePlayStatsComponent

use of org.terasology.telemetry.GamePlayStatsComponent in project Terasology by MovingBlocks.

the class BlockItemSystem method recordBlockPlaced.

private void recordBlockPlaced(ActivateEvent event, BlockFamily block) {
    EntityRef instigator = event.getInstigator();
    String blockName = block.getDisplayName();
    if (instigator.hasComponent(GamePlayStatsComponent.class)) {
        GamePlayStatsComponent gamePlayStatsComponent = instigator.getComponent(GamePlayStatsComponent.class);
        Map<String, Integer> blockPlacedMap = gamePlayStatsComponent.blockPlacedMap;
        if (blockPlacedMap.containsKey(blockName)) {
            blockPlacedMap.put(blockName, blockPlacedMap.get(blockName) + 1);
        } else {
            blockPlacedMap.put(blockName, 1);
        }
        instigator.saveComponent(gamePlayStatsComponent);
    } else {
        GamePlayStatsComponent gamePlayStatsComponent = new GamePlayStatsComponent();
        Map<String, Integer> blockPlacedMap = gamePlayStatsComponent.blockPlacedMap;
        blockPlacedMap.put(blockName, 1);
        instigator.addOrSaveComponent(gamePlayStatsComponent);
    }
}
Also used : GamePlayStatsComponent(org.terasology.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)6 GamePlayStatsComponent (org.terasology.telemetry.GamePlayStatsComponent)6 LocalPlayer (org.terasology.logic.players.LocalPlayer)4 Map (java.util.Map)1 CharacterComponent (org.terasology.logic.characters.CharacterComponent)1 BlockComponent (org.terasology.world.block.BlockComponent)1