Esempio n. 1
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();
                }
            }
        }
Esempio n. 2
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);
        }
Esempio 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);
         }
     }
 }
Esempio 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);
        }
Esempio n. 5
0
 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);
             }
         }
     }
 }
Esempio n. 6
0
 public void OnPlayerSaveAfter(PlayerEntityLogic logic, out Blob saveBlob)
 {
     saveBlob = null;
 }
Esempio n. 7
0
 public void OnPlayerLoadAfter(Blob blob)
 {
 }