Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous loading for ModPrefab #184

Merged
merged 4 commits into from
Sep 4, 2020
Merged

Asynchronous loading for ModPrefab #184

merged 4 commits into from
Sep 4, 2020

Conversation

zorgesho
Copy link
Member

Changes made in this pull request

public changes:

  • asynchronous virtual method IEnumerator GetGameObjectAsync(IOut<GameObject> gameObject) added to the ModPrefab.
    It is supposed to be used like GetGameObject, only all sync operations with game prefabs should be changed to async (examples will be added later).
  • AddPrefabCopy method added to the ModPrefabCache class. It can be used for instantiating prefab and adding that copy to the cache at the same time. That way instantiated copy will not run Awake(), Start() and Update() in both sync and async versions of GetGameObject.

internal changes:

  • ModPrefabRequest class added to the SMLHelper.V2.Assets namespace. It is used to get modded prefabs asynchronously (it calls ModPrefab.GetGameObjectInternalAsync)
  • various changes in PrefabDatabasePatcher (new patch for object deserialization, using of ModPrefabRequest and some refactoring)

All new code supposed to work on both SN branches. Modders can add GetGameObjectAsync methods to their prefabs along with GetGameObject. For now, on the stable branch, GetGameObjectAsync doesn't do/break anything. And exp branch for now can be used to test GetGameObjectAsync (GetGameObject shouldn't break anything on exp branch).
So mods can be updated to use async prefabs ahead of update and when async update will hit stable branch, mods will not be broken (at least because of that).

Copy link
Contributor

@Alexejhero Alexejhero left a comment

Choose a reason for hiding this comment

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

I dont think we should merge any PRs which have TODOs.

SMLHelper/Assets/ModPrefabRequest.cs Outdated Show resolved Hide resolved
SMLHelper/Assets/ModPrefabCache.cs Outdated Show resolved Hide resolved
SMLHelper/Assets/ModPrefab.cs Outdated Show resolved Hide resolved
@zorgesho zorgesho marked this pull request as draft August 28, 2020 17:50
SMLHelper/Assets/ModPrefab.cs Outdated Show resolved Hide resolved
SMLHelper/Patchers/PrefabDatabasePatcher.cs Outdated Show resolved Hide resolved
SMLHelper/Patchers/PrefabDatabasePatcher.cs Show resolved Hide resolved
@zorgesho zorgesho marked this pull request as ready for review September 1, 2020 12:03
Copy link
Member

@PrimeSonic PrimeSonic left a comment

Choose a reason for hiding this comment

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

This is looking good. I can approve this for now since only minor changes should be pending.

Base automatically changed from Dev to master September 2, 2020 07:30
@zorgesho zorgesho changed the base branch from master to dev September 4, 2020 22:51
@zorgesho zorgesho merged commit d9e6e48 into dev Sep 4, 2020
@zorgesho zorgesho deleted the async-prefabs branch September 4, 2020 22:55
@PrimeSonic PrimeSonic mentioned this pull request Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants