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

[Fix] Waddle / Походка Клоуна #107

Merged
merged 2 commits into from
Oct 31, 2024
Merged

[Fix] Waddle / Походка Клоуна #107

merged 2 commits into from
Oct 31, 2024

Conversation

Spatison
Copy link
Member

Описание PR

Исправление анимации ботинок клоуна


Изменения

🆑 Spatison

  • fix: Fixing the animation of the clown's shoes / Исправление анимации ботинок клоуна

@Spatison Spatison requested a review from Remuchi October 28, 2024 11:37
@Spatison Spatison self-assigned this Oct 28, 2024
Copy link
Contributor

coderabbitai bot commented Oct 28, 2024

Walkthrough

The changes involve the complete removal of the WaddleAnimationSystem class from the Content.Client.Movement.Systems namespace and the introduction of new WaddleAnimationSystem classes in both the Content.Client._White.Animations and Content.Server._White.Animations namespaces. The event classes StartedWaddlingEvent and StoppedWaddlingEvent have been modified to sealed classes with updated parameters. Additionally, the WaddleClothingSystem has been relocated to a shared namespace, and a new abstract class SharedWaddleAnimationSystem has been added to facilitate animation handling.

Changes

File Path Change Summary
Content.Client/Movement/Systems/WaddleAnimationSystem.cs Class removed: WaddleAnimationSystem
Content.Client/_White/Animations/WaddleAnimationSystem.cs Class added: public sealed class WaddleAnimationSystem, includes PlayAnimation and StopAnimation methods.
Content.Server/_White/Animations/WaddleAnimationSystem.cs Class added: WaddleAnimationSystem, includes PlayAnimation and StopAnimation methods.
Content.Shared/Movement/Components/WaddleAnimationComponent.cs Updated StartedWaddlingEvent and StoppedWaddlingEvent from record structs to sealed classes.
Content.Shared/_White/Clothing/EntitySystems/WaddleClothingSystem.cs Namespace changed from Content.Client.Clothing.Systems to Content.Shared._White.Clothing.EntitySystems.
Content.Shared/_White/Animations/SharedWaddleAnimationSystem.cs Class added: SharedWaddleAnimationSystem, includes abstract methods PlayAnimation and StopAnimation.

Suggested labels

Changes: Localization

Suggested reviewers

  • Remuchi
  • DVOniksWyvern

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
Contributor

@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 (5)
Content.Server/_White/Animations/WaddleAnimationSystem.cs (1)

6-17: Consider adding XML documentation.

To improve code maintainability, consider adding XML documentation to describe:

  • The purpose of this animation system
  • The expected behavior of PlayAnimation and StopAnimation methods
  • The relationship with the network events

Example addition:

+/// <summary>
+/// Server-side implementation of the waddle animation system.
+/// Handles raising network events for animation state changes.
+/// </summary>
 public sealed class WaddleAnimationSystem : SharedWaddledAnimationSystem
 {
+    /// <summary>
+    /// Starts the waddle animation for the specified user by raising a network event.
+    /// </summary>
+    /// <param name="user">The entity to animate</param>
     protected override void PlayAnimation(EntityUid user)
     {
         RaiseNetworkEvent(new StartedWaddlingEvent(GetNetEntity(user)));
     }

+    /// <summary>
+    /// Stops the waddle animation for the specified user by raising a network event.
+    /// </summary>
+    /// <param name="user">The entity to stop animating</param>
     protected override void StopAnimation(EntityUid user)
     {
         RaiseNetworkEvent(new StoppedWaddlingEvent(GetNetEntity(user)));
     }
 }
Content.Shared/Movement/Components/WaddleAnimationComponent.cs (2)

8-14: Enhance parameter documentation clarity

The implementation looks good with proper network serialization support and event inheritance. However, the parameter documentation could be more descriptive.

-/// <param name="user">The newly be-waddled.</param>
+/// <param name="user">The entity that started waddling.</param>

17-24: Enhance parameter documentation clarity

The implementation mirrors StartedWaddlingEvent appropriately. Consider improving the parameter documentation for consistency.

-/// <param name="user">The former waddle-er.</param>
+/// <param name="user">The entity that stopped waddling.</param>
Content.Shared/_White/Animations/SharedWaddledAnimationSystem.cs (2)

12-15: Ensure consistent access modifiers for dependency fields

The dependency fields have inconsistent access modifiers: Timing is protected, while _standingState, _gravity, and _buckle are private. For consistency, consider using the same access modifier for all dependency fields. If derived classes need access to these dependencies, they should all be protected; otherwise, they can all be private.


48-50: Use consistent parameter names for EntityUid

The methods PlayAnimation and StopAnimation use the parameter name user for EntityUid, whereas the rest of the code uses uid. For consistency and clarity, consider renaming the parameter to uid.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6093d72 and 718dba7.

📒 Files selected for processing (6)
  • Content.Client/Movement/Systems/WaddleAnimationSystem.cs (0 hunks)
  • Content.Client/_White/Animations/WaddleAnimationSystem.cs (1 hunks)
  • Content.Server/_White/Animations/WaddleAnimationSystem.cs (1 hunks)
  • Content.Shared/Movement/Components/WaddleAnimationComponent.cs (1 hunks)
  • Content.Shared/_White/Animations/SharedWaddledAnimationSystem.cs (1 hunks)
  • Content.Shared/_White/Clothing/EntitySystems/WaddleClothingSystem.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • Content.Client/Movement/Systems/WaddleAnimationSystem.cs
