Search in sources :

Example 1 with Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command 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 Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command 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 Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command 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 Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command 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 Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command 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

Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)67 ClientComponent (org.terasology.engine.network.ClientComponent)42 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)35 Vector3f (org.joml.Vector3f)16 ConsoleCommand (org.terasology.engine.logic.console.commandSystem.ConsoleCommand)16 CharacterMovementComponent (org.terasology.engine.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.engine.logic.common.DisplayNameComponent)10 LocationComponent (org.terasology.engine.logic.location.LocationComponent)10 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)9 BlockFamily (org.terasology.engine.world.block.family.BlockFamily)6 Map (java.util.Map)5 CharacterTeleportEvent (org.terasology.engine.logic.characters.CharacterTeleportEvent)5 DropItemEvent (org.terasology.engine.logic.inventory.events.DropItemEvent)5 BlockItemFactory (org.terasology.engine.world.block.items.BlockItemFactory)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 List (java.util.List)3 Locale (java.util.Locale)3