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

@@ -0,0 +1,39 @@
using System;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.Destructible.Thresholds.Triggers
{
/// <summary>
/// A trigger that will activate when the amount of damage received
/// of the specified class is above the specified threshold.
/// </summary>
[Serializable]
[DataDefinition]
public class DamageClassTrigger : IThresholdTrigger
{
/// <summary>
/// The class to check the damage of.
/// </summary>
[DataField("class")]
public DamageClass? Class { get; set; }
/// <summary>
/// The amount of damage at which this threshold will trigger.
/// </summary>
[DataField("damage")]
public int Damage { get; set; }
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
{
if (Class == null)
{
return false;
}
return damageable.TryGetDamage(Class.Value, out var damageReceived) &&
damageReceived >= Damage;
}
}
}

View File

@@ -1,42 +0,0 @@
using System;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Prototypes;
using Robust.Shared.IoC;
namespace Content.Server.Destructible.Thresholds.Triggers
{
/// <summary>
/// A trigger that will activate when the amount of damage received
/// of the specified class is above the specified threshold.
/// </summary>
[Serializable]
[DataDefinition]
public class DamageGroupTrigger : IThresholdTrigger
{
// TODO PROTOTYPE Replace this datafield variable with prototype references, once they are supported.
// While you're at it, maybe also combine damageGroup and damage into a dictionary, and allow it to test a sum
// of damage types?
[DataField("damageGroup", required: true)]
private string _damageGroupID { get; set; } = default!;
public DamageGroupPrototype DamageGroup => IoCManager.Resolve<IPrototypeManager>().Index<DamageGroupPrototype>(_damageGroupID);
/// <summary>
/// The amount of damage at which this threshold will trigger.
/// </summary>
[DataField("damage", required: true)]
public int Damage { get; set; } = default!;
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
{
if (DamageGroup == null)
{
return false;
}
return damageable.TryGetDamage(DamageGroup, out var damageReceived) &&
damageReceived >= Damage;
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Shared.Damage.Components;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -15,8 +15,8 @@ namespace Content.Server.Destructible.Thresholds.Triggers
/// <summary>
/// The amount of damage at which this threshold will trigger.
/// </summary>
[DataField("damage", required: true)]
public int Damage { get; set; } = default!;
[DataField("damage")]
public int Damage { get; set; }
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
{

View File

@@ -1,9 +1,7 @@
using System;
using System;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Prototypes;
using Robust.Shared.IoC;
namespace Content.Server.Destructible.Thresholds.Triggers
{
@@ -15,52 +13,20 @@ namespace Content.Server.Destructible.Thresholds.Triggers
[DataDefinition]
public class DamageTypeTrigger : IThresholdTrigger
{
<<<<<<< HEAD
<<<<<<< refs/remotes/origin/master
<<<<<<< refs/remotes/origin/master
[DataField("type")]
public DamageType? Type { get; set; }
=======
[DataField("damageType")]
public string? DamageType { get; set; }
>>>>>>> update damagecomponent across shared and server
=======
=======
>>>>>>> refactor-damageablecomponent
// TODO PROTOTYPE Replace this datafield variable with prototype references, once they are supported.
// While you're at it, maybe also combine damageGroup and damage into a dictionary, and allow it to test a sum
// of damage types?
[DataField("damageType", required:true)]
public string _damageTypeID { get; set; } = default!;
public DamageTypePrototype DamageType => IoCManager.Resolve<IPrototypeManager>().Index<DamageTypePrototype>(_damageTypeID);
<<<<<<< HEAD
>>>>>>> Refactor damageablecomponent update (#4406)
=======
>>>>>>> refactor-damageablecomponent
[DataField("damage", required: true)]
public int Damage { get; set; } = default!;
[DataField("damage")]
public int Damage { get; set; }
public bool Reached(IDamageableComponent damageable, DestructibleSystem system)
{
if (DamageType == null)
if (Type == null)
{
return false;
}
<<<<<<< HEAD
<<<<<<< refs/remotes/origin/master
<<<<<<< refs/remotes/origin/master
return damageable.TryGetDamage(Type.Value, out var damageReceived) &&
=======
return damageable.TryGetDamage(damageable.GetDamageType(DamageType), out var damageReceived) &&
>>>>>>> update damagecomponent across shared and server
=======
return damageable.TryGetDamage(DamageType, out var damageReceived) &&
>>>>>>> Refactor damageablecomponent update (#4406)
=======
return damageable.TryGetDamage(DamageType, out var damageReceived) &&
>>>>>>> refactor-damageablecomponent
damageReceived >= Damage;
}
}