internal static void AfterSave(PlayerEntityLogic __instance, Blob __state) { if (__instance == null) { return; } __state.FetchBlob("collections").MergeFrom(__instance.PlayerEntity.Blob.GetBlob("collections")); __state.SetBool("dontStare", __instance.PlayerEntity.GetPrivateFieldValue <bool>("NPCsDontStare")); __state.SetLong("theftCount", __instance.PlayerEntity.GetPrivateFieldValue <long>("_theftCount")); __state.SetLong("theftResetDay", __instance.PlayerEntity.GetPrivateFieldValue <long>("_theftResetDay")); __state.SetBool("hasSoldToMerchant", __instance.PlayerEntity.GetPrivateFieldValue <bool>("HasSoldToMerchant")); foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks")) { if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHookV3 mod) { mod.OnPlayerSaveAfter(__instance, out var blob); if (blob != null) { __state.MergeFrom(blob); } } } ServerContext.EntityBlobDatabase.Set(__instance.Uid(), __instance.DisplayName(), EntityStorageKey.OtherPlayerData, __state); Blob.Deallocate(ref __state); }
internal static void BeforeSave(PlayerEntityLogic __instance, Blob __state) { __state = BlobAllocator.Blob(true); if (__instance == null) { return; } foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks")) { if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHookV3 mod) { mod.OnPlayerSaveBefore(__instance, out var blob); if (blob != null) { __state.MergeFrom(blob); } } } }