Search in sources :

Example 1 with LocalPlayer

use of org.terasology.engine.logic.players.LocalPlayer in project Terasology by MovingBlocks.

the class InputSystemTests method setUpLocalPlayer.

private void setUpLocalPlayer(Context context) {
    LocalPlayer localPlayer = new LocalPlayer();
    localPlayer.setRecordAndReplayClasses(new DirectionAndOriginPosRecorderList(), new RecordAndReplayCurrentStatus());
    clientEntity = mock(EntityRef.class);
    ClientComponent clientComponent = new ClientComponent();
    characterEntity = mock(EntityRef.class);
    clientComponent.character = characterEntity;
    when(clientEntity.getComponent(ClientComponent.class)).thenReturn(clientComponent);
    localPlayer.setClientEntity(clientEntity);
    context.put(LocalPlayer.class, localPlayer);
    registerEntityKeyCapturing();
}
Also used : DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent)

Example 2 with LocalPlayer

use of org.terasology.engine.logic.players.LocalPlayer 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.engine.logic.players.LocalPlayer) GamePlayStatsComponent(org.terasology.engine.telemetry.GamePlayStatsComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Example 3 with LocalPlayer

use of org.terasology.engine.logic.players.LocalPlayer in project Terasology by MovingBlocks.

the class InitialiseRemoteWorld method step.

@Override
public boolean step() {
    // TODO: These shouldn't be done here, nor so strongly tied to the world renderer
    LocalPlayer localPlayer = new LocalPlayer();
    localPlayer.setRecordAndReplayClasses(context.get(DirectionAndOriginPosRecorderList.class), context.get(RecordAndReplayCurrentStatus.class));
    context.put(LocalPlayer.class, localPlayer);
    BlockManager blockManager = context.get(BlockManager.class);
    ExtraBlockDataManager extraDataManager = context.get(ExtraBlockDataManager.class);
    RemoteChunkProvider chunkProvider = new RemoteChunkProvider(blockManager, localPlayer);
    WorldProviderCoreImpl worldProviderCore = new WorldProviderCoreImpl(gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD), chunkProvider, blockManager.getBlock(BlockManager.UNLOADED_ID), context);
    EntityAwareWorldProvider entityWorldProvider = new EntityAwareWorldProvider(worldProviderCore, context);
    WorldProvider worldProvider = new WorldProviderWrapper(entityWorldProvider, extraDataManager);
    context.put(WorldProvider.class, worldProvider);
    context.put(BlockEntityRegistry.class, entityWorldProvider);
    context.get(ComponentSystemManager.class).register(entityWorldProvider, "engine:BlockEntityRegistry");
    DefaultCelestialSystem celestialSystem = new DefaultCelestialSystem(new BasicCelestialModel(), context);
    context.put(CelestialSystem.class, celestialSystem);
    context.get(ComponentSystemManager.class).register(celestialSystem);
    // Init. a new world
    context.put(BackdropProvider.class, new Skysphere(context));
    RenderingSubsystemFactory engineSubsystemFactory = context.get(RenderingSubsystemFactory.class);
    WorldRenderer worldRenderer = engineSubsystemFactory.createWorldRenderer(context);
    float reflectionHeight = context.get(NetworkSystem.class).getServer().getInfo().getReflectionHeight();
    worldRenderer.getActiveCamera().setReflectionHeight(reflectionHeight);
    context.put(WorldRenderer.class, worldRenderer);
    // TODO: These shouldn't be done here, nor so strongly tied to the world renderer
    context.put(Camera.class, worldRenderer.getActiveCamera());
    context.get(NetworkSystem.class).setRemoteWorldProvider(chunkProvider);
    return true;
}
Also used : LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) WorldProviderWrapper(org.terasology.engine.world.internal.WorldProviderWrapper) NetworkSystem(org.terasology.engine.network.NetworkSystem) WorldProviderCoreImpl(org.terasology.engine.world.internal.WorldProviderCoreImpl) ExtraBlockDataManager(org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager) EntityAwareWorldProvider(org.terasology.engine.world.internal.EntityAwareWorldProvider) DefaultCelestialSystem(org.terasology.engine.world.sun.DefaultCelestialSystem) RenderingSubsystemFactory(org.terasology.engine.core.subsystem.RenderingSubsystemFactory) WorldRenderer(org.terasology.engine.rendering.world.WorldRenderer) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) BasicCelestialModel(org.terasology.engine.world.sun.BasicCelestialModel) BlockManager(org.terasology.engine.world.block.BlockManager) Skysphere(org.terasology.engine.rendering.backdrop.Skysphere) EntityAwareWorldProvider(org.terasology.engine.world.internal.EntityAwareWorldProvider) WorldProvider(org.terasology.engine.world.WorldProvider) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) RemoteChunkProvider(org.terasology.engine.world.chunks.remoteChunkProvider.RemoteChunkProvider)

