Development environment setup
Prerequisites
- .NET 6.0 SDK - Required for building the mod
- Visual Studio 2022 or JetBrains Rider - Recommended IDEs with C# support
- MegaBonk - The game must be installed via Steam
- BepInEx IL2CPP - Mod loader for Unity IL2CPP games
Required libraries
The project references these assemblies from your MegaBonk installation:MEGABONK_SIMPLE_MOD.csproj
Libs/ directory in your project root.
Project configuration
The mod targets .NET 6.0 and uses unsafe code for IL2CPP interop:MEGABONK_SIMPLE_MOD.csproj
Unity assemblies
You’ll also need Unity engine assemblies from your MegaBonk installation:UnityEngine.dllUnityEngine.CoreModule.dllUnityEngine.IMGUIModule.dll- For GUI renderingUnityEngine.PhysicsModule.dllUnityEngine.UI.dllUnity.TextMeshPro.dll
Building the mod
Via Visual Studio
- Open
MEGABONK_SIMPLE_MOD.csprojin Visual Studio - Ensure all assembly references are resolved
- Build > Build Solution (or press
Ctrl+Shift+B) - The compiled DLL will be in
bin/Debug/net6.0/orbin/Release/net6.0/
Via command line
Installing your build
Copy the compiledMEGABONK_SIMPLE_MOD.dll to:
Testing approach
Manual testing workflow
- Build the mod with your changes
- Copy DLL to the BepInEx plugins folder
- Launch MegaBonk from Steam
- Check BepInEx console for load confirmation:
- Start a game and verify tracking behavior
- Check logs in
BepInEx/LogOutput.logfor detailed output
Debugging techniques
Use liberal logging:Common testing scenarios
- Round start: Verify all trackers reset to 0
- Object spawns: Check counts increment correctly
- Interactions: Verify interaction counts update
- Round end: Confirm tracking disables and overlay cleans up
- Scene transitions: Ensure overlay persists across level changes
- Multiple rounds: Test tracker reset behavior
Code style
Match the existing code patterns to maintain consistency:Naming conventions
Harmony patch structure
Follow this pattern for consistency:Logging format
Use consistent log prefixes:[SpawnLogger]- General mod events[ChestTracker]- Chest-related events[ShadyGuy]- ShadyGuy events[ShrineTracker]- Shrine events[OverlayManager]- Overlay lifecycle
Comments and documentation
Submitting improvements
Before submitting
- Test thoroughly - Verify your changes work across multiple rounds
- Check logs - Ensure no errors or warnings are introduced
- Follow style - Match existing code patterns
- Add logging - Include appropriate log statements for debugging
- Update trackers - If adding new tracking, update
SafeCleanup()and overlay display
Pull request checklist
- Code builds without errors
- Tested in actual game environment
- Follows existing code style
- Includes logging for new features
- Updates overlay UI if adding new trackers
- Adds appropriate
Reset()calls for new trackers - No errors in BepInEx console during testing
Contribution ideas
Here are some ways to contribute: New trackers:- Track additional interactable types
- Monitor enemy spawns
- Count item pickups
- Configurable overlay position
- Toggle overlay visibility with hotkey
- Export tracking data to file
- Statistical summaries (averages, best runs)
- Refactor duplicate code patterns
- Improve error handling
- Optimize patch performance
- Add configuration options
- Improve code comments
- Add usage examples
- Document undocumented game classes
GitHub repository
The SpawnTracker source code is hosted on GitHub: Repository: github.com/AntiParty/SpawnTracker- Issues: Report bugs or request features
- Pull Requests: Submit code contributions
- Discussions: Ask questions or share ideas
Getting help
If you encounter issues while developing:- Check BepInEx logs - Most issues show up in
LogOutput.log - Review Harmony docs - https://harmony.pardeike.net/
- Inspect game assemblies - Use dnSpy or ILSpy to examine MegaBonk’s code
- Ask in discussions - The community can help troubleshoot