use of org.terasology.anatomy.AnatomySkeleton.component.BoneComponent in project Anatomy by Terasology.
the class SkeletalAuthoritySystem method onRegen.
@ReceiveEvent
public void onRegen(DelayedActionTriggeredEvent event, EntityRef entityRef) {
BoneComponent boneComponent = entityRef.getComponent(BoneComponent.class);
String partID = event.getActionId().substring(SKELETAL_REGEN_PREFIX.length());
PartSkeletalDetails partDetails = boneComponent.parts.get(partID);
if (partDetails.health >= 0 && partDetails.health != partDetails.maxHealth && partDetails.regenRate != 0) {
int healAmount = 0;
healAmount = regenerateHealth(partDetails, healAmount);
partDetails.health += healAmount;
entityRef.saveComponent(boneComponent);
entityRef.send(new BoneHealthChangedEvent(partID));
}
delayManager.addDelayedAction(entityRef, SKELETAL_REGEN_PREFIX + partID, (long) (1000 / partDetails.regenRate));
}
Aggregations