Search in sources :

Example 1 with EntityRef

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

the class CirculatorySystem method showCirculatoryHealths.

@Command(shortDescription = "Show circulatory healths of all injured parts")
public String showCirculatoryHealths(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    InjuredCirculatoryComponent injuredCirculatoryComponent = character.getComponent(InjuredCirculatoryComponent.class);
    String result = "";
    if (injuredCirculatoryComponent != null) {
        result += "Blood level : ";
        result += injuredCirculatoryComponent.bloodLevel + "/" + injuredCirculatoryComponent.maxBloodLevel + " Blood regen rate: " + injuredCirculatoryComponent.bloodRegenRate + "\n";
        result += "Circulatory system healths :\n";
        for (Map.Entry<String, PartHealthDetails> partHealthDetailsEntry : injuredCirculatoryComponent.partHealths.entrySet()) {
            result += partHealthDetailsEntry.getKey() + " :" + partHealthDetailsEntry.getValue().health + "/" + partHealthDetailsEntry.getValue().maxHealth + "\n";
        }
    } else {
        result += "Circulatory system healthy.\n";
    }
    return result;
}
Also used : PartHealthDetails(org.terasology.anatomy.component.PartHealthDetails) InjuredCirculatoryComponent(org.terasology.anatomy.AnatomyCirculation.component.InjuredCirculatoryComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) HashMap(java.util.HashMap) Map(java.util.Map) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 2 with EntityRef

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

the class SkeletalSystem method healAllBones.

/**
 * Console command - Heals all parts' skeletal healths to max.
 */
@Command(shortDescription = "Heal all bone parts to full health")
public String healAllBones(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    InjuredBoneComponent injuredBoneComponent = character.getComponent(InjuredBoneComponent.class);
    if (injuredBoneComponent != null) {
        for (Map.Entry<String, PartHealthDetails> partHealthDetailsEntry : injuredBoneComponent.partHealths.entrySet()) {
            partHealthDetailsEntry.getValue().health = partHealthDetailsEntry.getValue().maxHealth;
            character.send(new BoneHealthChangedEvent(partHealthDetailsEntry.getKey()));
        }
    }
    return "Skeletal healths fully restored.";
}
Also used : BoneHealthChangedEvent(org.terasology.anatomy.AnatomySkeleton.event.BoneHealthChangedEvent) PartHealthDetails(org.terasology.anatomy.component.PartHealthDetails) InjuredBoneComponent(org.terasology.anatomy.AnatomySkeleton.component.InjuredBoneComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) HashMap(java.util.HashMap) Map(java.util.Map) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 3 with EntityRef

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

the class SkeletalSystem method showBoneHealths.

/**
 * Console command - Shows the skeletal healths of injured parts.
 */
@Command(shortDescription = "Show bone healths of all injured parts")
public String showBoneHealths(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    InjuredBoneComponent injuredBoneComponent = character.getComponent(InjuredBoneComponent.class);
    String result = "";
    if (injuredBoneComponent != null) {
        result += "Bone healths :\n";
        for (Map.Entry<String, PartHealthDetails> partHealthDetailsEntry : injuredBoneComponent.partHealths.entrySet()) {
            result += partHealthDetailsEntry.getKey() + " :" + partHealthDetailsEntry.getValue().health + "/" + partHealthDetailsEntry.getValue().maxHealth + "\n";
        }
    } else {
        result += "Skeletal system healthy.\n";
    }
    return result;
}
Also used : PartHealthDetails(org.terasology.anatomy.component.PartHealthDetails) InjuredBoneComponent(org.terasology.anatomy.AnatomySkeleton.component.InjuredBoneComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) HashMap(java.util.HashMap) Map(java.util.Map) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 4 with EntityRef

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

the class AnatomySystem method dmgAnatomyPart.

/**
 * Console command - Damages a particular anatomy part for a given amount.
 */
@Command(shortDescription = "Damage Anatomy part for amount")
public String dmgAnatomyPart(@Sender EntityRef entityRef, @CommandParam("name") String partName, @CommandParam("amount") int amount) {
    EntityRef clientEntity = entityRef.getComponent(ClientComponent.class).character;
    AnatomyComponent anatomyComponent = clientEntity.getComponent(AnatomyComponent.class);
    AnatomyPartTag partTag = anatomyComponent.parts.get(partName);
    if (partTag != null) {
        clientEntity.send(new AnatomyPartImpactedEvent(amount, partTag));
        return "Inflicted " + amount + " damage to " + getAnatomyNameFromID(partTag.id, anatomyComponent);
    } else {
        return "No such part found.";
    }
}
Also used : AnatomyPartTag(org.terasology.anatomy.component.AnatomyPartTag) AnatomyComponent(org.terasology.anatomy.component.AnatomyComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) AnatomyPartImpactedEvent(org.terasology.anatomy.event.AnatomyPartImpactedEvent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 5 with EntityRef

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

the class AnatomySystem method showAnatomyEffects.

/**
 * Console command - Shows a list of anatomy effects on each part.
 */
@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.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) Map(java.util.Map) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)298 Test (org.junit.jupiter.api.Test)88 ClientComponent (org.terasology.engine.network.ClientComponent)55 Vector3f (org.joml.Vector3f)51 LocationComponent (org.terasology.engine.logic.location.LocationComponent)44 Vector3i (org.joml.Vector3i)36 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)34 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)29 StringComponent (org.terasology.unittest.stubs.StringComponent)26 NetworkComponent (org.terasology.engine.network.NetworkComponent)23 EntityData (org.terasology.protobuf.EntityData)23 Quaternionf (org.joml.Quaternionf)19 DisplayNameComponent (org.terasology.engine.logic.common.DisplayNameComponent)19 Component (org.terasology.gestalt.entitysystem.component.Component)19 CharacterComponent (org.terasology.engine.logic.characters.CharacterComponent)15 Map (java.util.Map)14 EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)13 BlockComponent (org.terasology.engine.world.block.BlockComponent)13 Block (org.terasology.engine.world.block.Block)11 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)10