EntityAnchored.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Content.Shared.Construction;
  2. using Content.Shared.Examine;
  3. using JetBrains.Annotations;
  4. using Robust.Shared.Utility;
  5. namespace Content.Server.Construction.Conditions
  6. {
  7. [UsedImplicitly]
  8. [DataDefinition]
  9. public sealed partial class EntityAnchored : IGraphCondition
  10. {
  11. [DataField("anchored")] public bool Anchored { get; private set; } = true;
  12. public bool Condition(EntityUid uid, IEntityManager entityManager)
  13. {
  14. var transform = entityManager.GetComponent<TransformComponent>(uid);
  15. return transform.Anchored && Anchored || !transform.Anchored && !Anchored;
  16. }
  17. public bool DoExamine(ExaminedEvent args)
  18. {
  19. var entity = args.Examined;
  20. var anchored = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Anchored;
  21. switch (Anchored)
  22. {
  23. case true when !anchored:
  24. args.PushMarkup(Loc.GetString("construction-examine-condition-entity-anchored"));
  25. return true;
  26. case false when anchored:
  27. args.PushMarkup(Loc.GetString("construction-examine-condition-entity-unanchored"));
  28. return true;
  29. }
  30. return false;
  31. }
  32. public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
  33. {
  34. yield return new ConstructionGuideEntry()
  35. {
  36. Localization = Anchored
  37. ? "construction-step-condition-entity-anchored"
  38. : "construction-step-condition-entity-unanchored",
  39. Icon = new SpriteSpecifier.Rsi(new ("Objects/Tools/wrench.rsi"), "icon"),
  40. };
  41. }
  42. }
  43. }