Search in sources :

Example 31 with ClientComponent

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;
}
Also used : ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 32 with ClientComponent

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;
}
Also used : LocalPlayer(org.terasology.logic.players.LocalPlayer) UpdateSubscriberSystem(org.terasology.entitySystem.systems.UpdateSubscriberSystem) ClientComponent(org.terasology.network.ClientComponent) ComponentSystemManager(org.terasology.engine.ComponentSystemManager)

Example 33 with ClientComponent

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));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) GameInfo(org.terasology.rendering.nui.layers.mainMenu.savedGames.GameInfo) StateLoading(org.terasology.engine.modes.StateLoading) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) CanvasRenderer(org.terasology.rendering.nui.internal.CanvasRenderer) LocalPlayer(org.terasology.logic.players.LocalPlayer) InputSystem(org.terasology.input.InputSystem) CoreCommands(org.terasology.logic.console.commands.CoreCommands) ClientComponent(org.terasology.network.ClientComponent) NUIManagerInternal(org.terasology.rendering.nui.internal.NUIManagerInternal) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) ConsoleSystem(org.terasology.logic.console.ConsoleSystem) GameManifest(org.terasology.game.GameManifest) EventSystem(org.terasology.entitySystem.event.internal.EventSystem) NUIManager(org.terasology.rendering.nui.NUIManager) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 34 with ClientComponent

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;
}
Also used : ClientComponent(org.terasology.network.ClientComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 35 with ClientComponent

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

Aggregations

ClientComponent (org.terasology.network.ClientComponent)64 Command (org.terasology.logic.console.commandSystem.annotations.Command)37 EntityRef (org.terasology.entitySystem.entity.EntityRef)28 LocationComponent (org.terasology.logic.location.LocationComponent)13 Vector3f (org.terasology.math.geom.Vector3f)13 CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)10 ConsoleCommand (org.terasology.logic.console.commandSystem.ConsoleCommand)8 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)7 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)5 Prefab (org.terasology.entitySystem.prefab.Prefab)5 LocalPlayer (org.terasology.logic.players.LocalPlayer)4 Quat4f (org.terasology.math.geom.Quat4f)4 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 SetMovementModeEvent (org.terasology.logic.characters.events.SetMovementModeEvent)3 DropItemEvent (org.terasology.logic.inventory.events.DropItemEvent)3 Client (org.terasology.network.Client)3 ResourceUrn (org.terasology.assets.ResourceUrn)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)2