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();
}
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;
}
}
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;
}
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;
}
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);
}
Aggregations