2019-11-13 17:37:46 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using Content.Shared.GameObjects;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Triggers an event when values rise above or drop below this threshold
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public struct DamageThreshold
|
|
|
|
|
|
{
|
|
|
|
|
|
public DamageType DamageType { get; }
|
|
|
|
|
|
public int Value { get; }
|
|
|
|
|
|
public ThresholdType ThresholdType { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public DamageThreshold(DamageType damageType, int value, ThresholdType thresholdType)
|
|
|
|
|
|
{
|
|
|
|
|
|
DamageType = damageType;
|
|
|
|
|
|
Value = value;
|
|
|
|
|
|
ThresholdType = thresholdType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(Object obj)
|
|
|
|
|
|
{
|
2019-11-13 17:37:46 -05:00
|
|
|
|
return obj is DamageThreshold threshold && this == threshold;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return DamageType.GetHashCode() ^ Value.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
public static bool operator ==(DamageThreshold x, DamageThreshold y)
|
|
|
|
|
|
{
|
|
|
|
|
|
return x.DamageType == y.DamageType && x.Value == y.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
public static bool operator !=(DamageThreshold x, DamageThreshold y)
|
|
|
|
|
|
{
|
|
|
|
|
|
return !(x == y);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum ThresholdType
|
|
|
|
|
|
{
|
|
|
|
|
|
None,
|
|
|
|
|
|
Destruction,
|
|
|
|
|
|
Death,
|
|
|
|
|
|
Critical,
|
2019-08-14 10:49:28 +02:00
|
|
|
|
HUDUpdate,
|
|
|
|
|
|
Breakage,
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DamageThresholdPassedEventArgs : EventArgs
|
|
|
|
|
|
{
|
|
|
|
|
|
public DamageThreshold DamageThreshold { get; }
|
|
|
|
|
|
public bool Passed { get; }
|
2019-06-07 16:15:20 +05:00
|
|
|
|
public int ExcessDamage { get; }
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
2019-06-07 16:15:20 +05:00
|
|
|
|
public DamageThresholdPassedEventArgs(DamageThreshold threshold, bool passed, int excess)
|
2018-12-13 07:47:19 -06:00
|
|
|
|
{
|
|
|
|
|
|
DamageThreshold = threshold;
|
|
|
|
|
|
Passed = passed;
|
2019-06-07 16:15:20 +05:00
|
|
|
|
ExcessDamage = excess;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|