Files
tbd-station-14/Content.Shared/Explosion/EntitySystems/SharedExplosionSystem.cs
deltanedas 1c839da604 move TriggerExplosion to shared (#30227)
* move component to shared

* add fake systems

* update server explosion system and remove duplicate transform query

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2024-09-19 10:01:40 +10:00

41 lines
1.5 KiB
C#

using Content.Shared.Armor;
using Content.Shared.Explosion.Components;
namespace Content.Shared.Explosion.EntitySystems;
/// <summary>
/// Lets code in shared trigger explosions and handles explosion resistance examining.
/// All processing is still done clientside.
/// </summary>
public abstract class SharedExplosionSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
}
private void OnArmorExamine(Entity<ExplosionResistanceComponent> ent, ref ArmorExamineEvent args)
{
var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
if (value == 0)
return;
args.Msg.PushNewline();
args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
}
/// <summary>
/// Given an entity with an explosive component, spawn the appropriate explosion.
/// </summary>
/// <remarks>
/// Also accepts radius or intensity arguments. This is useful for explosives where the intensity is not
/// specified in the yaml / by the component, but determined dynamically (e.g., by the quantity of a
/// solution in a reaction).
/// </remarks>
public virtual void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
{
}
}