using Content.Shared.Examine;
namespace Content.Shared.Civ14.CivFactions;
public sealed class FactionExamineSystem : EntitySystem
{
///
/// Subscribes to examination events for entities with a faction component to provide custom examine text based on faction membership.
///
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnFactionExamine);
}
///
/// Adds a faction membership message to the examine event, indicating whether the examined entity shares a faction with the examiner or not.
///
/// The unique identifier of the examined entity.
/// The faction component of the examined entity.
/// The examination event arguments.
private void OnFactionExamine(EntityUid uid, CivFactionComponent component, ExaminedEvent args)
{
if (TryComp(args.Examiner, out var examinerFaction))
{
if (component.FactionName == "")
{
return;
}
if (component.FactionName == examinerFaction.FactionName)
{
var str = $"They are a member of your faction, [color=#007f00]{component.FactionName}[/color].";
args.PushMarkup(str);
}
else
{
var str = $"They are a member of [color=#7f0000]{component.FactionName}[/color].";
args.PushMarkup(str);
}
}
else
{
var str = $"They are not a member of any factions.";
args.PushMarkup(str);
}
}
}