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