1
0

SharedBodySystem.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // SPDX-FileCopyrightText: 2022 DrSmugleaf <DrSmugleaf@users.noreply.github.com>
  2. // SPDX-FileCopyrightText: 2022 Jezithyr <Jezithyr@gmail.com>
  3. // SPDX-FileCopyrightText: 2022 Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
  4. // SPDX-FileCopyrightText: 2022 metalgearsloth <metalgearsloth@gmail.com>
  5. // SPDX-FileCopyrightText: 2023 Jezithyr <jezithyr@gmail.com>
  6. // SPDX-FileCopyrightText: 2023 Psychpsyo <60073468+Psychpsyo@users.noreply.github.com>
  7. // SPDX-FileCopyrightText: 2023 Visne <39844191+Visne@users.noreply.github.com>
  8. // SPDX-FileCopyrightText: 2023 metalgearsloth <comedian_vs_clown@hotmail.com>
  9. // SPDX-FileCopyrightText: 2024 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
  10. // SPDX-FileCopyrightText: 2024 metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
  11. // SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
  12. // SPDX-FileCopyrightText: 2025 Aviu00 <93730715+Aviu00@users.noreply.github.com>
  13. // SPDX-FileCopyrightText: 2025 Piras314 <p1r4s@proton.me>
  14. //
  15. // SPDX-License-Identifier: AGPL-3.0-or-later
  16. using Content.Shared.Damage;
  17. using Content.Shared.Movement.Systems;
  18. using Content.Shared.Standing;
  19. using Robust.Shared.Containers;
  20. using Robust.Shared.Prototypes;
  21. using Robust.Shared.Timing;
  22. namespace Content.Shared.Body.Systems;
  23. public abstract partial class SharedBodySystem : EntitySystem
  24. {
  25. /*
  26. * See the body partial for how this works.
  27. */
  28. /// <summary>
  29. /// Container ID prefix for any body parts.
  30. /// </summary>
  31. public const string PartSlotContainerIdPrefix = "body_part_slot_";
  32. /// <summary>
  33. /// Container ID for the ContainerSlot on the body entity itself.
  34. /// </summary>
  35. public const string BodyRootContainerId = "body_root_part";
  36. /// <summary>
  37. /// Container ID prefix for any body organs.
  38. /// </summary>
  39. public const string OrganSlotContainerIdPrefix = "body_organ_slot_";
  40. [Dependency] private readonly IGameTiming _timing = default!;
  41. [Dependency] protected readonly IPrototypeManager Prototypes = default!;
  42. [Dependency] protected readonly DamageableSystem Damageable = default!;
  43. [Dependency] protected readonly MovementSpeedModifierSystem Movement = default!;
  44. [Dependency] protected readonly SharedContainerSystem Containers = default!;
  45. [Dependency] protected readonly SharedTransformSystem SharedTransform = default!;
  46. [Dependency] protected readonly StandingStateSystem Standing = default!;
  47. public override void Initialize()
  48. {
  49. base.Initialize();
  50. InitializeBody();
  51. InitializeParts();
  52. InitializeOrgans();
  53. // Shitmed Change Start
  54. // To try and mitigate the server load due to integrity checks, we set up a Job Queue.
  55. InitializeIntegrityQueue();
  56. InitializePartAppearances();
  57. InitializeRelay();
  58. // Shitmed Change End
  59. }
  60. /// <summary>
  61. /// Inverse of <see cref="GetPartSlotContainerId"/>
  62. /// </summary>
  63. protected static string? GetPartSlotContainerIdFromContainer(string containerSlotId)
  64. {
  65. // This is blursed
  66. var slotIndex = containerSlotId.IndexOf(PartSlotContainerIdPrefix, StringComparison.Ordinal);
  67. if (slotIndex < 0)
  68. return null;
  69. var slotId = containerSlotId.Remove(slotIndex, PartSlotContainerIdPrefix.Length);
  70. return slotId;
  71. }
  72. /// <summary>
  73. /// Gets the container Id for the specified slotId.
  74. /// </summary>
  75. public static string GetPartSlotContainerId(string slotId)
  76. {
  77. return PartSlotContainerIdPrefix + slotId;
  78. }
  79. /// <summary>
  80. /// Gets the container Id for the specified slotId.
  81. /// </summary>
  82. public static string GetOrganContainerId(string slotId)
  83. {
  84. return OrganSlotContainerIdPrefix + slotId;
  85. }
  86. }