Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Upstreams" #570

Merged
merged 1 commit into from
Nov 9, 2024
Merged

Revert "Upstreams" #570

merged 1 commit into from
Nov 9, 2024

Conversation

CrimeMoot
Copy link
Collaborator

@CrimeMoot CrimeMoot commented Nov 9, 2024

Reverts #567

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced surgery UI responsiveness with improved handling of player item additions.
    • Simplified body part appearance management and reduced complexity in body marking logic.
    • Added new animal entities and refined existing ones for better interaction and gameplay.
  • Bug Fixes

    • Resolved issues with UI error messages for missing tools during surgeries.
  • Improvements

    • Streamlined surgical procedures by refining requirements and correcting entity names.
    • Simplified gibbing methods for body parts, enhancing performance and clarity.
  • Documentation

    • Updated changelog with detailed entries on gameplay tweaks, additions, and fixes.

Copy link

coderabbitai bot commented Nov 9, 2024

Walkthrough

The changes in this pull request involve significant modifications across several classes related to body systems and surgery mechanics. Key alterations include the removal of methods and dependencies concerning body part markings, the introduction of new event handling in the surgery system, and updates to the UI interactions for surgery. Additionally, several properties and methods in various components have been simplified or removed, reflecting a shift towards a more streamlined approach to managing body appearances and surgery processes.

Changes

File Path Change Summary
Content.Client/Backmen/Body/BodySystem.cs Removed MarkingManager dependency and ApplyMarkingToPart method; replaced with UpdateAppearance method. Simplified logic for applying markings. Removed RemovePartMarkings method.
Content.Client/Backmen/Surgery/SurgeryBui.cs Introduced HandsSystem dependency; added OnPlayerItemAdded method; removed ReceiveMessage method; modified Dispose method for cleanup; enhanced RefreshUI method with logging and checks for player capabilities.
Content.Client/Backmen/Surgery/SurgerySystem.cs Added OnStep event; updated Initialize method to subscribe to SurgeryUiRefreshEvent; modified OnRefresh method to trigger OnStep event.
Content.Client/Humanoid/HumanoidAppearanceSystem.cs Updated SetLayerData method to remove overrideSkin parameter; simplified skin color application logic.
Content.Server/Backmen/Surgery/SurgerySystem.cs Added subscription to PrototypesReloadedEventArgs; modified RefreshUI method for UI updates; refined interaction logic in OnToolAfterInteract.
Content.Server/Body/Systems/BodySystem.cs Simplified GibBody method parameters; removed methods related to body part markings.
Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs Removed GibType and GibContents fields; simplified Execute method call to GibBody.
Content.Shared/Backmen/Surgery/Body/BodyPartAppearanceComponent.cs Removed Type, EyeColor, and Markings properties; updated ID, Color, and OriginalBody properties with custom field names.
Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs Updated event subscriptions and added static dictionary for visual layers; refactored appearance initialization logic.
Content.Shared/Backmen/Surgery/SharedSurgerySystem.Steps.cs Removed checks for contained entities in OnToolCanPerform; updated OnAddPartStep method.
Content.Shared/Backmen/Surgery/SurgeryUI.cs Added SurgeryUIKey enum and SurgeryBuiState class; removed SurgeryBuiRefreshMessage class.
Content.Shared/Body/Part/BodyPartComponent.cs Removed Species and Sex properties.
Content.Shared/Body/Part/BodyPartEvents.cs Removed BodyPartAttachedEvent and BodyPartDroppedEvent record structs.
Content.Shared/Body/Systems/SharedBodySystem.Body.cs Removed subscription to ProfileLoadFinishedEvent; simplified MapInitParts and GibBody methods.
Content.Shared/Body/Systems/SharedBodySystem.Parts.cs Updated logic for DropPart and AttachPart methods; enhanced event handling for body parts.
Content.Shared/Body/Systems/SharedBodySystem.cs Removed call to InitializePartAppearances() in Initialize() method.
Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs Deleted ProfileLoadFinishedEvent class.
Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs Updated LoadProfile method to include SetTTSVoice; modified AddMarking method to accept multiple colors.
Resources/Changelog/ChangelogBkm.yml Updated changelog with various tweaks, additions, and fixes.
Resources/Locale/en-US/surgery/surgery-ui.ftl Updated error message for missing tools.
Resources/Prototypes/Body/Parts/skeleton.yml Removed Destructible component from PartSkeleton entity.
Resources/Prototypes/Entities/Mobs/NPCs/animals.yml Introduced new entities and updated existing ones with refined interaction capabilities.
Resources/Prototypes/Entities/Mobs/Player/silicon_base.yml Deleted silicon_base.yml file.
Resources/Prototypes/Entities/Mobs/Species/skeleton.yml Updated GibBehavior component for Urist McSkelly.
Resources/Prototypes/_Backmen/Body/Parts/shadowkin.yml Removed various components and attributes from PartShadowkin and derived entities.
Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml Added breakoutTime property to Handcuff component of Purplecuffs.
Resources/Prototypes/_Backmen/Entities/Surgery/surgeries.yml Added requirement for SurgeryAttachHead entity and corrected name for SurgeryAttachLeftHand.

Poem

In the land of hops and playful cheer,
Changes abound, let’s give a cheer! 🐇
With markings gone, and systems anew,
Surgery's smoother, and UI shines through.
So let’s dance and play, in fields so bright,
For every tweak brings joy and delight! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (11)
Content.Client/Backmen/Surgery/SurgerySystem.cs (2)

7-8: Add XML documentation for the public event.

Since OnStep is part of the public API, it should be documented with XML comments explaining its purpose and when it's invoked.

+/// <summary>
+/// Event that is triggered when a surgery step is completed during UI refresh.
+/// </summary>
 public event Action? OnStep;

16-19: Consider passing relevant surgery step information to event subscribers.

The current implementation invokes OnStep without any context about which step was completed. This might limit the usefulness of the event for subscribers who need to know specific details about the surgery progress.

Consider either:

  1. Changing the event signature to include step information:
