use of org.terasology.anatomy.component.AnatomyPartTag 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));
}
}
}
use of org.terasology.anatomy.component.AnatomyPartTag 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));
}
}
}
use of org.terasology.anatomy.component.AnatomyPartTag in project Anatomy by Terasology.
the class AnatomySystem method onDamage.
@ReceiveEvent
public void onDamage(OnDamagedEvent event, EntityRef entity, AnatomyComponent comp) {
if (comp != null) {
List<String> keys = new ArrayList<>(comp.parts.keySet());
// Randomly assign damage to a part, until positional damage is introduced.
AnatomyPartTag partTag = comp.parts.get(keys.get(random.nextInt(0, keys.size() - 1)));
entity.send(new AnatomyPartImpactedEvent(event.getDamageAmount(), partTag, event.getType(), event.getInstigator()));
}
}
Aggregations