use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class HealthCommands method damage.
@Command(shortDescription = "Reduce the player's health by an amount", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String damage(@Sender EntityRef client, @CommandParam("amount") int amount) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
clientComp.character.send(new DoDamageEvent(amount, EngineDamageTypes.DIRECT.get(), clientComp.character));
return "Inflicted damage of " + amount;
}
use of org.terasology.network.ClientComponent 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.completeUpdate();
chunkProvider.beginUpdate();
}
return false;
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class StateHeadlessSetup method init.
@Override
public void init(GameEngine gameEngine) {
context = gameEngine.createChildContext();
CoreRegistry.setContext(context);
// let's get the entity event system running
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
entityManager = context.get(EngineEntityManager.class);
eventSystem = context.get(EventSystem.class);
context.put(Console.class, new ConsoleImpl(context));
NUIManager nuiManager = new NUIManagerInternal(context.get(CanvasRenderer.class), context);
context.put(NUIManager.class, nuiManager);
componentSystemManager = new ComponentSystemManager(context);
context.put(ComponentSystemManager.class, componentSystemManager);
componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem");
componentSystemManager.register(new CoreCommands(), "engine:CoreCommands");
componentSystemManager.register(context.get(InputSystem.class), "engine:InputSystem");
EntityRef localPlayerEntity = entityManager.create(new ClientComponent());
LocalPlayer localPlayer = new LocalPlayer();
context.put(LocalPlayer.class, localPlayer);
localPlayer.setClientEntity(localPlayerEntity);
componentSystemManager.initialise();
GameManifest gameManifest = null;
List<GameInfo> savedGames = GameProvider.getSavedGames();
if (savedGames.size() > 0) {
gameManifest = savedGames.get(0).getManifest();
} else {
gameManifest = createGameManifest();
}
gameEngine.changeState(new StateLoading(gameManifest, NetworkMode.LISTEN_SERVER));
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class StorageManagerTest method createClientEntity.
private EntityRef createClientEntity(EntityRef charac) {
ClientComponent clientComponent = new ClientComponent();
clientComponent.local = true;
clientComponent.character = charac;
EntityRef clientEntity = entityManager.create(clientComponent);
return clientEntity;
}
use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.
the class InputSystemTests method setUpLocalPlayer.
private void setUpLocalPlayer(Context context) {
LocalPlayer localPlayer = new LocalPlayer();
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();
}
Aggregations