-public event Action? OnStep;
+public event Action<SurgeryStepEventArgs>? OnStep;
  1. Or passing the event data from SurgeryUiRefreshEvent:
 private void OnRefresh(SurgeryUiRefreshEvent ev)
 {
-    OnStep?.Invoke();
+    OnStep?.Invoke(ev.StepInfo);
 }
Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml (1)

19-19: Add newline at end of file.

The file is missing a newline character at the end, which is a YAML best practice.

    breakoutTime: 5
+
🧰 Tools
🪛 yamllint

[error] 19-19: no new line character at the end of file

(new-line-at-end-of-file)

Content.Client/Backmen/Body/BodySystem.cs (1)

15-16: TODO comment needs more context.

The TODO comment is too vague. It should specify:

  1. What exactly needs to be adjusted
  2. What issues exist with player sprite updates
  3. Any dependencies or blockers preventing implementation

Consider updating the comment to be more descriptive:

-                //TODO a few things need to be adjusted before this is ready to be used - also need to find a way to update the player sprite
+                // TODO: Implementation blocked by:
+                // 1. [Specific adjustment needed]
+                // 2. Need to implement player sprite update mechanism through [expected approach]
+                // Related issue: [issue number if exists]
Content.Shared/Body/Part/BodyPartComponent.cs (1)

1-1: Remove the BOM character from the import statement

The line contains a Byte Order Mark (BOM) character which could cause issues in some environments. Consider removing it to maintain consistency.

-using Content.Shared.Backmen.Surgery.Tools;
+using Content.Shared.Backmen.Surgery.Tools;
Content.Client/Backmen/Surgery/SurgeryBui.cs (3)

46-58: Consider extracting the throttle duration as a constant.

The throttling logic is well-implemented, but the magic number 0.2 should be extracted as a named constant for better maintainability.

+ private const float ThrottleDurationSeconds = 0.2f;

  private void OnPlayerItemAdded(string handName, EntityUid item)
  {
      if (_throttling.handName.Equals(handName)
          && _throttling.item.Equals(item)
-         && DateTime.UtcNow - _lastRefresh < TimeSpan.FromSeconds(0.2)
+         && DateTime.UtcNow - _lastRefresh < TimeSpan.FromSeconds(ThrottleDurationSeconds)
          || !_timing.IsFirstTimePredicted
          || _window == null
          || !_window.IsOpen)
          return;

319-319: Consider using trace level for detailed logging.

Debug level logging might be too verbose for production. Consider using trace level for such detailed operational logs.

- Logger.Debug($"Running RefreshUI on {Owner}");
+ Logger.Trace($"Running RefreshUI on {Owner}");

360-379: Consider extracting error handling logic to a separate method.

The error handling switch statement could be extracted to a separate method for better readability and maintainability.

+ private void AppendStepErrorMessage(FormattedMessage stepName, StepInvalidReason reason)
+ {
+     switch (reason)
+     {
+         case StepInvalidReason.MissingSkills:
+             stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-skills")}[/color]");
+             break;
+         case StepInvalidReason.NeedsOperatingTable:
+             stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-table")}[/color]");
+             break;
+         case StepInvalidReason.Armor:
+             stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-armor")}[/color]");
+             break;
+         case StepInvalidReason.MissingTool:
+             stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-tools")}[/color]");
+             break;
+     }
+ }

  // In RefreshUI method:
- switch (reason)
- {
-     case StepInvalidReason.MissingSkills:
-         stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-skills")}[/color]");
-         break;
-     case StepInvalidReason.NeedsOperatingTable:
-         stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-table")}[/color]");
-         break;
-     case StepInvalidReason.Armor:
-         stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-armor")}[/color]");
-         break;
-     case StepInvalidReason.MissingTool:
-         stepName.AddMarkup($" [color=red]{Loc.GetString("surgery-ui-window-steps-error-tools")}[/color]");
-         break;
- }
+ AppendStepErrorMessage(stepName, reason);
Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs (2)

60-63: Simplify symmetry handling by avoiding unnecessary casts and string comparisons

Casting part.Symmetry and comparing enum values as strings can be fragile and less efficient. Instead, directly compare the enum values.

Apply this diff to improve the code:

- var symmetry = ((BodyPartSymmetry) part.Symmetry).ToString();
- if (symmetry == "None")
-     symmetry = "";
+ var symmetry = part.Symmetry != BodyPartSymmetry.None ? part.Symmetry.ToString() : "";

39-40: Optimize null checks for OriginalBody

You're checking part.OriginalBody != null before accessing part.OriginalBody.Value. To simplify and make the code cleaner, consider using pattern matching with null checks.

Apply this diff to streamline the null checks:

- if (TryComp(uid, out BodyPartComponent? part) && part.OriginalBody != null &&
-     TryComp(part.OriginalBody.Value, out HumanoidAppearanceComponent? bodyAppearance))
+ if (TryComp(uid, out BodyPartComponent? part) &&
+     part.OriginalBody is EntityUid originalBody &&
+     TryComp(originalBody, out HumanoidAppearanceComponent? bodyAppearance))
Content.Shared/Body/Systems/SharedBodySystem.Parts.cs (1)

631-638: Consider appearance handling for body parts from different sources

When attaching a body part, you add a BodyPartAppearanceComponent and set its color based on the body's HumanoidAppearanceComponent. This approach works well when the body part originates from the same body. However, if the body part comes from a different entity with different appearance attributes (e.g., skin color or species), this may lead to inconsistent visuals.

Consider updating the logic to preserve the original appearance of the attached body part if it already has a BodyPartAppearanceComponent, or to handle different species appropriately.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0eab1b4 and 7e36461.

