Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public void UniverseUpdateBefore(Universe universe, Timestep step)
        {
            Universe = universe;
            if (universe.Server)
            {
                if (ServerMainLoop == null)
                {
                    ServerMainLoop =
                        ServerContext.VillageDirector?.UniverseFacade?
                        .GetPrivateFieldValue <ServerMainLoop>("_serverMainLoop");
                }

                if (SettingsManager.UpdateList.Count > 0)
                {
                    var blob = BlobAllocator.Blob(true);

                    var settings = blob.FetchBlob("settings");

                    foreach (var item in SettingsManager.UpdateList)
                    {
                        settings.FetchBlob(item).MergeFrom(SettingsManager.ModsSettings[item]);
                    }

                    using (var ms = new MemoryStream()) {
                        blob.Write(ms);
                        ms.Seek(0, SeekOrigin.Begin);
                        FxCore.MessageAllPlayers(blob.ToString());
                    }

                    Blob.Deallocate(ref blob);

                    SettingsManager.UpdateList.Clear();
                }
            }
        }
Exemplo n.º 3
0
 internal static void AfterLoad(PlayerEntityLogic __instance)
 {
     if (__instance == null)
     {
         return;
     }
     foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks"))
     {
         if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHookV3 mod)
         {
             var blob = BlobAllocator.Blob(true);
             blob.AssignFrom(__instance.PlayerEntity.Blob);
             mod.OnPlayerLoadAfter(blob);
             Blob.Deallocate(ref blob);
         }
     }
 }
Exemplo n.º 4
0
        public void OnPlayerConnect(Entity entity)
        {
            var blob = BlobAllocator.Blob(true);

            var settings = blob.FetchBlob("settings");

            foreach (var setting in SettingsManager.ModsSettings)
            {
                settings.FetchBlob(setting.Key).MergeFrom(setting.Value);
            }

            if (settings.KeyValueIteratable.Count > 0)
            {
                FxCore.MessagePlayerByEntity(entity, blob.ToString());
            }

            Blob.Deallocate(ref blob);
        }