use of org.terasology.anatomy.component.PartSkeletalDetails 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));
}
use of org.terasology.anatomy.component.PartSkeletalDetails 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.anatomy.component.PartSkeletalDetails 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.anatomy.component.PartSkeletalDetails in project Anatomy by Terasology.
the class SkeletalAuthoritySystem method onBoneDamage.
@ReceiveEvent
public void onBoneDamage(AnatomyPartImpactedEvent event, EntityRef entityRef, AnatomyComponent anatomyComponent, BoneComponent boneComponent) {
PartSkeletalDetails partDetails = boneComponent.parts.get(event.getTargetPart().id);
// Check if the part contains bone.
int damageAmount = event.getAmount();
if (partDetails != null) {
if (event.getDamageType().getName().equals("Equipment:bluntDamage")) {
damageAmount *= bluntDamageMultiplier;
}
partDetails.health -= damageAmount;
if (partDetails.health < 0) {
partDetails.health = 0;
}
partDetails.nextRegenTick = time.getGameTimeInMs() + TeraMath.floorToInt(partDetails.waitBeforeRegen * 1000);
entityRef.saveComponent(boneComponent);
entityRef.send(new BoneHealthChangedEvent(event.getTargetPart().id));
}
}
Aggregations