📒 Files selected for processing (27)
  • Content.Client/Backmen/Body/BodySystem.cs (1 hunks)
  • Content.Client/Backmen/Surgery/SurgeryBui.cs (5 hunks)
  • Content.Client/Backmen/Surgery/SurgerySystem.cs (1 hunks)
  • Content.Client/Humanoid/HumanoidAppearanceSystem.cs (3 hunks)
  • Content.Server/Backmen/Surgery/SurgerySystem.cs (2 hunks)
  • Content.Server/Body/Systems/BodySystem.cs (3 hunks)
  • Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs (1 hunks)
  • Content.Shared/Backmen/Surgery/Body/BodyPartAppearanceComponent.cs (1 hunks)
  • Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs (1 hunks)
  • Content.Shared/Backmen/Surgery/SharedSurgerySystem.Steps.cs (0 hunks)
  • Content.Shared/Backmen/Surgery/SurgeryUI.cs (0 hunks)
  • Content.Shared/Body/Part/BodyPartComponent.cs (1 hunks)
  • Content.Shared/Body/Part/BodyPartEvents.cs (0 hunks)
  • Content.Shared/Body/Systems/SharedBodySystem.Body.cs (4 hunks)
  • Content.Shared/Body/Systems/SharedBodySystem.Parts.cs (2 hunks)
  • Content.Shared/Body/Systems/SharedBodySystem.cs (0 hunks)
  • Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs (0 hunks)
  • Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs (1 hunks)
  • Resources/Changelog/ChangelogBkm.yml (0 hunks)
  • Resources/Locale/en-US/surgery/surgery-ui.ftl (1 hunks)
  • Resources/Prototypes/Body/Parts/skeleton.yml (0 hunks)
  • Resources/Prototypes/Entities/Mobs/NPCs/animals.yml (1 hunks)
  • Resources/Prototypes/Entities/Mobs/Player/silicon_base.yml (0 hunks)
  • Resources/Prototypes/Entities/Mobs/Species/skeleton.yml (1 hunks)
  • Resources/Prototypes/_Backmen/Body/Parts/shadowkin.yml (0 hunks)
  • Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml (1 hunks)
  • Resources/Prototypes/_Backmen/Entities/Surgery/surgeries.yml (2 hunks)
💤 Files with no reviewable changes (9)
  • Content.Shared/Backmen/Surgery/SharedSurgerySystem.Steps.cs
  • Content.Shared/Backmen/Surgery/SurgeryUI.cs
  • Content.Shared/Body/Part/BodyPartEvents.cs
  • Content.Shared/Body/Systems/SharedBodySystem.cs
  • Content.Shared/Humanoid/Events/ProfileLoadFinishedEvent.cs
  • Resources/Changelog/ChangelogBkm.yml
  • Resources/Prototypes/Body/Parts/skeleton.yml
  • Resources/Prototypes/Entities/Mobs/Player/silicon_base.yml
  • Resources/Prototypes/_Backmen/Body/Parts/shadowkin.yml
🧰 Additional context used
🪛 yamllint
Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml

[error] 19-19: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (32)
Content.Client/Backmen/Surgery/SurgerySystem.cs (1)

Line range hint 1-19: Verify the implications of this revert.

Since this is a revert of PR #567, we should ensure that:

  1. Any dependent systems are aware of the removal of this event handling mechanism
  2. The revert doesn't break existing surgery UI functionality

Let's check for any dependencies on this event:

✅ Verification successful

Let me check the actual usage of OnStep in the SurgeryBui.cs file to understand how it's being used:


Let me check one more thing to understand the server-side implementation and the shared interface:


Based on the gathered information, I can now provide the final response:

The revert appears safe to proceed with

The event handling mechanism is properly contained within the surgery system:

  • The OnStep event is only subscribed to in SurgeryBui.cs for UI refresh purposes
  • The server properly raises SurgeryUiRefreshEvent which is handled by both client and server systems
  • The revert maintains the core surgery functionality through the shared interface (SharedSurgerySystem)

The event is properly cleaned up in the BUI's Dispose method, and there are no other dependencies on this event outside the surgery system's scope.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any references to OnStep in the codebase
rg -l "OnStep" --type cs

# Search for any classes that might be affected by this revert
rg -l "SurgeryBui" --type cs

Length of output: 709


Script:

#!/bin/bash
# Check how OnStep is used in SurgeryBui.cs
rg "OnStep" Content.Client/Backmen/Surgery/SurgeryBui.cs -A 5 -B 5

# Also check the SurgeryUI.cs to understand the shared interface
rg "class SurgeryUI" Content.Shared/Backmen/Surgery/SurgeryUI.cs -A 10

Length of output: 993


Script:

#!/bin/bash
# Check server implementation
rg "class SurgerySystem" Content.Server/Backmen/Surgery/SurgerySystem.cs -A 10

# Check for any UI state updates in server implementation
rg "SurgeryUiRefreshEvent" Content.Server/Backmen/Surgery/SurgerySystem.cs -A 3 -B 3

# Check the shared interface
rg "class SharedSurgerySystem" -A 10

Length of output: 3719

Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml (1)

19-19: Verify the breakout time value.

Since this is a revert PR, please confirm that 5 seconds was indeed the original breakout time value in the codebase before PR #567.

✅ Verification successful

Let me try a different approach to verify the history by looking at the specific PR #567 that this PR is reverting.


Let me try one final approach to check the changes in PR #567 with a corrected query:


The breakout time value of 5 seconds is correct and matches the original implementation.

From the git history, we can see that:

  1. The breakoutTime: 5 property was initially added in commit 4ac368f with PR [FEATURE] Purple maid/sec cuffs Rxup/space-station-14#889 that introduced the purple handcuffs
  2. It was temporarily removed in commit e720e4d with PR [FIX] Cuff popup Rxup/space-station-14#908
  3. This PR correctly restores it back to its original value of 5 seconds
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the history of breakoutTime value for Purplecuffs
# Expected: Find the original value before PR #567

# Search for previous versions of this file
git log -p -- "Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml" | grep -A 1 "breakoutTime:"

Length of output: 156


Script:

#!/bin/bash
# Get the commit details for PR #567 to check the changes made to handcuffs.yml
gh pr view 567 --json commits | jq -r '.commits[].oid' | while read -r commit; do
  git show "$commit" -- "Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml" | grep -A 1 "breakoutTime:"
done

