Search in sources :

Example 1 with EntityRef

use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.

the class SkeletalSystem method healAllBones.

@Command(shortDescription = "Heal all bone parts to full health")
public String healAllBones(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    BoneComponent boneComponent = character.getComponent(BoneComponent.class);
    if (boneComponent != null) {
        for (Map.Entry<String, PartSkeletalDetails> partSkeletalDetails : boneComponent.parts.entrySet()) {
            partSkeletalDetails.getValue().health = partSkeletalDetails.getValue().maxHealth;
        }
    }
    return "Healths fully restored.";
}
Also used : BrokenBoneComponent(org.terasology.anatomy.AnatomySkeleton.component.BrokenBoneComponent) BoneComponent(org.terasology.anatomy.AnatomySkeleton.component.BoneComponent) PartSkeletalDetails(org.terasology.anatomy.component.PartSkeletalDetails) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) HashMap(java.util.HashMap) Map(java.util.Map) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 2 with EntityRef

use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.

the class SkeletalSystem method showBoneHealths.

@Command(shortDescription = "Show bone healths of all parts")
public String showBoneHealths(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    BoneComponent boneComponent = character.getComponent(BoneComponent.class);
    String result = "Bone healths :\n";
    if (boneComponent != null) {
        for (Map.Entry<String, PartSkeletalDetails> partSkeletalDetails : boneComponent.parts.entrySet()) {
            result += partSkeletalDetails.getKey() + " :" + partSkeletalDetails.getValue().health + "/" + partSkeletalDetails.getValue().maxHealth + "\n";
        }
    }
    return result;
}
Also used : BrokenBoneComponent(org.terasology.anatomy.AnatomySkeleton.component.BrokenBoneComponent) BoneComponent(org.terasology.anatomy.AnatomySkeleton.component.BoneComponent) PartSkeletalDetails(org.terasology.anatomy.component.PartSkeletalDetails) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) HashMap(java.util.HashMap) Map(java.util.Map) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 3 with EntityRef

use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.

the class AnatomySystem method dmgAnatomyPart.

@Command(shortDescription = "Damage Anatomy part for amount")
public void dmgAnatomyPart(@CommandParam("name") String partName, @CommandParam("amount") int amount) {
    for (EntityRef clientEntity : entityManager.getEntitiesWith(AnatomyComponent.class)) {
        AnatomyComponent anatomyComponent = clientEntity.getComponent(AnatomyComponent.class);
        AnatomyPartTag partTag = anatomyComponent.parts.get(partName);
        if (partTag != null) {
            clientEntity.send(new AnatomyPartImpactedEvent(amount, partTag));
        }
    }
}
Also used : AnatomyPartTag(org.terasology.anatomy.component.AnatomyPartTag) AnatomyComponent(org.terasology.anatomy.component.AnatomyComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) AnatomyPartImpactedEvent(org.terasology.anatomy.event.AnatomyPartImpactedEvent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 4 with EntityRef

use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.

the class AnatomySystem method showAnatomyEffects.

@Command(shortDescription = "Lists anatomy effects on all parts")
public String showAnatomyEffects(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    String result = "Anatomy effects:\n";
    AnatomyStatusGatheringEvent event = new AnatomyStatusGatheringEvent();
    character.send(event);
    Map<String, List<String>> partEffects = event.getEffectsMap();
    for (Map.Entry<String, List<String>> partEntry : partEffects.entrySet()) {
        result += getAnatomyNameFromID(partEntry.getKey(), character.getComponent(AnatomyComponent.class)) + ": ";
        for (String partEffect : partEntry.getValue()) {
            result += partEffect + ", ";
        }
        result += "\n";
    }
    return result;
}
Also used : AnatomyStatusGatheringEvent(org.terasology.anatomy.event.AnatomyStatusGatheringEvent) AnatomyComponent(org.terasology.anatomy.component.AnatomyComponent) ArrayList(java.util.ArrayList) List(java.util.List) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) Map(java.util.Map) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 5 with EntityRef

use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.

the class InspectionScreen method updateFields.

private void updateFields(EntityRef interactionTarget) {
    InspectionToolComponent inspectorComponent = interactionTarget.getComponent(InspectionToolComponent.class);
    EntityRef inspectedEntity = inspectorComponent.inspectedEntity;
    entityIdField.setText(Long.toString(inspectedEntity.getId()));
    if (inspectedEntity.exists()) {
        if (inspectedEntity.isActive()) {
            fullDescriptionLabel.setText(inspectedEntity.toFullDescription());
        } else {
            fullDescriptionLabel.setText("not active: " + inspectedEntity.toFullDescription());
        }
    } else {
        fullDescriptionLabel.setText("Non existing entity with id " + inspectedEntity.getId());
    }
}
Also used : InspectionToolComponent(org.terasology.logic.common.InspectionToolComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

EntityRef (org.terasology.entitySystem.entity.EntityRef)337 Test (org.junit.Test)106 ClientComponent (org.terasology.network.ClientComponent)49 LocationComponent (org.terasology.logic.location.LocationComponent)45 Vector3f (org.terasology.math.geom.Vector3f)44 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)36 Vector3i (org.terasology.math.geom.Vector3i)34 Command (org.terasology.logic.console.commandSystem.annotations.Command)28 StringComponent (org.terasology.entitySystem.stubs.StringComponent)26 NetworkComponent (org.terasology.network.NetworkComponent)21 EntityData (org.terasology.protobuf.EntityData)21 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)17 Block (org.terasology.world.block.Block)16 Component (org.terasology.entitySystem.Component)15 EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)15 CharacterComponent (org.terasology.logic.characters.CharacterComponent)14 Quat4f (org.terasology.math.geom.Quat4f)14 BlockComponent (org.terasology.world.block.BlockComponent)13 Map (java.util.Map)11 LocalPlayer (org.terasology.logic.players.LocalPlayer)11