it will be easier to use with callbacks, mentioned not all methods, i think u got the idea:
private object TryPaste(Vector3 startPos, string filename, BasePlayer player, float RotationCorrection, string[] args, bool autoHeight = true, Action callback = null)
{
...
Paste(preloadData, protocol, startPos, player, stability, RotationCorrection, autoHeight ? heightAdj : 0, auth, callback );
return true;
}
private void Paste(ICollection<Dictionary<string, object>> entities, Dictionary<string, object> protocol, Vector3 startPos, BasePlayer player, bool stability,
float RotationCorrection, float heightAdj, bool auth, Action callback = null)
{
...
NextTick(() => PasteLoop(pasteData,callback ));
}
private void PasteLoop(PasteData pasteData, Action callback = null)
{
...
if (callback != null)
callback.Invoke();
}
and for pasting data maybe you prefer to use something like this, idk how it would be better to implement yield in coroutine, maybe other way...
ServerMgr.Instance.StartCoroutine(PasteLoop(PasteData pasteData, callback));
public IEnumerator PasteLoop(PasteData pasteData, Action callback = null)
{
for (...)
{
DOSOMETING();
yield return new WaitForEndOfFrame();
}
}