Length of output: 10569


Script:

#!/bin/bash
# Also check if there are any other handcuff-related files that might have this property
fd handcuff -t f | xargs grep -l "breakoutTime"

Length of output: 170


Script:

#!/bin/bash
# Get the base and head commits of PR #567 to see the exact changes
gh pr view 567 --json baseRefOid,headRefOid | jq -r '"\(.baseRefOid) \(.headRefOid)"' | while read -r base head; do
  echo "Changes in PR #567:"
  git diff "$base" "$head" -- "Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml"
done

Length of output: 740


Script:

#!/bin/bash
# Get PR #567 details with correct fields
gh pr view 567 --json headRefName,baseRefName | jq -r '"\(.baseRefName) \(.headRefName)"' | while read -r base head; do
  echo "Checking changes in handcuffs.yml between $base and $head branches"
  git diff "origin/$base...origin/$head" -- "Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml"
done

Length of output: 468


Script:

#!/bin/bash
# Check the commit that added the breakoutTime property initially
git log -p --all --full-history -S "breakoutTime:" -- "Resources/Prototypes/_Backmen/Entities/Objects/Misc/handcuffs.yml"

Length of output: 2419

🧰 Tools
🪛 yamllint

[error] 19-19: no new line character at the end of file

(new-line-at-end-of-file)

Resources/Locale/en-US/surgery/surgery-ui.ftl (1)

9-9: Consider retaining this improved error message.

While this PR is marked as a revert of PR #567, this particular change improves user experience by providing clearer context about missing surgical tools. The new message "You're missing tools for this surgery" is more descriptive and consistent with other error messages in the file. Consider keeping this improvement even if reverting other changes.

Let's verify the original message from PR #567:

Content.Server/Destructible/Thresholds/Behaviors/GibBehavior.cs (1)

16-16: LGTM! Simplified GibBody call aligns with revert objectives.

The removal of gib and contents parameters from the GibBody call is consistent with the revert operation and appears to restore the previous behavior.

Let's verify the method signature change in BodySystem:

✅ Verification successful

The GibBody call signature change is correct and consistent with the codebase

The search results confirm that GibBody is defined in SharedBodySystem.Body.cs with the signature:

public virtual HashSet<EntityUid> GibBody(
    EntityUid bodyId,
    bool gibOrgans = false,
    BodyComponent? body = null,

This matches the usage in GibBehavior.cs and is consistently used across the codebase, validating that the simplified call is correct.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the GibBody method signature in BodySystem
# Expected: Should find the reverted method signature without gib and contents parameters

ast-grep --pattern 'GibBody(EntityUid owner, bool recursive, BodyComponent? body)'

Length of output: 84


Script:

#!/bin/bash
# Let's try a broader search for GibBody method using ripgrep
rg "GibBody" -A 3 --type cs

Length of output: 8682

Content.Client/Backmen/Body/BodySystem.cs (1)

9-18: ⚠️ Potential issue

Implementation appears incomplete and needs clarification.

The UpdateAppearance method contains commented-out functionality and a TODO comment that lacks specific details. Since this is a revert PR, we should ensure this transitional state is intentional and won't cause issues.

Let's verify the impact of these changes:

Consider either:

  1. Implementing the TODO items before merging
  2. Adding more detailed documentation about what adjustments are needed
  3. Reverting this method to its previous implementation if the changes weren't meant to be included in this revert
✅ Verification successful

Let me gather more context about the specific changes in this revert PR by examining the related body system files.


Based on the gathered information, I can now provide a final response:

Commented-out code is intentionally transitional and aligns with component design

The current implementation state is actually correct for this revert PR because:

  1. The BodyPartAppearanceComponent itself has a TODO comment indicating future plans for species and marking support
  2. The server-side implementation is intentionally empty, suggesting a client-only feature
  3. The component is properly structured with networking and state management ([NetworkedComponent, AutoGenerateComponentState])

The commented-out sprite color code and TODO in UpdateAppearance align with the component's design phase, where additional features like species-specific appearances are planned but not yet implemented.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any remaining references to body part markings that might be affected
rg -l "BodyPartAppearanceComponent|MarkingPrototype" --type cs

# Check for any other TODO comments related to appearance updates
rg "TODO.*sprite|TODO.*appearance" --type cs

Length of output: 2496


Script:

#!/bin/bash
# Check the content of BodyPartAppearanceComponent to understand the intended functionality
cat Content.Shared/Backmen/Surgery/Body/BodyPartAppearanceComponent.cs

# Look for related appearance update implementations in other body systems
rg -A 5 "UpdateAppearance.*BodyPart" --type cs

# Check git history for the specific changes being reverted
git show 567 -- Content.Client/Backmen/Body/BodySystem.cs || true

Length of output: 2494

Content.Shared/Backmen/Surgery/Body/BodyPartAppearanceComponent.cs (4)

7-7: LGTM! Component attributes are correctly configured.

The component is properly set up with necessary attributes for networking and state generation.


14-14: LGTM! ID property is well-defined with appropriate type safety.

The property uses correct serialization for prototype IDs and includes clear documentation.


20-20: LGTM! Color property is properly configured with clear documentation.

The nullable Color property correctly handles the skin color fallback case.


23-23: Verify if the TODO comment is still relevant after the revert.

Since this is a revert PR, let's verify if the TODO comment about adding species and markings is still applicable to the current architecture.

Let's check for any related implementations or discussions:

Also applies to: 26-26

✅ Verification successful

Based on the search results, I can generate the final response as we have sufficient evidence about species and marking implementations in the codebase:

TODO comment about species and markings remains relevant

The TODO comment is still applicable as the codebase shows active implementation of species-specific body parts and marking systems:

  • Species-specific body parts exist (e.g. Reptilian parts in multiple texture directories)
  • Active marking system that interacts with body parts (MarkingsSet.cs, HumanoidAppearanceSystem.cs)
  • Current implementation includes species-body part compatibility checks (MustMatchSkin method)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for related species/marking implementations and discussions

# Check for species-related code in body parts
rg -g "!*.{md,txt}" -i "species.*body.*part|body.*part.*species"

# Check for marking-related code in body parts
rg -g "!*.{md,txt}" -i "marking.*body.*part|body.*part.*marking"

# Check for any related TODO comments
rg -g "!*.{md,txt}" "TODO.*species.*marking|TODO.*marking.*species"

Length of output: 2292

Resources/Prototypes/Entities/Mobs/Species/skeleton.yml (1)

44-44: Verify the GibBehavior reversion's impact on the skeleton entity.

The change simplifies the GibBehavior to an empty object syntax { }, which according to the AI summary, aligns with the broader simplification of the BodySystem class. However, since this is a revert PR, we should verify that this change properly restores the previous behavior.

Let's verify the GibBehavior configuration across different entity definitions:

✅ Verification successful

GibBehavior configuration is consistent across entities

The verification shows that:

  • All entities using GibBehavior consistently use the empty object syntax { }
  • The skeleton entity maintains its unique gibSound property separately from GibBehavior
  • This pattern is consistent across various entity types (base mobs, animals, xenomorphs)

The empty GibBehavior configuration appears to be the standard implementation across the codebase, confirming that the revert properly aligns with the existing entity definitions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check GibBehavior configurations across entity definitions
# to ensure consistent behavior after the revert

# Search for GibBehavior configurations
rg -U "GibBehavior.*?\{.*?\}" --type yaml

# Also check for any related gibbing configurations that might be affected
rg "gibContents|gibType|gibSound" --type yaml

Length of output: 888

Content.Server/Body/Systems/BodySystem.cs (2)

111-111: LGTM: GibBody parameter changes are consistent

The addition of gibSoundOverride parameter and corresponding base method call changes maintain consistency with the GibPart method signature while preserving the core gibbing functionality.

Also applies to: 125-125


167-170: Verify the empty UpdateAppearance implementation

The method overrides the base implementation but does nothing, which could affect body part appearance updates. Since this is a revert PR, please confirm if this is the intended behavior.

Let's check how this method is used in the codebase:

✅ Verification successful

Let me gather more context about the client-side implementation and the base class to better understand the impact.


Empty UpdateAppearance implementation is correct for server-side

The empty implementation in the server-side BodySystem.cs is the intended behavior because:

  • The appearance update logic is properly handled on the client-side in Content.Client/Backmen/Body/BodySystem.cs, where it manages sprite color updates
  • The shared base class SharedBodySystem defines the abstract method that both client and server must implement, but only the client needs to handle visual updates
  • The server-side implementation intentionally does nothing as appearance/visual changes are client-side concerns
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for UpdateAppearance method calls and related event handlers
rg -A 3 "UpdateAppearance.*BodyPartAppearanceComponent" 

# Search for any references to BodyPartAppearanceComponent to understand the impact
ast-grep --pattern 'class $_ {
  $$$
  BodyPartAppearanceComponent
  $$$
}'