✅ Files skipped from review due to trivial changes (1)
  • Content.Shared/_White/Clothing/EntitySystems/WaddleClothingSystem.cs
🔇 Additional comments (4)
Content.Server/_White/Animations/WaddleAnimationSystem.cs (1)

1-4: LGTM! Clean and minimal imports.

The imports and namespace structure are well-organized and follow the server-side conventions.

Content.Shared/Movement/Components/WaddleAnimationComponent.cs (2)

2-2: LGTM: Required using statement added for serialization support

The addition of the Serialization namespace is necessary for the new network serialization attributes.


11-12: Verify network event handling implementation

The events are now network-serializable. Let's ensure all systems properly handle these networked events.

Also applies to: 21-22

✅ Verification successful

Let me gather more information about the event handling implementation by checking the actual systems.


Network event handling is properly implemented

The verification shows that the network events are correctly implemented across the client-server architecture:

  • Server raises network events using RaiseNetworkEvent for both start and stop events
  • Client subscribes to these events using SubscribeAllEvent and handles them appropriately
  • Events are properly serializable with the required attributes
  • The component and systems maintain proper separation of concerns between client, server, and shared code
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for proper event handling implementation in both client and server systems

# Look for systems that raise these events
echo "Systems that raise these events:"
rg -l "StartedWaddlingEvent|StoppedWaddlingEvent" --type cs

# Check for proper event subscriptions
echo -e "\nEvent subscriptions:"
ast-grep --pattern 'Subscribe<$_(StartedWaddlingEvent|StoppedWaddlingEvent)>'

Length of output: 452


Script:

#!/bin/bash
# Check the implementation details of the systems
echo "=== Server System Implementation ==="
cat Content.Server/_White/Animations/WaddleAnimationSystem.cs

echo -e "\n=== Client System Implementation ==="
cat Content.Client/_White/Animations/WaddleAnimationSystem.cs

echo -e "\n=== Shared Component Definition ==="
cat Content.Shared/Movement/Components/WaddleAnimationComponent.cs

Length of output: 7345

Content.Shared/_White/Animations/SharedWaddledAnimationSystem.cs (1)

24-46: Logic in OnMovementInput method is correct and well-structured

The OnMovementInput method effectively manages the waddling animation state based on movement input and entity conditions. The use of early returns enhances readability and performance.

Copy link
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (1)
Content.Client/_White/Animations/WaddleAnimationSystem.cs (1)

39-39: Use Constants for Magic Numbers

For better readability and maintainability, consider defining a constant for the value 360.

Add the constant at the class level:

private const float FullRotationDegrees = 360f;

Then update the line:

-var tumbleIntensity = component.LastStep ? 360 - component.TumbleIntensity : component.TumbleIntensity;
+var tumbleIntensity = component.LastStep ? FullRotationDegrees - component.TumbleIntensity : component.TumbleIntensity;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 718dba7 and 67918ac.

📒 Files selected for processing (3)
  • Content.Client/_White/Animations/WaddleAnimationSystem.cs (1 hunks)
  • Content.Server/_White/Animations/WaddleAnimationSystem.cs (1 hunks)
  • Content.Shared/_White/Animations/SharedWaddleAnimationSystem.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Content.Server/_White/Animations/WaddleAnimationSystem.cs
🔇 Additional comments (7)
Content.Shared/_White/Animations/SharedWaddleAnimationSystem.cs (4)

12-15: Dependencies are correctly injected.

The dependencies are properly declared and injected using the [Dependency] attribute, ensuring that all necessary systems are available for this class.


17-22: Initialization correctly subscribes to movement events.

The Initialize method appropriately calls base.Initialize() and subscribes to the MoveInputEvent for the WaddleAnimationComponent, which is essential for handling movement input.


24-46: Effective handling of movement input for waddling animation.

The OnMovementInput method efficiently manages the logic to start and stop the waddling animation based on the entity's state and directional movement input.


48-50: Abstract methods enforce consistent animation behavior in derived classes.

Defining PlayAnimation and StopAnimation as abstract methods ensures that all inheriting classes implement these methods, promoting a consistent and extendable design for animation handling.

Content.Client/_White/Animations/WaddleAnimationSystem.cs (3)

24-25: Previous Comment Still Applicable: Replace GetEntity(ev.User) with ev.User

The method GetEntity used in PlayAnimation(GetEntity(ev.User)) and StopAnimation(GetEntity(ev.User)) is not defined and may not be necessary. If ev.User is already an EntityUid, you can pass it directly.


30-30: Previous Comment Still Applicable: Inject IGameTiming and Update Reference to Timing

The Timing object used in the condition !Timing.IsFirstTimePredicted is not defined within the scope of this class. You need to inject IGameTiming via dependency injection to access timing information.


57-59: Previous Comment Still Applicable: Correct KeyFrame Times to Complete the Animation

The KeyFrames in your AnimationTracks have duplicate times at len/3, causing the animation to reset prematurely. The final keyframe should occur at len to match the total length of the animation.

Also applies to: 69-71

@Remuchi Remuchi merged commit 579444c into master Oct 31, 2024
10 checks passed
@Remuchi Remuchi deleted the waddle-fix branch October 31, 2024 03:22
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.

2 participants