make syndie bag and rigs explosion resistant (#22088)
* remove empty file real * support explosion resistance for non-worn things * remove redundant entitystorage resistance * port entitystorage optimisation to apply for everything with 100% resistance * add explosion resistance for bag contents * make thing reusable * add resistance to chest rig too * medical chest rig too --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -5,7 +5,9 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
||||
namespace Content.Server.Explosion.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Component that provides entities with explosion resistance.
|
||||
/// Component that provides entities with explosion resistance.
|
||||
/// By default this is applied when worn, but to solely protect the entity itself and
|
||||
/// not the wearer use <c>worn: false</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
|
||||
@@ -21,6 +23,20 @@ public sealed partial class ExplosionResistanceComponent : Component
|
||||
[DataField("damageCoefficient")]
|
||||
public float DamageCoefficient = 1;
|
||||
|
||||
/// <summary>
|
||||
/// When true, resistances will be applied to the entity wearing this item.
|
||||
/// When false, only this entity will get th resistance.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Worn = true;
|
||||
|
||||
/// <summary>
|
||||
/// Examine string for explosion resistance.
|
||||
/// Passed <c>value</c> from 0 to 100.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public LocId Examine = "explosion-resistance-coefficient-value";
|
||||
|
||||
/// <summary>
|
||||
/// Modifiers specific to each explosion type for more customizability.
|
||||
/// </summary>
|
||||
|
||||
@@ -389,7 +389,13 @@ public sealed partial class ExplosionSystem
|
||||
private void GetEntitiesToDamage(EntityUid uid, DamageSpecifier originalDamage, string prototype)
|
||||
{
|
||||
_toDamage.Clear();
|
||||
_toDamage.Add((uid, GetDamage(uid, prototype, originalDamage)));
|
||||
|
||||
// don't raise BeforeExplodeEvent if the entity is completely immune to explosions
|
||||
var thisDamage = GetDamage(uid, prototype, originalDamage);
|
||||
if (!thisDamage.Any())
|
||||
return;
|
||||
|
||||
_toDamage.Add((uid, thisDamage));
|
||||
|
||||
for (var i = 0; i < _toDamage.Count; i++)
|
||||
{
|
||||
|
||||
@@ -132,7 +132,8 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component,
|
||||
InventoryRelayedEvent<GetExplosionResistanceEvent> args)
|
||||
{
|
||||
OnGetResistance(uid, component, ref args.Args);
|
||||
if (component.Worn)
|
||||
OnGetResistance(uid, component, ref args.Args);
|
||||
}
|
||||
|
||||
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args)
|
||||
@@ -378,9 +379,9 @@ public sealed partial class ExplosionSystem : EntitySystem
|
||||
|
||||
private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
|
||||
{
|
||||
var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);
|
||||
|
||||
args.Msg.PushNewline();
|
||||
args.Msg.AddMarkup(Loc.GetString("explosion-resistance-coefficient-value",
|
||||
("value", MathF.Round((1f - component.DamageCoefficient) * 100, 1))
|
||||
));
|
||||
args.Msg.AddMarkup(Loc.GetString(component.Examine, ("value", value)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user