Length of output: 1018


Script:

#!/bin/bash
# Check the client-side implementation
rg -A 10 "protected override void UpdateAppearance.*BodyPartAppearanceComponent" Content.Client/Backmen/Body/BodySystem.cs

# Check the abstract base implementation
cat Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs

Length of output: 4500

Content.Shared/Body/Part/BodyPartComponent.cs (2)

Line range hint 13-15: Implementation follows component best practices

The component is well-structured with proper access control, networking setup, and clear separation of concerns.


Line range hint 13-15: Verify the impact of removed Species and Sex properties

The removal of these serialized properties might affect existing save data and dependent systems. Let's verify there are no lingering references.

✅ Verification successful

Based on the results from our verification attempts, I can now generate the final response:

Removal of Species and Sex properties appears safe

The verification shows:

  • No direct references to these properties in BodyPartComponent
  • No serialization or migration code depending on these fields
  • The only references to Sex are in HumanoidCharacterProfile and HumanoidAppearanceComponent, which are separate systems
  • No evidence of these properties being used in save data or requiring migration

The properties appear to have been moved to more appropriate components (HumanoidAppearanceComponent) as part of system refactoring, with no lingering dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to the removed properties in the codebase
echo "Checking for Species property references..."
rg -l "Species.*=.*\"\"" --type cs

echo "Checking for Sex property references..."
rg -l "Sex.*=.*Sex\.Male" --type cs

echo "Checking for serialized data usage..."
rg -l "BodyPartComponent.*Species|BodyPartComponent.*Sex" --type cs

Length of output: 578


Script:

#!/bin/bash
# Let's check for more specific patterns and context

# Check for direct references to these properties in BodyPartComponent
echo "Checking BodyPartComponent references..."
rg "Species|Sex" Content.Shared/Body/Part/BodyPartComponent.cs -C 3

# Check for any serialization or data migration code
echo -e "\nChecking serialization and migration code..."
rg "BodyPartComponent.*\b(Serialize|Deserialize|Load|Save|Migrate)" --type cs -C 2

# Check for system interactions with BodyPartComponent
echo -e "\nChecking system interactions..."
rg "IEntityManager.*GetComponent.*BodyPartComponent|EntityQuery.*BodyPartComponent" --type cs -C 2

# Check for any recent changes or migrations
echo -e "\nChecking git history for related changes..."
git log -p --grep="Species\|Sex" -- Content.Shared/Body/Part/BodyPartComponent.cs

Length of output: 1206


Script:

#!/bin/bash
# Let's check for any data migration systems and recent changes in the body system

# Check for any migration systems
echo "Checking for migration systems..."
rg "Migration.*Body|Body.*Migration" --type cs -C 3

# Look for recent changes in SharedBodySystem
echo -e "\nChecking SharedBodySystem changes..."
rg "Species|Sex" Content.Shared/Backmen/Surgery/Body/SharedBodySystem.cs -C 3

# Check for any prototype changes related to body parts
echo -e "\nChecking body part prototypes..."
fd ".*[Bb]ody[Pp]art.*\.yml" --exec cat {}

