Skip to content

Fix: NPC spawn animation - #473

Merged
AngeloTadeucci merged 1 commit into
masterfrom
npc-spawn-animation
Jun 5, 2025
Merged

Fix: NPC spawn animation#473
AngeloTadeucci merged 1 commit into
masterfrom
npc-spawn-animation

Conversation

@AngeloTadeucci

@AngeloTadeucci AngeloTadeucci commented Jun 5, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Refactor
    • Simplified spawn animation handling for NPCs by using a string-based approach instead of animation metadata.
    • Updated internal logic to check for the presence of spawn animations using the new string representation.
    • Improved NPC spawning methods to allow optional use of spawn animations.

@coderabbitai

coderabbitai Bot commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor how spawn animations for NPCs are handled. The FieldNpc class now uses a nullable string for spawn animation instead of animation metadata. Related logic in the movement state and trigger context was updated to accommodate this change, including adjustments to method signatures and property access modifiers.

Changes

File(s) Change Summary
.../Actor/ActorStateComponent/MovementStateTasks/MovementState.StandbyTask.cs Changed Sequence and IsIdle properties from public to private; initialization moved to constructor.
.../Actor/FieldNpc.cs Changed SpawnSequence from animation metadata to nullable string SpawnAnimation; logic updated.
.../Trigger/TriggerContext.Npc.cs SpawnNpc method updated to accept useSpawnAnimation flag; spawn animation assignment logic changed.

Sequence Diagram(s)

sequenceDiagram
    participant TriggerContext
    participant FieldNpc
    participant MovementState

    TriggerContext->>FieldNpc: SpawnNpc(spawnId, useSpawnAnimation)
    alt useSpawnAnimation and SpawnAnimation exists
        FieldNpc->>MovementState: TryEmote(spawnAnimation)
    else
        FieldNpc->>MovementState: TryEmote("")
    end
Loading

Suggested reviewers

  • Zintixx

Poem

A string for a dance, a hop and a prance,
The spawn now arrives with a simpler stance.
No metadata fuss, just a name in the air—
The code feels refreshed, much lighter to bear!
Hopping through logic, with carrots in tow,
This rabbit approves—onward we go! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 690ba1e and e4d27d4.

📒 Files selected for processing (3)
  • Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.StandbyTask.cs (1 hunks)
  • Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (4 hunks)
  • Maple2.Server.Game/Trigger/TriggerContext.Npc.cs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.StandbyTask.cs (2)
Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/TaskState.cs (2)
  • TaskState (6-155)
  • TaskState (14-21)
Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementState.cs (2)
  • MovementState (11-324)
  • MovementState (37-48)
Maple2.Server.Game/Trigger/TriggerContext.Npc.cs (2)
Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (2)
  • FieldNpc (22-495)
  • FieldNpc (98-130)
Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.State.cs (2)
  • FieldNpc (105-125)
  • FieldNpc (127-129)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (8)
Maple2.Server.Game/Model/Field/Actor/ActorStateComponent/MovementStateTasks/MovementState.StandbyTask.cs (1)

11-12: LGTM! Good encapsulation improvement.

The change from public to private access modifiers for Sequence and IsIdle properties improves encapsulation. Since these properties are only used internally within the NpcStandbyTask class (in the TaskResumed method), making them private is appropriate and follows the principle of least privilege.

Also applies to: 17-18

Maple2.Server.Game/Trigger/TriggerContext.Npc.cs (3)

25-25: LGTM! Proper parameter forwarding.

The method call correctly forwards the spawnAnimation parameter to the updated SpawnNpc method signature.


280-280: LGTM! Good API design with backward compatibility.

Adding the optional parameter useSpawnAnimation with a default value of false maintains backward compatibility while enabling the new conditional spawn animation feature.


293-297: LGTM! Correct conditional logic for spawn animation.

The implementation properly handles the conditional spawn animation logic:

  • Defaults to empty string when spawn animation should not be used
  • Only applies spawn animation when both conditions are met: useSpawnAnimation is true AND spawn.SpawnAnimation is not null/empty
  • Correctly passes the result to Field.SpawnNpc

This provides the expected behavior for the spawn animation feature.

Maple2.Server.Game/Model/Field/Actor/FieldNpc.cs (4)

79-79: LGTM! Simplified spawn animation representation.

The change from AnimationSequenceMetadata? to string? simplifies the spawn animation handling while maintaining the nullable semantics. This aligns well with the string-based approach used throughout the codebase.


103-103: LGTM! Direct parameter assignment.

The direct assignment of the spawnAnimation parameter to the SpawnAnimation property is clean and straightforward.


253-253: LGTM! Consistent condition update.

The condition change from checking animation metadata to checking SpawnAnimation is not null is consistent with the new string-based spawn animation approach. The logic correctly determines when to use spawn animation for emote tasks.


340-342: LGTM! Proper spawn animation check in Talk method.

The condition update correctly prevents the Talk action when a spawn animation is present, which is the expected behavior. The null check is appropriate for the nullable string type.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@AngeloTadeucci
AngeloTadeucci merged commit 8a075ca into master Jun 5, 2025
@AngeloTadeucci
AngeloTadeucci deleted the npc-spawn-animation branch June 5, 2025 11:51
@coderabbitai coderabbitai Bot mentioned this pull request Jul 9, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants