feat: introduce configurable weapon catalogs#330
Merged
Conversation
* Replace GtaWeapons with WeaponCatalog abstraction * Introduce WeaponDefinitions as the source of weapon definitions * Add Walking, Run and Mixed weapon catalogs * Add WeaponCatalogSettings for catalog selection * Register weapon catalogs through dependency injection * Remove hardcoded dependency on a global weapon collection * Make weapon availability configurable through application settings
* Replace GtaWeapons tests with WeaponCatalogBase tests * Simplify WeaponPack tests * Remove assumptions about default weapons * Add validation tests for WeaponCatalogSettings * Update test data to use WeaponDefinitions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces configurable weapon catalogs and refactors the weapon module to support different gameplay styles without modifying consumer code.
The previous implementation relied on a static
GtaWeaponscollection that exposed all available weapons globally. While simple, it made it difficult to restrict weapon availability or support alternative weapon sets.Changes
Weapon catalogs
Introduced a catalog-based architecture:
WalkingWeaponCatalogRunWeaponCatalogMixedWeaponCatalogEach catalog defines the weapons available for a specific gameplay style.
Weapon definitions
Introduced
WeaponDefinitionsas the canonical source of weapon definitions.Weapon metadata such as slots are now defined in a single place and reused across catalogs.
Weapon catalog abstraction
Introduced:
WeaponCatalogBaseWeaponCatalogWeaponCatalogSettingsWeaponCatalogTypeThe active catalog can now be selected through configuration.
Example:
Dependency injection
Weapon catalogs are registered through the DI container and resolved dynamically based on the configured catalog type.
This removes the need for a global static weapon collection while keeping the public API simple for consumers.
Weapon pack
WeaponPackno longer relies on implicit default weapons.New weapon packs start empty and are populated through the existing weapon selection flow.
This prevents inconsistencies when changing the active weapon catalog.
Architectural decisions
Why replace GtaWeapons?
The previous design assumed a single global weapon collection.
Introducing catalogs allows the server to restrict available weapons depending on the selected gameplay style while preserving a consistent API.
Why keep WeaponDefinitions?
Weapon definitions contain shared metadata such as weapon slots.
Keeping these definitions centralized avoids duplication across catalogs and ensures consistency.
Why start WeaponPack empty?
Weapon packs represent player-selected weapons.
Since players already select their weapons through the weapon selection dialog, pre-populating weapon packs introduces unnecessary state and can lead to inconsistencies when the active catalog changes.
For example, if a player's weapon pack contains a weapon that is not available in the currently selected catalog, catalog lookup operations such as GetById() or GetByName() may fail because the weapon can no longer be resolved through the active catalog.
Testing
WeaponCatalogSettings.WeaponPacktests by removing assumptions about default weapons.WeaponCatalogBase.