# Check for any tests that might be affected
echo -e "\nChecking related tests..."
rg "BodyPartComponent.*Test" --type cs -C 2

Length of output: 636

Resources/Prototypes/_Backmen/Entities/Surgery/surgeries.yml (1)

72-72: LGTM: Requirement addition improves surgical safety.

The addition of requirement: SurgeryOpenIncision for head attachment surgery ensures proper surgical procedure and maintains consistency with other similar surgeries in the file.

Content.Client/Humanoid/HumanoidAppearanceSystem.cs (3)

76-76: LGTM: Method signature simplification.

The removal of the overrideSkin parameter simplifies the interface while maintaining the core functionality.


94-95: Verify skin color application behavior.

The simplified condition for skin color application (proto.MatchSkin) might affect how layers inherit skin color. Please ensure this change:

  1. Maintains correct skin color inheritance for layers that should match skin
  2. Preserves custom colors for layers that shouldn't match skin
#!/bin/bash
# Description: Check for potential skin color application issues
# Look for any tests or usages that verify skin color behavior
rg "MatchSkin.*SkinColor" --type cs -A 5

58-58: Verify the impact on custom base layers' skin color handling.

The removal of the overrideSkin parameter might affect how skin color is applied to custom base layers. Please ensure this change doesn't unintentionally force skin color matching on layers that should maintain their custom colors.

✅ Verification successful

Based on the gathered evidence, I can now provide a final response:

The removal of overrideSkin parameter is safe and maintains correct color handling

The code review shows that custom base layers maintain their own color handling through the CustomBaseLayerInfo structure, which explicitly stores color information. When setting layer data for custom base layers, the color is passed directly from info.Color and sexMorph is set to false, ensuring custom colors are preserved. The removal of overrideSkin parameter simplifies the API without affecting the color handling behavior for custom base layers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential skin color-related regressions in custom base layers
# Look for any references to custom base layers and skin color handling
rg -A 5 "CustomBaseLayers.*SkinColor" --type cs

Length of output: 42


Script:

#!/bin/bash
# Let's try a broader search to understand the skin color handling logic
rg "CustomBaseLayer" --type cs -A 5

# Also search for SetLayerData to understand the method's implementation
ast-grep --pattern 'SetLayerData($$$) {
  $$$
}'

Length of output: 18995


Script:

#!/bin/bash
# Let's look at the SetLayerData implementation and its usage
rg "SetLayerData" --type cs -A 10

Length of output: 2507

Content.Client/Backmen/Surgery/SurgeryBui.cs (1)

27-27: LGTM: Clean dependency injection and event subscription setup.

The HandsSystem dependency is properly injected and event subscriptions are correctly set up in the constructor.

Also applies to: 40-43

Content.Shared/Body/Systems/SharedBodySystem.Body.cs (4)

132-132: LGTM: Removed unused parameter.

The removal of the rootPart parameter from MapInitParts call is a clean-up change as the parameter wasn't being used in the method implementation.


186-187: LGTM: Method signature cleanup.

The removal of the unused rootPart parameter from the method signature is consistent with its implementation and improves code clarity.


364-365: LGTM: Simplified method signature by hardcoding constant values.

The removal of gib and contents parameters from GibBody method signature and hardcoding their values (GibType.Gib and GibContentsOption.Drop) is appropriate since these values were constant and didn't need to be configurable.

Also applies to: 381-383


Line range hint 233-252: Verify appearance system integration.

The body part appearance initialization looks correct, but let's verify the integration with the appearance system to ensure proper handling of body part visuals.

✅ Verification successful

Let me gather more specific information about the appearance system integration.


Based on the gathered information, I can now provide the final response:

Body part appearance system integration is properly implemented

The appearance system integration is correctly structured with:

  • Proper event subscriptions for component initialization and body part addition
  • Complete mapping of body parts to visual layers
  • Proper synchronization with the humanoid appearance system
  • Correct handling of custom base layers and color information
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the appearance system integration
# Check for any appearance-related components and systems that might be affected

# Look for appearance component references
echo "Checking appearance component references..."
rg -l "BodyPartAppearanceComponent|HumanoidAppearanceComponent" --type cs

# Look for appearance-related systems
echo "Checking appearance system implementations..."
ast-grep --pattern 'class $_ : IAppearanceSystem
{
  $$$
}'

Length of output: 4676


Script:

#!/bin/bash
# Check for appearance system implementations and related methods

# Look for appearance-related methods in SharedBodySystem.PartAppearance.cs
echo "Checking PartAppearance system implementations..."
rg -A 10 "BodyPartAppearanceComponent" "Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs"

# Check for appearance updates and event handlers
echo "Checking appearance update handlers..."
rg -A 5 "UpdateAppearance|OnAppearanceChange" "Content.Shared/Body/Systems/SharedBodySystem.Body.cs" "Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs"

# Check for visual state handling
echo "Checking visual state handling..."
rg -A 5 "AppearanceComponent|VisualState" "Content.Shared/Backmen/Surgery/Body/BodyPartAppearanceComponent.cs"

Length of output: 3838

Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs (3)

450-450: Verify the impact of LoadProfile changes on voice settings.

Since this is a revert PR, removing the Dirty call and SetTTSVoice functionality might affect voice synchronization. Please ensure that voice settings are properly handled through alternative means if these changes are reverted.

#!/bin/bash
# Description: Check for other voice-related calls that might handle synchronization
# Test: Search for voice-related method calls
rg -l "SetTTSVoice|VoicePrototypeId"

# Test: Search for other methods that might call Dirty after LoadProfile
ast-grep --pattern 'LoadProfile($$$)'

Line range hint 509-534: Verify dependencies on the multi-color marking functionality.

The new AddMarking overload with IReadOnlyList<Color> provides better flexibility. However, since this is a revert PR, we should ensure that removing this overload won't break existing functionality.

