Change all of body system to use entities and components (#2074)

* Early commit

* Early commit 2

* merging master broke my git

* does anyone even read these

* life is fleeting

* it just works

* this time passing integration tests

* Remove hashset yaml serialization for now

* You got a license for those nullables?

* No examine, no context menu, part and mechanism parenting and visibility

* Fix wrong brain sprite state

* Removing layers was a mistake

* just tear body system a new one and see if it still breathes

* Remove redundant code

* Add that comment back

* Separate damage and body, component states, stomach rework

* Add containers for body parts

* Bring layers back pls

* Fix parts magically changing color

* Reimplement sprite layer visibility

* Fix tests

* Add leg test

* Active legs is gone

Crab rave

* Merge fixes, rename DamageState to CurrentState

* Remove IShowContextMenu and ICanExamine
This commit is contained in:
DrSmugleaf
2020-10-10 15:25:13 +02:00
committed by GitHub
parent 73c730d06c
commit dd385a0511
165 changed files with 4232 additions and 4650 deletions

View File

@@ -19,16 +19,18 @@ namespace Content.Shared.GameObjects.Components.Damage
/// </summary>
event Action<HealthChangedEventArgs> HealthChangedEvent;
Dictionary<DamageState, int> Thresholds { get; }
/// <summary>
/// List of all <see cref="DamageState">DamageStates</see> that
/// <see cref="CurrentDamageState"/> can be.
/// List of all <see cref="Damage.DamageState">DamageStates</see> that
/// <see cref="CurrentState"/> can be.
/// </summary>
List<DamageState> SupportedDamageStates { get; }
/// <summary>
/// The <see cref="DamageState"/> currently representing this component.
/// The <see cref="Damage.DamageState"/> currently representing this component.
/// </summary>
DamageState CurrentDamageState { get; }
DamageState CurrentState { get; set; }
/// <summary>
/// Sum of all damages taken.
@@ -157,26 +159,37 @@ namespace Content.Shared.GameObjects.Components.Damage
/// </summary>
void ForceHealthChangedEvent();
void IExAct.OnExplosion(ExplosionEventArgs eventArgs)
{
var damage = eventArgs.Severity switch
{
ExplosionSeverity.Light => 20,
ExplosionSeverity.Heavy => 60,
ExplosionSeverity.Destruction => 250,
_ => throw new ArgumentOutOfRangeException()
};
/// <summary>
/// Calculates the health of an entity until it enters
/// <see cref="threshold"/>.
/// </summary>
/// <param name="threshold">The state to use as a threshold.</param>
/// <returns>
/// The current and maximum health on this entity based on
/// <see cref="threshold"/>, or null if the state is not supported.
/// </returns>
(int current, int max)? Health(DamageState threshold);
ChangeDamage(DamageType.Piercing, damage, false);
ChangeDamage(DamageType.Heat, damage, false);
}
/// <summary>
/// Calculates the health of an entity until it enters
/// <see cref="threshold"/>.
/// </summary>
/// <param name="threshold">The state to use as a threshold.</param>
/// <param name="health">
/// The current and maximum health on this entity based on
/// <see cref="threshold"/>, or null if the state is not supported.
/// </param>
/// <returns>
/// True if <see cref="threshold"/> is supported, false otherwise.
/// </returns>
bool TryHealth(DamageState threshold, [NotNullWhen(true)] out (int current, int max) health);
}
/// <summary>
/// Data class with information on how to damage a
/// <see cref="IDamageableComponent"/>.
/// While not necessary to damage for all instances, classes such as
/// <see cref="SharedBodyManagerComponent"/> may require it for extra data
/// <see cref="SharedBodyComponent"/> may require it for extra data
/// (such as selecting which limb to target).
/// </summary>
public class HealthChangeParams : EventArgs