Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Source/Client/Syncing/Handler/SyncAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,18 @@ public void PatchAll(string methodName)

postfix.priority = MpPriority.MpLast;

Multiplayer.harmony.PatchMeasure(method, prefix, postfix);
SyncActions.syncActions[method] = this;
// Types with StaticConstructorOnStartup may be loading resources, which causes issues with
// modded types. I assume that vanilla types end up loading their resources at some point earlier.
if (method.DeclaringType?.Assembly != typeof(Game).Assembly && method.DeclaringType.HasAttribute<StaticConstructorOnStartup>())
LongEventHandler.ExecuteWhenFinished(Patch);
else
Patch();

void Patch()
{
Multiplayer.harmony.PatchMeasure(method, prefix, postfix);
SyncActions.syncActions[method] = this;
}
}
}
}
Expand Down
Loading