If keeping this overload, consider adding validation for the colors list length against the marking's sprite count to prevent index out of range errors:

 public void AddMarking(EntityUid uid,
     string marking,
     IReadOnlyList<Color> colors,
     bool sync = true,
     bool forced = false,
     HumanoidAppearanceComponent? humanoid = null)
 {
     if (!Resolve(uid, ref humanoid)
         || !_markingManager.Markings.TryGetValue(marking, out var prototype))
     {
         return;
     }
 
+    if (colors.Count > prototype.Sprites.Count)
+    {
+        Log.Warning($"More colors provided than sprites for marking {marking}");
+    }
+
     var markingObject = new Marking(marking, colors);
     markingObject.Forced = forced;
     humanoid.MarkingSet.AddBack(prototype.MarkingCategory, markingObject);
 
     if (sync)
         Dirty(uid, humanoid);
 }

Line range hint 536-545: Verify TTS voice handling after revert.

The SetTTSVoice method provides centralized voice management. If this PR reverts these changes, ensure that TTS voice settings are properly handled elsewhere to maintain functionality.

Consider adding validation for the voice ID to ensure it exists in the voice prototypes:

 public void SetTTSVoice(EntityUid uid, string voiceId, HumanoidAppearanceComponent humanoid)
 {
     if (!TryComp<TTSComponent>(uid, out var comp))
         return;
 
+    if (!_proto.HasIndex<TTSVoicePrototype>(voiceId))
+    {
+        Log.Warning($"Invalid TTS voice ID: {voiceId}");
+        return;
+    }
+
     humanoid.Voice = voiceId;
     comp.VoicePrototypeId = voiceId;
 }
Resources/Prototypes/Entities/Mobs/NPCs/animals.yml (1)

403-403: LGTM: GibBehavior implementation looks correct.

The addition of GibBehavior to the cockroach's Destructible component is appropriate and follows the standard pattern for entities that should explode into gibs when taking sufficient blunt damage.

Let's verify this behavior is consistent with other similar small mob entities:

✅ Verification successful

Based on the search results, I can see that GibBehavior is consistently used in similar small mob entities like the mothroach, which also has a GibBehavior triggered by blunt damage. Let me verify the damage thresholds to ensure the implementation is consistent.


Based on the search results, I can now generate the final response as I have verified the GibBehavior implementation across different entities:

GibBehavior implementation is consistent with similar entities

The addition of GibBehavior to the cockroach's Destructible component with a 10 blunt damage threshold is appropriate and consistent with other small mob entities. For comparison:

  • Cockroach: Gibs at 10 blunt damage
  • Mothroach: Gibs at 60 blunt damage
  • Base mobs: Gib at 400 blunt damage

The lower threshold for the cockroach is justified by its smaller size and weaker nature compared to other entities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar GibBehavior implementations in other mob entities
# Look for Destructible components with GibBehavior in mob entities
rg --multiline '(?s)parent:.*SimpleMobBase.*Destructible.*GibBehavior'

Length of output: 43025


Script:

#!/bin/bash
# Search for Destructible components with GibBehavior and their damage thresholds
rg --multiline --multiline-dotall 'type: Destructible.*?thresholds:.*?GibBehavior' -A 10

Length of output: 12873

Content.Shared/Backmen/Surgery/Body/SharedBodySystem.PartAppearance.cs (1)

16-17: Confirm necessity of calling base.Initialize()

In the InitializePartAppearances method, base.Initialize() is being called. Ensure that this call is required; otherwise, it might lead to unexpected behavior if Initialize() is not defined in the base class.

Please check if SharedBodySystem inherits from a base class with an Initialize() method. If not, remove the base.Initialize() call to prevent potential runtime errors.

Content.Server/Backmen/Surgery/SurgerySystem.cs (3)

52-54: Appropriate subscription to prototype reload events and initialization.

The code correctly subscribes to the PrototypesReloadedEventArgs event and calls LoadPrototypes() during initialization. This ensures that surgery prototypes are properly loaded and refreshed when prototypes are modified.


86-91: Effective UI refresh implementation for surgery interface.

By retrieving the UI actors and raising a SurgeryUiRefreshEvent, the code ensures that all clients with the surgery UI open receive timely updates. This addresses the UI refresh issues mentioned in the comment and enhances the responsiveness of the interface.


Line range hint 120-125: Efficient loading of surgery prototypes in LoadPrototypes().

The LoadPrototypes() method efficiently clears and reloads the _surgeries list by enumerating all EntityPrototypes that have a SurgeryComponent. This ensures that the list of available surgeries is always up-to-date with the current prototypes.

Content.Shared/Body/Systems/SharedBodySystem.Parts.cs (1)

179-180: Ensure proper handling of BodyPartEnableChangedEvent when dropping a part

Raising the BodyPartEnableChangedEvent(false) event when a body part is dropped ensures that systems listening for this event can update their state accordingly. Please verify that all relevant event handlers properly handle the Enabled property being set to false to prevent unintended side effects.

Run the following script to check for handlers of BodyPartEnableChangedEvent and ensure they correctly handle the Enabled flag:

✅ Verification successful

Let me gather more information about the usage and impact of the Enabled property.


Let me try a different search pattern to find usages of the Enabled property.


The BodyPartEnableChangedEvent is properly handled throughout the codebase

The event handling is implemented correctly with proper cascading effects:

  • The OnPartEnableChanged handler in SharedBodySystem updates the part's Enabled state and triggers appropriate follow-up actions through EnablePart/DisablePart
  • The system raises specific events (BodyPartEnabledEvent/BodyPartDisabledEvent) that are handled by dependent systems like HandsSystem
  • The hands system properly manages hand functionality when parts are enabled/disabled
  • The enabled state is properly networked through [AutoNetworkedField]
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all event handlers for BodyPartEnableChangedEvent and display surrounding code for context.

# Search for methods subscribing to BodyPartEnableChangedEvent
rg --type cs --context 5 "SubscribeLocalEvent<.*,\s*BodyPartEnableChangedEvent>" 

# Search for methods handling BodyPartEnableChangedEvent
rg --type cs --context 5 "void\s+\w+\(Entity<BodyPartComponent>\s+\w+,\s*ref\s+BodyPartEnableChangedEvent\s+\w+\)"

