Search in sources :

Example 66 with Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Anatomy by Terasology.

the class CirculatorySystem method healAllCirculation.

@Command(shortDescription = "Heal all circulatory system parts to full health")
public String healAllCirculation(@Sender EntityRef client) {
    EntityRef character = client.getComponent(ClientComponent.class).character;
    InjuredCirculatoryComponent injuredCirculatoryComponent = character.getComponent(InjuredCirculatoryComponent.class);
    if (injuredCirculatoryComponent != null) {
        for (Map.Entry<String, PartHealthDetails> partHealthDetailsEntry : injuredCirculatoryComponent.partHealths.entrySet()) {
            partHealthDetailsEntry.getValue().health = partHealthDetailsEntry.getValue().maxHealth;
            character.send(new PartCirculatoryHealthChangedEvent(partHealthDetailsEntry.getKey()));
        }
    }
    return "Circulatory healths fully restored.";
}
Also used : PartHealthDetails(org.terasology.anatomy.component.PartHealthDetails) InjuredCirculatoryComponent(org.terasology.anatomy.AnatomyCirculation.component.InjuredCirculatoryComponent) PartCirculatoryHealthChangedEvent(org.terasology.anatomy.AnatomyCirculation.event.PartCirculatoryHealthChangedEvent) 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 67 with Command

use of org.terasology.engine.logic.console.commandSystem.annotations.Command in project Anatomy by Terasology.

the class AnatomySystem method dmgAnatomyPartAll.

/**
 * Console command - Damages all anatomy parts for a given amount.
 */
@Command(shortDescription = "Damage ALL Anatomy parts for amount")
public String dmgAnatomyPartAll(@Sender EntityRef entityRef, @CommandParam("amount") int amount) {
    EntityRef clientEntity = entityRef.getComponent(ClientComponent.class).character;
    AnatomyComponent anatomyComponent = clientEntity.getComponent(AnatomyComponent.class);
    List<String> keys = new ArrayList<>(anatomyComponent.parts.keySet());
    String result = "";
    for (String key : keys) {
        result += "Inflicted " + amount + " damage to " + getAnatomyNameFromID(key, anatomyComponent) + "\n";
        AnatomyPartTag partTag = anatomyComponent.parts.get(key);
        clientEntity.send(new AnatomyPartImpactedEvent(amount, partTag));
    }
    return result;
}
Also used : AnatomyPartTag(org.terasology.anatomy.component.AnatomyPartTag) AnatomyComponent(org.terasology.anatomy.component.AnatomyComponent) ArrayList(java.util.ArrayList) 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)

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