use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.
the class SkeletalSystem method healAllBones.
@Command(shortDescription = "Heal all bone parts to full health")
public String healAllBones(@Sender EntityRef client) {
EntityRef character = client.getComponent(ClientComponent.class).character;
BoneComponent boneComponent = character.getComponent(BoneComponent.class);
if (boneComponent != null) {
for (Map.Entry<String, PartSkeletalDetails> partSkeletalDetails : boneComponent.parts.entrySet()) {
partSkeletalDetails.getValue().health = partSkeletalDetails.getValue().maxHealth;
}
}
return "Healths fully restored.";
}
use of org.terasology.entitySystem.entity.EntityRef in project Anatomy by Terasology.
the class SkeletalSystem method showBoneHealths.
@Command(shortDescription = "Show bone healths of all parts")
public String showBoneHealths(@Sender EntityRef client) {
EntityRef character = client.getComponent(ClientComponent.class).character;
BoneComponent boneComponent = character.getComponent(BoneComponent.class);
String result = "Bone healths :\n";
if (boneComponent != null) {
for (Map.Entry<String, PartSkeletalDetails> partSkeletalDetails : boneComponent.parts.entrySet()) {
result += partSkeletalDetails.getKey() + " :" + partSkeletalDetails.getValue().health + "/" + partSkeletalDetails.getValue().maxHealth + "\n";
}
}
return result;
}
use of org.terasology.entitySystem.entity.EntityRef 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.entitySystem.entity.EntityRef in project Anatomy by Terasology.
the class AnatomySystem method showAnatomyEffects.
@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;
}
use of org.terasology.entitySystem.entity.EntityRef in project Terasology by MovingBlocks.
the class InspectionScreen method updateFields.
private void updateFields(EntityRef interactionTarget) {
InspectionToolComponent inspectorComponent = interactionTarget.getComponent(InspectionToolComponent.class);
EntityRef inspectedEntity = inspectorComponent.inspectedEntity;
entityIdField.setText(Long.toString(inspectedEntity.getId()));
if (inspectedEntity.exists()) {
if (inspectedEntity.isActive()) {
fullDescriptionLabel.setText(inspectedEntity.toFullDescription());
} else {
fullDescriptionLabel.setText("not active: " + inspectedEntity.toFullDescription());
}
} else {
fullDescriptionLabel.setText("Non existing entity with id " + inspectedEntity.getId());
}
}
Aggregations