Length of output: 2519


Script:

#!/bin/bash
# Search for usages of the Enabled property of BodyPartComponent
rg --type cs -C 5 "\.Enabled\b.*BodyPartComponent"

# Search for any methods that might be affected by the enabled state
rg --type cs -C 5 "BodyPartComponent.*\.Enabled\b"

# Search for the BodyPartComponent class definition to understand the Enabled property
ast-grep --pattern 'class BodyPartComponent {
  $$$
  Enabled $$$
  $$$
}'

Length of output: 182


Script:

#!/bin/bash
# Search for the BodyPartComponent class definition and its properties
rg --type cs -C 10 "class BodyPartComponent"

# Search for any references to Enabled in body part related files
rg --type cs -C 5 "Enabled" "Content.Shared/Body/"

# Search for methods that check body part state
rg --type cs -C 5 "(?i)(?:check|is|get).*body.*part.*(?:enabled|disabled)"

Length of output: 9244

@@ -149,7 +149,7 @@
- type: entity
parent: SurgeryBase
id: SurgeryAttachLeftHand
name: Attach Left Hand
name: Attach Left Han
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in surgery name.

There's a typo in the surgery name: "Attach Left Han" should be "Attach Left Hand". This needs to be corrected to maintain consistency with other hand surgeries and ensure proper UI display.

Apply this diff to fix the typo:

-  name: Attach Left Han
+  name: Attach Left Hand
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: Attach Left Han
name: Attach Left Hand

Comment on lines +72 to +73

_system.OnStep -= RefreshUI;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing event unsubscription for OnPlayerItemAdded.

While the OnStep event is properly unsubscribed, the OnPlayerItemAdded event subscription is not cleaned up in the Dispose method.

  protected override void Dispose(bool disposing)
  {
      base.Dispose(disposing);
      if (disposing)
          _window?.Dispose();

      _system.OnStep -= RefreshUI;
+     _hands.OnPlayerItemAdded -= OnPlayerItemAdded;
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
_system.OnStep -= RefreshUI;
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
_window?.Dispose();
_system.OnStep -= RefreshUI;
_hands.OnPlayerItemAdded -= OnPlayerItemAdded;
}

Comment on lines +20 to +34
private static readonly Dictionary<(BodyPartType, BodyPartSymmetry), HumanoidVisualLayers> BodyPartVisualLayers
= new Dictionary<(BodyPartType, BodyPartSymmetry), HumanoidVisualLayers>
{
{ (BodyPartType.Head,BodyPartSymmetry.None), HumanoidVisualLayers.Head },
{ (BodyPartType.Tail,BodyPartSymmetry.None), HumanoidVisualLayers.Tail },
{ (BodyPartType.Torso,BodyPartSymmetry.None), HumanoidVisualLayers.Chest },
{ (BodyPartType.Arm,BodyPartSymmetry.Right), HumanoidVisualLayers.RArm },
{ (BodyPartType.Arm,BodyPartSymmetry.Left), HumanoidVisualLayers.LArm },
{ (BodyPartType.Hand,BodyPartSymmetry.Right), HumanoidVisualLayers.RHand },
{ (BodyPartType.Hand,BodyPartSymmetry.Left), HumanoidVisualLayers.LHand },
{ (BodyPartType.Leg,BodyPartSymmetry.Right), HumanoidVisualLayers.RLeg },
{ (BodyPartType.Leg,BodyPartSymmetry.Left), HumanoidVisualLayers.LLeg },
{ (BodyPartType.Foot,BodyPartSymmetry.Right), HumanoidVisualLayers.RLeg },
{ (BodyPartType.Foot,BodyPartSymmetry.Left), HumanoidVisualLayers.LLeg }
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Prevent potential KeyNotFoundException when accessing BodyPartVisualLayers

Accessing the BodyPartVisualLayers dictionary without verifying if the key exists may lead to a KeyNotFoundException when an unexpected combination of BodyPartType and BodyPartSymmetry is encountered.

Apply this diff to safely access the dictionary:

- var visualLayer = BodyPartVisualLayers[(part.PartType, part.Symmetry)];
+ if (BodyPartVisualLayers.TryGetValue((part.PartType, part.Symmetry), out var visualLayer))
+ {
+     // Existing logic using visualLayer
+ }
+ else
+ {
+     // Handle the missing key scenario
+     // For example, assign a default visualLayer or log a warning
+     visualLayer = HumanoidVisualLayers.Default;
+ }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +73 to +78
if (TryComp(uid, out HumanoidAppearanceComponent? bodyAppearance))
{
_humanoid.SetLayerVisibility(entity, visualLayer, false, true, bodyAppearance);
var part = args.Part;
var customLayers = bodyAppearance.CustomBaseLayers;
var visualLayer = BodyPartVisualLayers[(part.Comp.PartType, part.Comp.Symmetry)];
customLayers[visualLayer] = new CustomBaseLayerInfo(component.ID, customLayers[visualLayer].Color);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add safety check when accessing BodyPartVisualLayers in OnPartAddedToBody

Similar to the previous issue, accessing the dictionary without checking may cause a KeyNotFoundException. Ensure the key exists before using it.

Apply this diff to add a safety check:

- var visualLayer = BodyPartVisualLayers[(part.Comp.PartType, part.Comp.Symmetry)];
+ if (BodyPartVisualLayers.TryGetValue((part.Comp.PartType, part.Comp.Symmetry), out var visualLayer))
+ {
+     // Update customLayers with visualLayer
+     customLayers[visualLayer] = new CustomBaseLayerInfo(component.ID, customLayers[visualLayer].Color);
+ }
+ else
+ {
+     // Handle the missing key scenario appropriately
+     // e.g., log a warning or assign a default value
+ }

Committable suggestion skipped: line range outside the PR's diff.

@CrimeMoot CrimeMoot merged commit a205a5e into master Nov 9, 2024
11 checks passed
@CrimeMoot CrimeMoot deleted the revert-567-upstreams branch November 10, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant