Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

Changed verb syncing to work closer like IThingHolder

Open SokyranTheDragon opened this issue 1 year ago • 2 comments

One of the changes I've proposed in #411, but without any API implementation.

List of changes:

  • VerbOwnerType enum was removed and replaced by supportedVerbOwnerTypes array
  • The array includes typeof(Thing) instead of typeof(Pawn) for increased compatibility
  • IVerbOwner sync worker entry was added
  • Verb sync worker entry was modified to sync the owner as IVerbOwner

Those changes should result in greater compatibility, as new supported IVerbOwner types can now be added to the array and synced using their own sync workers.

This should also end up simplifying Verb sync worker going forward, as we won't have to expand it anymore in the future - only the array of supported types.

Things that I did not include, but we may want to potentially consider:

  • Add more vanilla types to the list of supported verb owners, which could include:
    • HediffComp (specifically due to HediffComp_VerbGiver) - in vanilla RW they don't have gizmos, but a mod could add a custom hediff comp that adds them
    • Pawn_MeleeVerbs_TerrainSource - likely will never get gizmos, probably will be completely pointless to include
    • Pawn_NativeVerbs - same as above
  • Automatically including all subtypes of IVerbOwner which have a(n explicit) sync worker
    • Would simplify mod compat, as mods would (likely) never need to modify the list of supported verb owners
    • Could have potentially unintended consequences?

SokyranTheDragon avatar Jan 03 '24 18:01 SokyranTheDragon

I think IVerbOwner and ISelectable can just be handled like the other interfaces. The worst that can happen is an error message when syncing an unsupported implementation.

Zetrith avatar Jan 06 '24 11:01 Zetrith

I've attempted to sync IVerbOwner like other interfaces, but sadly - it doesn't look like it'll work without other changes. I thought I managed to fix it, but seems like it's not the case, so I reverted the commit.

The issue is trying to sync (for example) a Pawn, which causes it to be synced as IVerbOwner. IVerbOwner then tries to sync the Pawn as IVerbOwner, which tries to... You get the idea. It tries to recursively sync Pawn as IVerbOwner over and over until the game crashes.

SokyranTheDragon avatar Jan 07 '24 17:01 SokyranTheDragon

This should be entirely addressed by b5a01c3

Zetrith avatar Apr 10 '24 22:04 Zetrith