Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add component and ui element docs #102

Merged
merged 6 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/_media/damage-overlay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_media/directional-damage-overlay.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_media/hud.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 7 additions & 5 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
* [Home](README.md)
* Events
* Players
* [Health HUD](ui-hud.md)
* [Damage Overlay](ui-damage-overlay.md)
* Modders
* [Health](health.md)
* [Damage](damage.md)
* [Regeneration](regeneration.md)
* [Restoration](restoration.md)
* Systems
* [Damage System](system-damage.md)
* [Block Damage System](system-block-damage.md)
* API
* Developers
* [API](http://jenkins.terasology.io/teraorg/job/Terasology/job/Modules/job/H/job/Health/job/master/javadoc/overview-summary.html)
* [API (SNAPSHOT)](http://jenkins.terasology.io/teraorg/job/Terasology/job/Modules/job/H/job/Health/job/develop/javadoc/overview-summary.html)
29 changes: 29 additions & 0 deletions docs/damage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Damage

Damage refers to the reduction of health points caused by the affected entity itself or a third party.
Self-inflicted causes include, for instance, falling, drowning, or poison damage.
Damage inflicted by a third party typically involves some form of hitting the affected entity.
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this separation 🤔 I wouldn't have thought of "poison damage" as self-inflicted, for example.

Why do we think this distinction is important?

Ideally, the instigator (I guess this is what this is technically about) could carry information about the body of water the player drowned in, the exact poison or disease they are infected with, etc. The instigator might not be another player or NPC, but it could be any entity in the game.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do vaguely recall this from the past - poison is "internal" damage in a sense, unlike third party direct damage. Probably "self-inflicted" is a poor term for that. It would be nice if an internal damage effect had an original trigger source that could be referenced as well.

Player X died from poisoning, after getting too close to a Thornwood Cactus!

That might be a bit of a lofty goal for this point in time tho :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we think this distinction is important?

This distinction is important because the directional damage indicator depends on having a direction to indicate. If we as the player are drowning in water, suffocating due to gas, or dying to poison in our system, there is no specific direction for the damage indicator to indicate as the "instigator" is in ourselves (poison) or all around us (water/gas).
We can also make the distinction between an instigator in or all around us vs an instigator at a specific location, however I have even less of a clue how to name that then...

Probably "self-inflicted" is a poor term for that.

Yeah, naming things is not exactly a strength of mine... I'm happy about any suggestions!

It would be nice if an internal damage effect had an original trigger source that could be referenced as well.

In terms of the directional damage indicator, I'm not sure how it would help the player to know that the cactus they originally got poisoned by, for instance is somewhere to their right...

For the player the interesting point is "why / where from do I lose health right now?" The directional damage indicator shows them, where their attacker can be found, for instance an archer. It's important for the player to understand whether there's an attacker they might be able to defend themselves against or whether the damage is caused by an "environmental" (again maybe not the right term) effect like water, gas, poison, ...


The `DamageSystem` handles damage dealt to entities with health.
The `BlockDamageAuthoritySystem` enables blocks to sustain some damage before getting destroyed.
The `DamageEffectAuthoritySystem` produces block particle effect in the event of damage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be rendered as single paragraph. Should we use bullet points here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


Send a `DoDamageEvent` to a specific entity to deal damage to it.

Use the `DamageResistComponent` to configure an entity to not take damage from specific damage types.
Examples for damage types are drowning (`engine:drowningDamage`) or explosive (`engine:explosiveDamage`) damage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future: explain how to add more damage types?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a vague recollection that we have a module that adds a new damage type. But I have no idea what that is 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #103 to track this. Not sure we want the main docs for that in the Health module, though... I guess it makes more sense putting it in the engine wiki and linking to it from docs of relevant modules including Health.

The `DamageAuthoritySystem` considers the settings provided by this component before an entity is damaged.

Damage sounds added to an entity via the `DamageSoundComponent` are randomly selected and played when the entity is damaged.
Sounds should be referenced as `[engine|<module>]:<soundFileName>` for sound files located in the `assets/sounds` directory of the engine or a module, for instance `engine:Slime3`.

Event chain:
* `DoDamageEvent`
* `BeforeDamageEvent`
* Entity damaged, health component saved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of using italic font to indicate that this is an abstract explanation of what is happening?

Suggested change
* Entity damaged, health component saved
* _Entity damaged, health component saved_

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* `OnDamagedEvent`

Commands:
* `damageResist(damagetype,percentage)`: gives resistance to damage (damagetype = all for total resistance).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future: Would be nice to have a command to list possible damage types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, I can write an issue for that. However, I'm wondering whether that should be a command introduced by Health... Damage types are an engine-level concept after all...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to challenge that damage types are part of the engine if the engine itself does not have a notion of, well, health....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point

* `damageImmune(damagetype)`: percentage = 100 by default.
* `checkResistance()`: gives list of active resistance values
8 changes: 8 additions & 0 deletions docs/health.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Health

Health determines the maximum amount of damage any entity to which the health concept applies can take before, for instance, being destroyed.
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved

The `HealthAuthoritySystem` handles changes to an entity's maximum health.
The `HealthClientSystem` manages the current health of entities with health as well as the UI elements visually representing an entity's health status.

Access the `HealthComponent` to retrieve information about an entity's maximum and current health, its damage thresholds, and whether or not the entity should be destroyed if its health drops to 0.
13 changes: 7 additions & 6 deletions docs/regeneration.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Regeneration

Handles the natural healing of entities (and blocks).
To activate regeneration send `ActivateRegenEvent(String id, float value, float endTime)`.
Health is regenerated every second.
Empty event `ActivateRegenEvent()` activates base regeneration of entity.
The `RegenAuthoritySystem` handles the natural healing of entities including players, NPCs, and even blocks.

To deactivate particular type of regeneration, send `DeactivateRegenEvent(String id)`.
Empty event `DeactivateRegenEvent()` deactivates base regeneration fo entity.
To activate regeneration send `ActivateRegenEvent(String id, float value, float endTime)` for a specific entity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future: Link to JavaDoc when referencing events or methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #104 to track this. This is currently blocked by #101

This will result in health being regenerated for the specified entity every second.
Sending an empty event `ActivateRegenEvent()` activates the base regeneration for the specified entity.

To deactivate a particular type of regeneration, send `DeactivateRegenEvent(String id)`.
Sending an empty event `DeactivateRegenEvent()` deactivates the base regeneration for the specified entity.
3 changes: 2 additions & 1 deletion docs/restoration.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Restoration

Handles magical healing of entities.
The `RestorationAuthoritySystem` handles the magical healing of entities.

To heal an entity, send `DoRestoreEvent(amount, instigatorRef)`.

The event chain of restoration:
Expand Down
3 changes: 0 additions & 3 deletions docs/system-block-damage.md

This file was deleted.

15 changes: 0 additions & 15 deletions docs/system-damage.md

This file was deleted.

14 changes: 14 additions & 0 deletions docs/ui-damage-overlay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Damage Overlay

The `Health` module adds a visual overlay whenever the you are damaged.
If you hurt yourself, for instance through drowning or fall damage, the default damage overlay is displayed.
It consists of four red indicators, one on each side of your screen.
The default damage overlay is also shown when you are hurt by an effect such as poison.
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved

![Damage Overlay](./_media/damage-overlay.jpg)

In case of an external cause, for instance another player or an NPC attacking you, the overlay will be directional.
There will only be one red indicator, marking the direction of origin of the damage cause.
This will allow you to locate the external cause that is hurting you.

![Damage Overlay](./_media/directional-damage-overlay.jpg)
9 changes: 9 additions & 0 deletions docs/ui-hud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Health HUD

The `Health` module extends the Player HUD with a health bar consisting of red hearts.

![Health HUD](./_media/hud.jpg)

When you receive damage, you will lose health, visualized by the full hearts being drained from the right to the left.
Once all the hearts in your health bar are empty, you will die.
You start automatically regenerating health over time once you are no longer being damaged.