The primary reason for me making this issue is to raise some discussion on stuff we could add or change to either improve compatibility, or extend the API. Personally, many of those would be useful when patching compat for mods. However, not all of them are fully needed or something that would be reasonable to implement (specifically the last one).
@Zetrith @notfood I'd appreciate your thoughts on the list I've prepared. Perhaps some other ideas of things to add to here?
I personally would be able to (somewhat quickly) implement the first 4-5 objects on the list here, as well as the one for accessing faction from IPlayerInfo. I believe it would take a few days at most. However, I'm not exactly sure how to easily access current player's PlayerInfo object (tried to look through code, but couldn't find a simple way to do it besides relying on player's username). As for the other positions on this list, I could look into them - but currently don't see them as a priority.
Potential API/Compat improvements and changes that could be implemented:
- Custom handlers for syncing
Verb
- Perhaps this could be done by syncing their parent in a similar way to
IThingHolder? (a list of supported types, and synced using WriteWithImpl<T>/ReadWithImpl<T>)
- Not the most common thing to happen in mods that need compat, but it does happen (currently happening with XVI-MECHFRAME)
- Ability to easily add additional entries to
supportedThingHolders to support custom IThingHolder implementations
- There's currently 1 mod in MP Compat that modifies the list of supported thing holders (Vehicle Framework)
- There's another mod that could have use this (PokéWorld), but was done in a different way
- Change the
VerbOwnerType handler from Pawn to Thing for greater compatibility
- Ability to exclude specific designators from being automatically synced
- We've got
Designator_MechControlGroup in vanilla that doesn't require syncing, and we already exclude it
- Currently would simplify the patch for
AllowTool
- This would require changing
DesignatorFinalizePatch to not cancel execution if the designator is not synced
- Could likely be registered by a method call, as well as an attribute on the designator itself
- A simple way to access and manipulate the 'true'
Selector and WorldSelector selected objects when executing commands
- Currently without using reflection, it's basically impossible to check selected objects or select new ones in a synced context
- Even when using reflection, it's not always possible - it's only possible to access
Selector it if it was temporarily replaced by AsyncTimeComp, but not DebugSync or SyncUtil, as those don't store it in a temporary field
- This currently prevents situations where an object is despawned and a new one replacing it spawned, while also keeping the new object selected (keeping the illusion that it's only a single object)
- A way to access the current player's
IPlayerInfo
- Currently, this can be achieved by iterating over all players and comparing
MP.PlayerName with IPlayerInfo.Username
- Have the current player's
IPlayerInfo actually list the selected objects
- The current player will always have the list empty
- Expand
IPlayerInfo to be able to lookup specific player's faction
- Perhaps some other data that would be useful to include here?
- Ability to push/pop current player faction for situations where it's needed?
- Honestly, haven't really looked into mod compatibility with multifaction, so I'm unsure of how useful this would be
- Easy ability to check ticks for specific context (world/specific map) with async time
- In a couple of situations, I've come across the need to do something based on ticks - however, it was using the world time instead of map time, causing minor issues
- Could be situationally useful to control time on specific maps
- This one would be quite a bit of a stretch, but - ability to easily modify how some objects are synced
- Primary use would be if a mod does something weird, like how Gestalt Engine/Reinforced Mechanoids 2 has a "dummy" pawn tied to a building, which MP fails to sync
- Still, as I said, this is not something that we'll do and likely not something that should end up in API - especially since it doesn't come up often - but I thought I'd throw it in anyway
The primary reason for me making this issue is to raise some discussion on stuff we could add or change to either improve compatibility, or extend the API. Personally, many of those would be useful when patching compat for mods. However, not all of them are fully needed or something that would be reasonable to implement (specifically the last one).
@Zetrith @notfood I'd appreciate your thoughts on the list I've prepared. Perhaps some other ideas of things to add to here?
I personally would be able to (somewhat quickly) implement the first 4-5 objects on the list here, as well as the one for accessing faction from
IPlayerInfo. I believe it would take a few days at most. However, I'm not exactly sure how to easily access current player'sPlayerInfoobject (tried to look through code, but couldn't find a simple way to do it besides relying on player's username). As for the other positions on this list, I could look into them - but currently don't see them as a priority.Potential API/Compat improvements and changes that could be implemented:
VerbIThingHolder? (a list of supported types, and synced usingWriteWithImpl<T>/ReadWithImpl<T>)supportedThingHoldersto support customIThingHolderimplementationsVerbOwnerTypehandler fromPawntoThingfor greater compatibilityDesignator_MechControlGroupin vanilla that doesn't require syncing, and we already exclude itAllowToolDesignatorFinalizePatchto not cancel execution if the designator is not syncedSelectorandWorldSelectorselected objects when executing commandsSelectorit if it was temporarily replaced byAsyncTimeComp, but notDebugSyncorSyncUtil, as those don't store it in a temporary fieldIPlayerInfoMP.PlayerNamewithIPlayerInfo.UsernameIPlayerInfoactually list the selected objectsIPlayerInfoto be able to lookup specific player's faction