use of org.terasology.anatomy.AnatomySkeleton.component.BrokenBoneComponent in project Anatomy by Terasology.
the class SkeletalSystem method applyEffect.
private void applyEffect(EntityRef entityRef, String partId, int severity) {
if (entityRef.getComponent(BrokenBoneComponent.class) == null) {
entityRef.addComponent(new BrokenBoneComponent());
}
BrokenBoneComponent brokenBoneComponent = entityRef.getComponent(BrokenBoneComponent.class);
for (Map.Entry<String, List<String>> partsOfSeverity : brokenBoneComponent.parts.entrySet()) {
if (partsOfSeverity.getValue().contains(partId)) {
if (Integer.parseInt(partsOfSeverity.getKey()) == severity) {
return;
} else {
partsOfSeverity.getValue().remove(partId);
}
}
}
if (brokenBoneComponent.parts.containsKey(String.valueOf(severity))) {
brokenBoneComponent.parts.get(String.valueOf(severity)).add(partId);
} else {
brokenBoneComponent.parts.put(String.valueOf(severity), Lists.newArrayList(partId));
}
entityRef.saveComponent(brokenBoneComponent);
}
Aggregations