using Content.Shared.Armor;
using Content.Shared.Explosion.Components;
using Robust.Shared.Prototypes;
namespace Content.Shared.Explosion.EntitySystems;
// TODO some sort of struct like DamageSpecifier but for explosions.
///
/// Lets code in shared trigger explosions and handles explosion resistance examining.
/// All processing is still done clientside.
///
public abstract class SharedExplosionSystem : EntitySystem
{
///
/// The "default" explosion prototype.
///
///
/// Generally components should specify an explosion prototype via a yaml datafield, so that the yaml-linter can
/// find errors. However some components, like rogue arrows, or some commands like the admin-smite need to have
/// a "default" option specified outside of yaml data-fields. Hence this const string.
///
public static readonly ProtoId DefaultExplosionPrototypeId = "Default";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnArmorExamine);
}
private void OnArmorExamine(Entity 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)));
}
///
/// Given an entity with an explosive component, spawn the appropriate explosion.
///
///
/// 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).
///
public virtual void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
{
}
///
/// Queue an explosion centered on some entity. Bypasses needing .
///
/// Where the explosion happens.
/// A ProtoId of type .
/// The entity which caused the explosion.
/// Whether to add an admin log about this explosion. Includes user.
public virtual void QueueExplosion(EntityUid uid,
string typeId,
float totalIntensity,
float slope,
float maxTileIntensity,
float tileBreakScale = 1f,
int maxTileBreak = int.MaxValue,
bool canCreateVacuum = true,
EntityUid? user = null,
bool addLog = true)
{
}
///
/// This forces the explosion system to re-calculate the explosion intensity required to destroy all airtight entities.
///
public virtual void ReloadMap()
{
}
}