Revert "Refactor Damage to use Protoypes (#4262)"

This reverts commit 20bf5739a9.
This commit is contained in:
Silver
2021-08-24 00:50:39 -06:00
committed by Silver
parent 20bf5739a9
commit e708091518
121 changed files with 711 additions and 10237 deletions

View File

@@ -5,9 +5,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
namespace Content.Server.Chemistry.ReagentEffects
{
@@ -15,7 +12,7 @@ namespace Content.Server.Chemistry.ReagentEffects
/// Default metabolism for medicine reagents. Attempts to find a DamageableComponent on the target,
/// and to update its damage values.
/// </summary>
public class HealthChange : ReagentEffect, ISerializationHooks
public class HealthChange : ReagentEffect
{
/// <summary>
/// How much damage is changed when 1u of the reagent is metabolized.
@@ -23,67 +20,35 @@ namespace Content.Server.Chemistry.ReagentEffects
[DataField("healthChange")]
public float AmountToChange { get; set; } = 1.0f;
// TODO DAMAGE UNITS When damage units support decimals, get rid of this.
// See also _accumulatedDamage in ThirstComponent and HungerComponent
private float _accumulatedDamage;
/// <summary>
/// Damage group to change.
/// Class of damage changed, Brute, Burn, Toxin, Airloss.
/// </summary>
// TODO PROTOTYPE Replace this datafield variable with prototype references, once they are supported.
// Also remove ISerializationHooks, if no longer needed.
[DataField("damageGroup", required: true)]
private readonly string _damageGroupID = default!;
public DamageGroupPrototype DamageGroup = default!;
void ISerializationHooks.AfterDeserialization()
{
DamageGroup = IoCManager.Resolve<IPrototypeManager>().Index<DamageGroupPrototype>(_damageGroupID);
}
[DataField("damageClass")]
public DamageClass DamageType { get; set; } = DamageClass.Brute;
private float _accumulatedHealth;
/// <summary>
/// Changes damage if a DamageableComponent can be found.
/// </summary>
public override void Metabolize(IEntity solutionEntity, Solution.ReagentQuantity amount)
{
if (solutionEntity.TryGetComponent(out IDamageableComponent? damageComponent))
if (solutionEntity.TryGetComponent(out IDamageableComponent? health))
{
<<<<<<< HEAD
<<<<<<< refs/remotes/origin/master
<<<<<<< refs/remotes/origin/master
<<<<<<< refs/remotes/origin/master:Content.Server/Chemistry/ReagentEffects/HealthChange.cs
health.ChangeDamage(DamageType, (int)AmountToChange, true);
=======
damageComponent.ChangeDamage(damageComponent.GetDamageType(damageType), (int)AmountToChange, true);
>>>>>>> Fix Merge issues
float decHealthChange = (float) (AmountToChange - (int) AmountToChange);
=======
damageComponent.ChangeDamage(damageComponent.GetDamageType(damageType), (int)HealthChange, true);
float decHealthChange = (float) (HealthChange - (int) HealthChange);
>>>>>>> update damagecomponent across shared and server:Content.Server/Chemistry/Metabolism/HealthChangeMetabolism.cs
_accumulatedHealth += decHealthChange;
=======
damageComponent.TryChangeDamage(DamageGroup, (int)AmountToChange, true);
float decHealthChange = (float) (AmountToChange - (int) AmountToChange);
_accumulatedDamage += decHealthChange;
>>>>>>> Refactor damageablecomponent update (#4406)
=======
damageComponent.TryChangeDamage(DamageGroup, (int)AmountToChange, true);
float decHealthChange = (float) (AmountToChange - (int) AmountToChange);
_accumulatedDamage += decHealthChange;
>>>>>>> refactor-damageablecomponent
if (_accumulatedDamage >= 1)
if (_accumulatedHealth >= 1)
{
damageComponent.TryChangeDamage(DamageGroup, 1, true);
_accumulatedDamage -= 1;
health.ChangeDamage(DamageType, 1, true);
_accumulatedHealth -= 1;
}
else if(_accumulatedDamage <= -1)
else if(_accumulatedHealth <= -1)
{
damageComponent.TryChangeDamage(DamageGroup, -1, true);
_accumulatedDamage += 1;
health.ChangeDamage(DamageType, -1, true);
_accumulatedHealth += 1;
}
}
}