Revert "Refactor Damage to use Protoypes (#4262)"
This reverts commit 20bf5739a9.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Content.Server.Alert;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -8,8 +8,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Temperature.Components
|
||||
{
|
||||
@@ -24,38 +22,11 @@ namespace Content.Server.Temperature.Components
|
||||
/// <inheritdoc />
|
||||
public override string Name => "Temperature";
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
=======
|
||||
[DataField("coldDamageType",required: true)]
|
||||
private readonly string coldDamageType = default!;
|
||||
[DataField("hotDamageType",required: true)]
|
||||
private readonly string hotDamageType = default!;
|
||||
=======
|
||||
>>>>>>> Refactor damageablecomponent update (#4406)
|
||||
=======
|
||||
>>>>>>> refactor-damageablecomponent
|
||||
[DataField("heatDamageThreshold")]
|
||||
private float _heatDamageThreshold = default;
|
||||
[DataField("coldDamageThreshold")]
|
||||
private float _coldDamageThreshold = default;
|
||||
[DataField("tempDamageCoefficient")]
|
||||
private float _tempDamageCoefficient = 1;
|
||||
[DataField("currentTemperature")]
|
||||
public float CurrentTemperature { get; set; } = Atmospherics.T20C;
|
||||
[DataField("specificHeat")]
|
||||
private float _specificHeat = Atmospherics.MinimumHeatCapacity;
|
||||
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
>>>>>>> update damagecomponent across shared and server
|
||||
[ViewVariables] public float CurrentTemperature { get => _currentTemperature; set => _currentTemperature = value; }
|
||||
=======
|
||||
>>>>>>> Refactor damageablecomponent update (#4406)
|
||||
|
||||
[ViewVariables] public float HeatDamageThreshold => _heatDamageThreshold;
|
||||
[ViewVariables] public float ColdDamageThreshold => _coldDamageThreshold;
|
||||
[ViewVariables] public float TempDamageCoefficient => _tempDamageCoefficient;
|
||||
[ViewVariables] public float SpecificHeat => _specificHeat;
|
||||
[ViewVariables] public float HeatCapacity {
|
||||
get
|
||||
{
|
||||
@@ -68,29 +39,22 @@ namespace Content.Server.Temperature.Components
|
||||
}
|
||||
}
|
||||
|
||||
// TODO PROTOTYPE Replace this datafield variable with prototype references, once they are supported.
|
||||
// Also remove Initialize override, if no longer needed.
|
||||
[DataField("coldDamageType")]
|
||||
private readonly string _coldDamageTypeID = "Cold";
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageTypePrototype ColdDamageType = default!;
|
||||
[DataField("hotDamageType")]
|
||||
private readonly string _hotDamageTypeID = "Heat";
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public DamageTypePrototype HotDamageType = default!;
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
ColdDamageType = IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>(_coldDamageTypeID);
|
||||
HotDamageType = IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>(_hotDamageTypeID);
|
||||
}
|
||||
[ViewVariables] public float SpecificHeat => _specificHeat;
|
||||
|
||||
[DataField("heatDamageThreshold")]
|
||||
private float _heatDamageThreshold = default;
|
||||
[DataField("coldDamageThreshold")]
|
||||
private float _coldDamageThreshold = default;
|
||||
[DataField("tempDamageCoefficient")]
|
||||
private float _tempDamageCoefficient = 1;
|
||||
[DataField("currentTemperature")]
|
||||
private float _currentTemperature = Atmospherics.T20C;
|
||||
[DataField("specificHeat")]
|
||||
private float _specificHeat = Atmospherics.MinimumHeatCapacity;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
var tempDamage = 0;
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
DamageType? damageType = null;
|
||||
if (CurrentTemperature >= _heatDamageThreshold)
|
||||
{
|
||||
@@ -102,13 +66,6 @@ namespace Content.Server.Temperature.Components
|
||||
tempDamage = (int) Math.Floor((_coldDamageThreshold - CurrentTemperature) * _tempDamageCoefficient);
|
||||
damageType = DamageType.Cold;
|
||||
}
|
||||
=======
|
||||
DamageTypePrototype? damageType = null;
|
||||
>>>>>>> update damagecomponent across shared and server
|
||||
=======
|
||||
>>>>>>> Refactor damageablecomponent update (#4406)
|
||||
=======
|
||||
>>>>>>> refactor-damageablecomponent
|
||||
|
||||
if (Owner.TryGetComponent(out ServerAlertsComponent? status))
|
||||
{
|
||||
@@ -151,40 +108,10 @@ namespace Content.Server.Temperature.Components
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
if (!damageType.HasValue) return;
|
||||
|
||||
if (!Owner.TryGetComponent(out IDamageableComponent? component)) return;
|
||||
component.ChangeDamage(damageType.Value, tempDamage, false);
|
||||
=======
|
||||
if (!Owner.TryGetComponent(out IDamageableComponent? component)) return;
|
||||
=======
|
||||
if (!Owner.TryGetComponent(out IDamageableComponent? component)) return;
|
||||
>>>>>>> refactor-damageablecomponent
|
||||
|
||||
if (CurrentTemperature >= _heatDamageThreshold)
|
||||
{
|
||||
int tempDamage = (int) Math.Floor((CurrentTemperature - _heatDamageThreshold) * _tempDamageCoefficient);
|
||||
component.TryChangeDamage(HotDamageType, tempDamage, false);
|
||||
}
|
||||
else if (CurrentTemperature <= _coldDamageThreshold)
|
||||
{
|
||||
int tempDamage = (int) Math.Floor((_coldDamageThreshold - CurrentTemperature) * _tempDamageCoefficient);
|
||||
component.TryChangeDamage(ColdDamageType, tempDamage, false);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< refs/remotes/origin/master
|
||||
|
||||
if (damageType is null) return;
|
||||
component.ChangeDamage(damageType, tempDamage, false);
|
||||
>>>>>>> update damagecomponent across shared and server
|
||||
=======
|
||||
|
||||
>>>>>>> Refactor damageablecomponent update (#4406)
|
||||
=======
|
||||
|
||||
>>>>>>> refactor-damageablecomponent
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user