How kerema14/startasanyone works
Project Type and Purpose
• This is a game mod (plugin) for Mount & Blade II: Bannerlord. Its purpose is to allow players to start as any existing lord by integrating with the game’s character-creation flow.
• It is written in C# (.cs files, .csproj, Solution) and uses Harmony for runtime patching plus XML data for GUI/layout and localization.
File-Structure Analysis
• Top-level C# files:
• CharacterCreation*.cs, HeroInfoPageVM.cs, KingdomInfoPageVM.cs, etc. — these implement new view-models and actions injected into the game UI.
• DestroyClanAction2.cs, ReflectionHelper.cs — utility and action-patch classes.
• StartAsAnyone.csproj(.user), StartAsAnyone.sln — build and solution definitions.
• _Module directory:
• GUI/Prefabs/*.xml — UI definitions for new screens in Bannerlord’s XML‐based layout system.
• ModuleData/Languages/* — language packs (EN, DE, FR, etc.).
• SubModule.xml — Bannerlord’s module descriptor (metadata, assemblies to load, dependencies like Harmony).
• No separate backend/frontend; instead:
• Game Engine (Bannerlord) hosts the mod assembly.
• Harmony dependency (external mod) required for patching game methods.
README Insights
• Describes features, installation steps, dependencies (Harmony), and integration points (main menu → character creation screen).
Diagramming the Architecture
a. Main Components
• Bannerlord Game Engine
• Harmony Patcher (external mod dependency)
• StartAsAnyone Mod Assembly (C# DLL)
• Patches & Hooks (ReflectionHelper, Harmony patches)
• ViewModels & Actions (CharacterCreationHeroVM, DestroyClanAction2, etc.)
• XML GUI Prefabs (CharacterCreationStartAsAnyoneOrNewStage.xml)
• Localization ModuleData (language_data.xml, strings.xml)
• SubModule Descriptor (SubModule.xml)
b. Relationships & Interactions
• Bannerlord loads SubModule.xml → identifies and loads the mod’s DLL and XML resources.
• Harmony initializes first: injects patch methods (via ReflectionHelper) into game’s character creation code paths.
• When user opens Character Creation:
• Game calls patched methods → instantiates mod’s ViewModels and Actions.
• XML Prefabs render additional UI controls.
• Localization: UI strings loaded from ModuleData/Languages based on game locale.
c. Architectural Patterns & Principles
• Plugin/Patch architecture using Harmony AOP (Aspect-Oriented Programming).
• MVVM pattern for UI integration (ViewModels + XML Views/Prefabs).
• Resource modularization: separate ASM, GUI, and language packs.
d. Key Technologies
• C#, .NET Core (Bannerlord modding API)
• Harmony for method patching
• Bannerlord XML UI system
• Git for source/version control