Skip to content

Updates and additions to API#9

Merged
Zetrith merged 7 commits intorwmt:developmentfrom
SokyranTheDragon:api-update
Dec 26, 2023
Merged

Updates and additions to API#9
Zetrith merged 7 commits intorwmt:developmentfrom
SokyranTheDragon:api-update

Conversation

@SokyranTheDragon
Copy link
Copy Markdown
Member

@SokyranTheDragon SokyranTheDragon commented Mar 18, 2023

It's going to require changes to MP as well to work rwmt/Multiplayer#381

Several additions to the API:

  • Bumped up the version to 0.5 (from 0.3/0.4) handled by ThingFilterContext and ISyncSimple #10
  • Referenced Harmony NuGet package (needed for MethodType enum, but also used for a few other things) removed
  • Added CanUseDevMode bool property to check if the current player has access to dev mode (made default return false, should we keep it or change it to true/something else?)
  • Added sync method/delegate register method for lambdas/local funcs
  • Added SetHostOnly for sync methods/delegates to bring them on par with sync fields
  • For sync methods/delegates, added transforming arguments, target, and (only for delegates) fields
  • Added ExposeFields for sync delegates
  • Added SetPreInvoke/SetPostInvoke for sync delegates (it was possible to use them before by casting ISyncDelegate to ISyncMethod)
  • Added CancelIfNoSelectedMapObjects and CancelIfNoSelectedWorldObjects for sync delegates, matching sync methods
  • Marked CancelIfNoSelectedObjects as obsolete with a message to use CancelIfNoSelectedMapObjects instead (still works as before) as it's more descriptive
  • Minor changes to XML documentation

# Conflicts:
#	Source/API/Dummy.cs
#	Source/MultiplayerAPI.csproj
@SokyranTheDragon
Copy link
Copy Markdown
Member Author

Merged in changes from #8

@notfood
Copy link
Copy Markdown
Member

notfood commented Jun 12, 2023

API can't depend on Harmony since it needs to be included by random projects that may choose not to use Harmony. Is it being used? I don't see it at first glance.

@SokyranTheDragon
Copy link
Copy Markdown
Member Author

That... I did not consider. My bad. There's 2 different things use Harmony. Shouldn't be that bad to fix.

First - MethodType enum is used in a few methods as arguments. We can just make identical enum on our side (with different name to avoid conflicts). If we match the values 1:1 to the ones from Harmony, we'll just be able to cast them no problem.

Second - since I already dropped in Harmony in, I've also used AccessTools inside of MP.cs for convenience methods. Can be done without those, but will take a bit more space in code. Hopefully won't be an issue.

Also, this will need further changes to due to #10, as some of the changes here overlap with those (I assume that due to changes in MP itself, the changes in my PR would need fixing anyway).

I'll try to look at this tomorrow if I have the time.

@notfood
Copy link
Copy Markdown
Member

notfood commented Jun 12, 2023

Yeah, we can have a copy of the enum just fine.

Sokyran added 2 commits June 20, 2023 00:35
# Conflicts:
#	Source/API/Dummy.cs
#	Source/API/Interfaces.cs
#	Source/API/MP.cs
The usage of Harmony was a big oversight on my part which has now been corrected.

The removal of ThingFilterContext and ISyncSimple happened due to rwmt#10
@SokyranTheDragon
Copy link
Copy Markdown
Member Author

Dropped reliance on Harmony, removed ThingFilterContext and ISyncSimple.

Copy link
Copy Markdown
Member

@notfood notfood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

# Conflicts:
#	Source/API/Dummy.cs
#	Source/API/MP.cs
#	Source/MultiplayerAPI.csproj
@SokyranTheDragon
Copy link
Copy Markdown
Member Author

Fixed merge conflicts

@SokyranTheDragon
Copy link
Copy Markdown
Member Author

I've added another commit with an InInterface getter, as it tends to be really useful.

It's a minor change that shouldn't cause issues, so I made it part of this PR to avoid potential merge conflicts.

I tried to make the summary as good as possible, but I feel it could still be improved.

@Zetrith Zetrith merged commit 5807388 into rwmt:development Dec 26, 2023
Zetrith pushed a commit to rwmt/Multiplayer that referenced this pull request Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants