1
0

FactionExamineSystem.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Content.Shared.Examine;
  2. namespace Content.Shared.Civ14.CivFactions;
  3. public sealed class FactionExamineSystem : EntitySystem
  4. {
  5. /// <summary>
  6. /// Subscribes to examination events for entities with a faction component to provide custom examine text based on faction membership.
  7. /// </summary>
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<CivFactionComponent, ExaminedEvent>(OnFactionExamine);
  12. }
  13. /// <summary>
  14. /// Adds a faction membership message to the examine event, indicating whether the examined entity shares a faction with the examiner or not.
  15. /// </summary>
  16. /// <param name="uid">The unique identifier of the examined entity.</param>
  17. /// <param name="component">The faction component of the examined entity.</param>
  18. /// <param name="args">The examination event arguments.</param>
  19. private void OnFactionExamine(EntityUid uid, CivFactionComponent component, ExaminedEvent args)
  20. {
  21. if (TryComp<CivFactionComponent>(args.Examiner, out var examinerFaction))
  22. {
  23. if (component.FactionName == "")
  24. {
  25. return;
  26. }
  27. if (component.FactionName == examinerFaction.FactionName)
  28. {
  29. var str = $"They are a member of your faction, [color=#007f00]{component.FactionName}[/color].";
  30. args.PushMarkup(str);
  31. }
  32. else
  33. {
  34. var str = $"They are a member of [color=#7f0000]{component.FactionName}[/color].";
  35. args.PushMarkup(str);
  36. }
  37. }
  38. else
  39. {
  40. var str = $"They are not a member of any factions.";
  41. args.PushMarkup(str);
  42. }
  43. }
  44. }