HideMechanismsCommand.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Content.Shared.Body.Organ;
  2. using Robust.Client.GameObjects;
  3. using Robust.Shared.Console;
  4. using Robust.Shared.Containers;
  5. namespace Content.Client.Commands;
  6. public sealed class HideMechanismsCommand : LocalizedCommands
  7. {
  8. [Dependency] private readonly IEntityManager _entityManager = default!;
  9. public override string Command => "hidemechanisms";
  10. public override string Description => LocalizationManager.GetString($"cmd-{Command}-desc", ("showMechanismsCommand", ShowMechanismsCommand.CommandName));
  11. public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));
  12. public override void Execute(IConsoleShell shell, string argStr, string[] args)
  13. {
  14. var containerSys = _entityManager.System<SharedContainerSystem>();
  15. var query = _entityManager.AllEntityQueryEnumerator<OrganComponent>();
  16. while (query.MoveNext(out var uid, out _))
  17. {
  18. if (!_entityManager.TryGetComponent(uid, out SpriteComponent? sprite))
  19. {
  20. continue;
  21. }
  22. sprite.ContainerOccluded = false;
  23. var tempParent = uid;
  24. while (containerSys.TryGetContainingContainer((tempParent, null, null), out var container))
  25. {
  26. if (!container.ShowContents)
  27. {
  28. sprite.ContainerOccluded = true;
  29. break;
  30. }
  31. tempParent = container.Owner;
  32. }
  33. }
  34. }
  35. }