Search in sources :

Example 1 with AnatomyComponent

use of org.terasology.anatomy.component.AnatomyComponent 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 2 with AnatomyComponent

use of org.terasology.anatomy.component.AnatomyComponent in project Anatomy by Terasology.

the class AnatomySystem method dmgAnatomyPartAll.

@Command(shortDescription = "Damage ALL Anatomy parts for amount")
public void dmgAnatomyPartAll(@CommandParam("amount") int amount) {
    for (EntityRef clientEntity : entityManager.getEntitiesWith(AnatomyComponent.class)) {
        AnatomyComponent anatomyComponent = clientEntity.getComponent(AnatomyComponent.class);
        List<String> keys = new ArrayList<>(anatomyComponent.parts.keySet());
        for (String key : keys) {
            AnatomyPartTag partTag = anatomyComponent.parts.get(key);
            clientEntity.send(new AnatomyPartImpactedEvent(amount, partTag));
        }
    }
}
Also used : AnatomyPartTag(org.terasology.anatomy.component.AnatomyPartTag) AnatomyComponent(org.terasology.anatomy.component.AnatomyComponent) ArrayList(java.util.ArrayList) EntityRef(org.terasology.entitySystem.entity.EntityRef) AnatomyPartImpactedEvent(org.terasology.anatomy.event.AnatomyPartImpactedEvent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Aggregations

AnatomyComponent (org.terasology.anatomy.component.AnatomyComponent)2 AnatomyPartTag (org.terasology.anatomy.component.AnatomyPartTag)2 AnatomyPartImpactedEvent (org.terasology.anatomy.event.AnatomyPartImpactedEvent)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 Command (org.terasology.logic.console.commandSystem.annotations.Command)2 ArrayList (java.util.ArrayList)1