Skip to content

feat(network-weapon): allow firing multiple projectiles in a single batch - #638

Draft
Nyx255 wants to merge 2 commits into
foxssake:mainfrom
Nyx255:feature/projectile-batch-spawning
Draft

feat(network-weapon): allow firing multiple projectiles in a single batch#638
Nyx255 wants to merge 2 commits into
foxssake:mainfrom
Nyx255:feature/projectile-batch-spawning

Conversation

@Nyx255

@Nyx255 Nyx255 commented Jul 29, 2026

Copy link
Copy Markdown

Overview

This PR introduces the ability to fire multiple projectiles in a single RPC roundtrip for NetworkWeapon. It aims to optimize network traffic for weapons that shoot multiple projectiles simultaneously (e.g., shotguns or burst patterns).


Key Changes

  • Added batch firing capabilities (fire_multiple, _after_fire_multiple, _configure_multi_projectile) to support multi-projectile execution in a single RPC.
  • Extended _NetworkWeaponProxy with callables (c_after_fire_multiple, c_configure_multi_projectile) to ensure full functionality for proxy-based setups.
  • Kept existing single-shot methods (fire(), _after_fire(), etc.) fully intact to guarantee 100% backward compatibility.

Architectural Considerations & Discussion Points

1. Backward Compatibility vs. Code Duplication

Currently, single-shot and multi-shot methods exist side-by-side, which introduces some code duplication.

  • Alternative considered: Merging into a single unified method signature like fire(projectile_count: int = 1) -> Array.
  • Reason for current approach:
    1. Returning a 1-element Array for single shots would introduce breaking changes to existing setups.
    2. GDScript typing constraints (e.g., overriding Array[Node] vs Array[Node2D]) limit clean sub-typing without extra overhead or type cast issues.
  • Question for maintainers: Would you prefer keeping the dedicated batch methods to preserve full backward compatibility, or should we refactor the existing single-shot methods into a single unified array-returning API?

2. _NetworkWeaponProxy Implementation

  • Added the multi-shot callables to _NetworkWeaponProxy. I would appreciate a quick review to ensure this aligns with the intended proxy pattern design.

3. Hitscan Weapons Integration

  • I am currently unsure how or if this batching concept should apply to hitscan implementations, as they don't spawn distinct projectile nodes in the same way.
  • Any guidance or preference on how hitscan multi-shot should be structured within Netfox would be very helpful!

TODO / Next Steps

  • Local testing
  • verification
  • Gather feedback on API / duplicate code vs. breaking changes
  • Clarify hitscan integration scope

Nyx255 added 2 commits July 29, 2026 16:21
…PC roundtrip

- Add batch methods to trigger multiple shots in a single RPC roundtrip
- Retain existing single-shot API for backward compatibility
- Some callbacks were missing for each network weapon type that were now added
- changed the first parameter of the _after_fire_multiple function to just be an untyped Array.
The type check now happens internally.
@Nyx255 Nyx255 changed the title feat(network-weapon): allow firing multiple projectiles in a single R… feat(network-weapon): allow firing multiple projectiles in a single batch Aug 9, 2026
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.

1 participant