-
Notifications
You must be signed in to change notification settings - Fork 68
Framework Definitions
AllowedThread is used to temporarily allow original game code to run on the current thread.
Example:MobilePartyAIPatches.cs
Allowed threads are checked by CallOriginalPolicy. This is useful when patch logic would normally block or redirect the original game call, but a specific section of code needs to execute the original behavior safely.
Notes:
- Supports nested usage.
- Should be used narrowly around the code that needs to bypass patch restrictions.
- Do not use this as a general workaround for threading issues.
AutoSync automatically sends synchronized value updates from the server to clients.
Example: MobilePartyAiSync.cs
Use AutoSync when a server-owned value needs to stay updated on connected clients.
Notes:
- The server is authoritative.
- Clients receive updates automatically when synced values change.
- Custom sync policies are supported, but most use cases should not need them.
GameThread is used to run code on the game thread.
Example: MobilePartyAiHandler.cs
Use GameThread whenever network code needs to mutate game state. Network handlers run on a separate thread from the game thread, and directly modifying game objects from the network thread can cause unsafe behavior, including unpredictable AccessViolationExceptions.
General rule:
- Reading simple immutable/network-safe data may be okay from a network handler.
- Mutating Bannerlord game state should be dispatched through
GameThread. - When in doubt, use
GameThreadfor game object changes triggered by network messages.