Package org.terasology.logic.health

Examples of org.terasology.logic.health.HealthComponent


    }

    @Command(shortDescription = "Reduce the player's health to zero", runOnServer = true)
    public void kill(EntityRef client) {
        ClientComponent clientComp = client.getComponent(ClientComponent.class);
        HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
        if (health != null) {
            clientComp.character.send(new DestroyEvent(clientComp.character, EntityRef.NULL, EngineDamageTypes.DIRECT.get()));
        }
    }
View Full Code Here


    @Command(shortDescription = "Jump really high", runOnServer = true)
    public String hjump(EntityRef client) {
        ClientComponent clientComp = client.getComponent(ClientComponent.class);
        CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
        HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
        if (health != null && move != null) {
            move.jumpSpeed = 75f;
            health.fallingDamageSpeedThreshold = 85f;
            health.excessSpeedDamageMultiplier = 2f;
            clientComp.character.saveComponent(health);
View Full Code Here

            move.slopeFactor = moveDefault.slopeFactor;
            move.distanceBetweenFootsteps = moveDefault.distanceBetweenFootsteps;
            clientComp.character.saveComponent(move);
        }

        HealthComponent healthDefault = ((PojoPrefab) asset).getComponent(HealthComponent.class);
        HealthComponent health = clientComp.character.getComponent(HealthComponent.class);
        if(health != null && healthDefault != null){
            health.fallingDamageSpeedThreshold = healthDefault.fallingDamageSpeedThreshold;
            health.horizontalDamageSpeedThreshold = healthDefault.horizontalDamageSpeedThreshold;
            health.excessSpeedDamageMultiplier = healthDefault.excessSpeedDamageMultiplier;
            clientComp.character.saveComponent(health);
View Full Code Here

    }

    @Override
    public void setup() {
        i = 0;
        comp = new HealthComponent();
        try {
            accessor = reflectFactory.createFieldAccessor(HealthComponent.class, HealthComponent.class.getField("maxHealth"));
        } catch (InaccessibleFieldException | NoSuchFieldException e) {
            logger.error("Failed to establish field accessor object", e);
        }
View Full Code Here

        UIIconBar healthBar = find("healthBar", UIIconBar.class);
        healthBar.bindValue(new ReadOnlyBinding<Float>() {
            @Override
            public Float get() {
                HealthComponent healthComponent = localPlayer.getCharacterEntity().getComponent(HealthComponent.class);
                if (healthComponent != null) {
                    return (float) healthComponent.currentHealth;
                }
                return 0f;
            }
        });
        healthBar.bindMaxValue(new ReadOnlyBinding<Float>() {
            @Override
            public Float get() {
                HealthComponent healthComponent = localPlayer.getCharacterEntity().getComponent(HealthComponent.class);
                if (healthComponent != null) {
                    return (float) healthComponent.maxHealth;
                }
                return 0f;
            }
View Full Code Here


        blockComponent.setBlock(type);
        blockEntity.saveComponent(blockComponent);

        HealthComponent health = blockEntity.getComponent(HealthComponent.class);
        if (health == null && type.isDestructible()) {
            blockEntity.addComponent(new HealthComponent(type.getHardness(), type.getHardness() / BLOCK_REGEN_SECONDS, 1.0f));
        } else if (health != null && !type.isDestructible()) {
            blockEntity.removeComponent(HealthComponent.class);
        } else if (health != null && type.isDestructible()) {
            health.maxHealth = type.getHardness();
            health.currentHealth = Math.min(health.currentHealth, health.maxHealth);
View Full Code Here

        EntityBuilder builder = entityManager.newBuilder(block.getPrefab());
        builder.addComponent(new LocationComponent(blockPosition.toVector3f()));
        builder.addComponent(new BlockComponent(block, blockPosition));
        if (block.isDestructible() && !builder.hasComponent(HealthComponent.class)) {
            // Block regen should always take the same amount of time,  regardless of its hardness
            builder.addComponent(new HealthComponent(block.getHardness(), block.getHardness() / BLOCK_REGEN_SECONDS, 1.0f));
        }
        boolean isTemporary = isTemporaryBlock(builder, block);
        if (!isTemporary && !builder.hasComponent(NetworkComponent.class)) {
            builder.addComponent(new NetworkComponent());
        }
View Full Code Here

        glBlendFunc(GL_DST_COLOR, GL_ZERO);

        Vector3f cameraPosition = CoreRegistry.get(WorldRenderer.class).getActiveCamera().getPosition();

        for (EntityRef entity : entityManager.getEntitiesWith(HealthComponent.class, BlockComponent.class)) {
            HealthComponent health = entity.getComponent(HealthComponent.class);
            if (health.currentHealth == health.maxHealth) {
                continue;
            }
            BlockComponent blockComp = entity.getComponent(BlockComponent.class);
            renderHealth(blockComp.getPosition(), health, cameraPosition);
        }
        for (EntityRef entity : entityManager.getEntitiesWith(BlockRegionComponent.class, HealthComponent.class)) {
            HealthComponent health = entity.getComponent(HealthComponent.class);
            if (health.currentHealth == health.maxHealth) {
                continue;
            }
            BlockRegionComponent blockRegion = entity.getComponent(BlockRegionComponent.class);
            for (Vector3i blockPos : blockRegion.region) {
View Full Code Here

TOP

Related Classes of org.terasology.logic.health.HealthComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.