As discussed on the Discord, xenos are not humans (#1840)

* As discussed on the Discord, xenos are not humans

* Add living component for living beings without a defined body

* Merge LivingDamageable and Damageable components

* Fix ruinable and state manager inconsistencies

* Fix ruinable exposedata

* Fix new destructibles yamls

* Fix healing not healing

* Fix alive not being a valid state

* Fix valid state checking
This commit is contained in:
DrSmugleaf
2020-08-22 13:40:22 +02:00
committed by GitHub
parent f7c71b500f
commit bb923aa230
32 changed files with 175 additions and 108 deletions

View File

@@ -18,14 +18,12 @@ using Content.Shared.Body.Template;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Server.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Reflection;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
@@ -138,11 +136,6 @@ namespace Content.Server.GameObjects.Components.Body
base.Initialize();
LoadBodyPreset(Preset);
foreach (var behavior in Owner.GetAllComponents<IOnHealthChangedBehavior>())
{
HealthChangedEvent += behavior.OnHealthChanged;
}
}
protected override void Startup()

View File

@@ -41,8 +41,6 @@ namespace Content.Server.GameObjects.Components.Damage
switch (eventArgs.Severity)
{
case ExplosionSeverity.Destruction:
PerformDestruction();
break;
case ExplosionSeverity.Heavy:
PerformDestruction();
break;

View File

@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Damage
{
@@ -18,13 +17,6 @@ namespace Content.Server.GameObjects.Components.Damage
{
private DamageState _currentDamageState;
/// <summary>
/// How much HP this component can sustain before triggering
/// <see cref="PerformDestruction"/>.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public int MaxHp { get; private set; }
/// <summary>
/// Sound played upon destruction.
/// </summary>
@@ -35,29 +27,24 @@ namespace Content.Server.GameObjects.Components.Damage
public override DamageState CurrentDamageState => _currentDamageState;
public override void Initialize()
{
base.Initialize();
HealthChangedEvent += OnHealthChanged;
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(this, ruinable => ruinable.MaxHp, "maxHP", 100);
serializer.DataReadWriteFunction(
"deadThreshold",
100,
t => DeadThreshold = t ,
() => DeadThreshold ?? -1);
serializer.DataField(this, ruinable => ruinable.DestroySound, "destroySound", string.Empty);
}
public override void OnRemove()
protected override void EnterState(DamageState state)
{
base.OnRemove();
HealthChangedEvent -= OnHealthChanged;
}
base.EnterState(state);
private void OnHealthChanged(HealthChangedEventArgs e)
{
if (CurrentDamageState != DamageState.Dead && TotalDamage >= MaxHp)
if (state == DamageState.Dead)
{
PerformDestruction();
}

View File

@@ -187,7 +187,12 @@ namespace Content.Server.GameObjects.Components.Mobs
{
case RuinableComponent ruinable:
{
var modifier = (int) (ruinable.TotalDamage / (ruinable.MaxHp / 7f));
if (ruinable.DeadThreshold == null)
{
break;
}
var modifier = (int) (ruinable.TotalDamage / (ruinable.DeadThreshold / 7f));
status.ChangeStatusEffectIcon(StatusEffect.Health,
"/Textures/Interface/StatusEffects/Human/human" + modifier + ".png");
@@ -196,8 +201,12 @@ namespace Content.Server.GameObjects.Components.Mobs
}
case BodyManagerComponent body:
{
// TODO: Declare body max normal damage (currently 100)
var modifier = (int) (body.TotalDamage / (100f / 7f));
if (body.CriticalThreshold == null)
{
return;
}
var modifier = (int) (body.TotalDamage / (body.CriticalThreshold / 7f));
status.ChangeStatusEffectIcon(StatusEffect.Health,
"/Textures/Interface/StatusEffects/Human/human" + modifier + ".png");