Example 4 with LocalPlayer

use of org.terasology.engine.logic.players.LocalPlayer in project Terasology by MovingBlocks.

the class AwaitCharacterSpawn method step.

@Override
public boolean step() {
    ComponentSystemManager componentSystemManager = context.get(ComponentSystemManager.class);
    for (UpdateSubscriberSystem updater : componentSystemManager.iterateUpdateSubscribers()) {
        updater.update(0.0f);
    }
    LocalPlayer localPlayer = context.get(LocalPlayer.class);
    ClientComponent client = localPlayer.getClientEntity().getComponent(ClientComponent.class);
    if (client != null && client.character.exists()) {
        client.character.send(new AwaitedLocalCharacterSpawnEvent());
        return true;
    } else {
        chunkProvider.update();
    }
    return false;
}
Also used : LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) UpdateSubscriberSystem(org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem) ClientComponent(org.terasology.engine.network.ClientComponent) ComponentSystemManager(org.terasology.engine.core.ComponentSystemManager)

Example 5 with LocalPlayer

use of org.terasology.engine.logic.players.LocalPlayer in project Terasology by MovingBlocks.

the class AbstractState method createLocalPlayer.

protected static void createLocalPlayer(Context context) {
    EngineEntityManager entityManager = context.get(EngineEntityManager.class);
    EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
    LocalPlayer localPlayer = new LocalPlayer();
    localPlayer.setRecordAndReplayClasses(context.get(DirectionAndOriginPosRecorderList.class), context.get(RecordAndReplayCurrentStatus.class));
    context.put(LocalPlayer.class, localPlayer);
    localPlayer.setClientEntity(localPlayerEntity);
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) DirectionAndOriginPosRecorderList(org.terasology.engine.recording.DirectionAndOriginPosRecorderList) LocalPlayer(org.terasology.engine.logic.players.LocalPlayer) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent)

Aggregations

LocalPlayer (org.terasology.engine.logic.players.LocalPlayer)10 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)7 DirectionAndOriginPosRecorderList (org.terasology.engine.recording.DirectionAndOriginPosRecorderList)4 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)4 GamePlayStatsComponent (org.terasology.engine.telemetry.GamePlayStatsComponent)4 ComponentSystemManager (org.terasology.engine.core.ComponentSystemManager)3 ClientComponent (org.terasology.engine.network.ClientComponent)3 RenderingSubsystemFactory (org.terasology.engine.core.subsystem.RenderingSubsystemFactory)2 EntityManager (org.terasology.engine.entitySystem.entity.EntityManager)2 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 Skysphere (org.terasology.engine.rendering.backdrop.Skysphere)2 WorldRenderer (org.terasology.engine.rendering.world.WorldRenderer)2 WorldProvider (org.terasology.engine.world.WorldProvider)2 BlockManager (org.terasology.engine.world.block.BlockManager)2 ExtraBlockDataManager (org.terasology.engine.world.chunks.blockdata.ExtraBlockDataManager)2 EntityAwareWorldProvider (org.terasology.engine.world.internal.EntityAwareWorldProvider)2 WorldProviderCoreImpl (org.terasology.engine.world.internal.WorldProviderCoreImpl)2 WorldProviderWrapper (org.terasology.engine.world.internal.WorldProviderWrapper)2 BasicCelestialModel (org.terasology.engine.world.sun.BasicCelestialModel)2 DefaultCelestialSystem (org.terasology.engine.world.sun.DefaultCelestialSystem)2