Remove damage flags (#4189)

This commit is contained in:
DrSmugleaf
2021-06-19 10:50:56 +02:00
committed by GitHub
parent 9b8185db23
commit 4093e2b5ba
9 changed files with 59 additions and 288 deletions

View File

@@ -1,8 +1,10 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Atmos;
using Content.Shared.Damage;
using Content.Shared.Damage.Components;
using Content.Shared.Damage.Resistances;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
@@ -35,7 +37,8 @@ namespace Content.Server.Damage
if (entity.TryGetComponent(out IDamageableComponent? damageable))
{
damageable.AddFlag(DamageFlag.Invulnerable);
damageable.SupportedTypes.Clear();
damageable.SupportedClasses.Clear();
}
return true;
@@ -60,7 +63,15 @@ namespace Content.Server.Damage
if (entity.TryGetComponent(out IDamageableComponent? damageable))
{
damageable.RemoveFlag(DamageFlag.Invulnerable);
if (old.SupportedTypes != null)
{
damageable.SupportedTypes.UnionWith(old.SupportedTypes);
}
if (old.SupportedClasses != null)
{
damageable.SupportedClasses.UnionWith(old.SupportedClasses);
}
}
return true;
@@ -91,10 +102,21 @@ namespace Content.Server.Damage
{
Entity = entity;
MovedByPressure = entity.IsMovedByPressure();
if (entity.TryGetComponent(out IDamageableComponent? damageable))
{
SupportedTypes = damageable.SupportedTypes.ToHashSet();
SupportedClasses = damageable.SupportedClasses.ToHashSet();
}
}
public IEntity Entity { get; }
public bool MovedByPressure { get; }
public HashSet<DamageType>? SupportedTypes { get; }
public HashSet<DamageClass>? SupportedClasses { get; }
}
}
}