Пример #1
0
        public static void Postfix(ref ZNetScene __instance)
        {
            if (piecesAdded)
            {
                return;
            }
            piecesAdded = true;

            try {
                Plugin.Logger.LogInfo("Adding pieces to the hammer.");
                var hammer = ZNetScene.instance.GetPrefab("Hammer");

                foreach (GameObject pieceGo in UnityBundle.Database.Pieces)
                {
                    Plugin.Logger.LogInfo($"Setting up {pieceGo.name}.");
                    var pieceConfig = AppConfig.instance.Pieces[pieceGo.name];
                    var piece       = pieceGo.GetComponent <ValheimStands.Unity.CustomPiece>();
                    Plugin.Logger.LogInfo($"Calling LoadConfig on {piece}.");
                    piece.LoadConfig(pieceConfig);
                    Plugin.Logger.LogInfo($"Adding {piece} to the hammer's piece table.");
                    hammer.GetComponent <ItemDrop>().m_itemData.m_shared.m_buildPieces.m_pieces.Add(pieceGo);
                }
            }catch (Exception exc) {
                Plugin.Logger.LogError(exc);
            }
        }
Пример #2
0
        private static bool Prefix(ref ZNetScene __instance)
        {
            if (ZNetScene.instance.InLoadingScreen())
            {
                return true;
            }

            if (objectScanThread == null)
            {
                VFPSModPlugin.VFPSModLogger.LogInfo($"Starting ObjectScanThread.");

                objectScanThread = new ObjectScanThread();

                // Force run scan once.
                objectScanThread.RunScan();

                // Then start thread.
                Thread scanThread = new Thread(objectScanThread.ThreadEx);
                scanThread.Start();
            }

            __instance.m_tempCurrentObjects.Clear();
            __instance.m_tempCurrentDistantObjects.Clear();

            __instance.m_tempCurrentObjects = new List<ZDO>(ObjectScanThread.CurrentObjects);
            __instance.m_tempCurrentDistantObjects = new List<ZDO>(ObjectScanThread.CurrentDistantObjects);

            __instance.CreateObjects(__instance.m_tempCurrentObjects, __instance.m_tempCurrentDistantObjects);
            __instance.RemoveObjects(__instance.m_tempCurrentObjects, __instance.m_tempCurrentDistantObjects);

            // Skip original code.
            return false;
        }
Пример #3
0
            public static void Prefix(ZNetScene __instance)
            {
                if (__instance == null)
                {
                    return;
                }

                if (customItems.Count > 0)
                {
                    foreach (var gameObject in customItems)
                    {
                        __instance.m_prefabs.RemoveAll(i => i.name == gameObject.gameObject.name);
                        __instance.m_prefabs.Add(gameObject.gameObject);
                    }
                }

                if (myItemList.Count > 0)
                {
                    foreach (GameObject gameObject in myItemList)
                    {
                        __instance.m_prefabs.RemoveAll(i => i.name == gameObject.name);
                        __instance.m_prefabs.Add(gameObject);
                    }
                }
            }
Пример #4
0
 public static void Prefix(ZNetScene __instance)
 {
     foreach (GameObject go in objectsToAdd.Values)
     {
         __instance.m_prefabs.Add(go);
     }
 }
Пример #5
0
        /// <summary>
        ///     Register a single prefab to the current <see cref="ZNetScene"/>.<br />
        ///     Checks for existence of the object via GetStableHashCode() and adds the prefab if it is not already added.
        /// </summary>
        /// <param name="gameObject"></param>
        public void RegisterToZNetScene(GameObject gameObject)
        {
            ZNetScene znet = ZNetScene.instance;

            if (znet)
            {
                string name = gameObject.name;
                int    hash = name.GetStableHashCode();

                if (znet.m_namedPrefabs.ContainsKey(hash))
                {
                    Logger.LogDebug($"Prefab {name} already in ZNetScene");
                }
                else
                {
                    if (gameObject.GetComponent <ZNetView>() != null)
                    {
                        znet.m_prefabs.Add(gameObject);
                    }
                    else
                    {
                        znet.m_nonNetViewPrefabs.Add(gameObject);
                    }
                    znet.m_namedPrefabs.Add(hash, gameObject);
                    Logger.LogDebug($"Added prefab {name}");
                }
            }
        }
Пример #6
0
 public static void ValRegister(ZNetScene zns)
 {
     foreach (var item in odbRegList.Values)
     {
         zns.m_prefabs.Add(item);
     }
     DBG.blogInfo("Register odb to zns");
 }
Пример #7
0
 static void Awake_Prefix(ref ZNetScene __instance)
 {
     // add birchtree if it needs to be?
     if (null != Plugin.BirchTreeSapling && !__instance.m_prefabs.Contains(Plugin.BirchTreeSapling))
     {
         __instance.m_prefabs.Add(Plugin.BirchTreeSapling);
     }
 }
Пример #8
0
 static void Postfix(ZNetScene __instance)
 {
     if (!modEnabled.Value)
     {
         return;
     }
     LoadAllArmorData(__instance);
 }
Пример #9
0
 public static void TryRegisterFabs(ZNetScene zNetScene)
 {
     if (zNetScene == null || zNetScene.m_prefabs == null || zNetScene.m_prefabs.Count <= 0)
     {
         return;
     }
     zNetScene.m_prefabs.Add(aedenkey);
 }
Пример #10
0
 static void Prefix(ZNetScene __instance)
 {
     if (!modEnabled.Value || !Player.m_localPlayer)
     {
         return;
     }
     ResetBackpackSector();
 }
Пример #11
0
            public static void Prefix(ZNetScene __instance)
            {
                if (__instance == null)
                {
                    return;
                }

                __instance.m_prefabs.Add(ExampleSword);
            }
Пример #12
0
 private static void Postfix(ZNetScene __instance)
 {
     prefabManager.PostZNS();
     GetFirework();
     if (Player.m_localPlayer != null)
     {
         SetPlayerSpwanEffect();
     }
 }
Пример #13
0
 public static void TryRegisterFabs(ZNetScene zNetScene)
 {
     if (zNetScene == null || zNetScene.m_prefabs == null || zNetScene.m_prefabs.Count <= 0)
     {
         return;
     }
     zNetScene.m_prefabs.Add(bombstick);
     zNetScene.m_prefabs.Add(bomb);
     zNetScene.m_prefabs.Add(bombammo);
 }
Пример #14
0
 static void ZNetScene_GetPrefab_Postfix(ZNetScene __instance, int hash, ref GameObject __result)
 {
     if (__result == null &&
         interceptGetPrefab)
     {
         interceptGetPrefab = false;
         PlanBuild.Instance.ScanHammer(true);
         __result           = __instance.GetPrefab(hash);
         interceptGetPrefab = true;
     }
 }
Пример #15
0
 public static void TryRegisterPrefabs(ZNetScene zNetScene)
 {
     if (zNetScene == null)
     {
         return;
     }
     foreach (var rune in runesData)
     {
         zNetScene.m_prefabs.Add(rune.prefab);
     }
 }
Пример #16
0
 // Refs:
 //  - ZNetScene.m_prefabs
 //  - Piece
 public static void ModifyExistingPieces(ZNetScene scene)
 {
     foreach (GameObject prefab in scene.m_prefabs)
     {
         var piece = prefab.GetComponent <Piece>();
         if (piece)
         {
             ModifyPiece(piece, false);
         }
     }
 }
Пример #17
0
 private static void Postfix(ZNetScene __instance)
 {
     try
     {
         PostfixEvent?.Invoke(__instance);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message + Environment.NewLine + ex.StackTrace);
     }
 }
Пример #18
0
 // Refs:
 //  - ZNetScene.m_prefabs
 public static void RegisterPrefabs(ZNetScene scene)
 {
     foreach (GameObject prefab in scene.m_prefabs)
     {
         if (ShouldIgnorePrefab(prefab))
         {
             continue;
         }
         CreatePrefabPiece(prefab);
         CreateGhostPrefab(prefab);
     }
 }
Пример #19
0
        public static void AwakePostfix(ZNetScene __instance)
        {
            if (Prefabs.Count == 0)
            {
                return;
            }

            foreach (var p in Prefabs)
            {
                __instance.m_namedPrefabs[p.name.GetStableHashCode()] = p;
            }
        }
Пример #20
0
 public static void Prefix(ref ZNetScene __instance)
 {
     try {
         Plugin.Logger.LogInfo("Adding items to the ZNetScene database");
         foreach (GameObject resource in UnityBundle.Database.Items)
         {
             __instance.m_prefabs.Add(resource);
         }
     }catch (Exception exc) {
         Plugin.Logger.LogError(exc);
     }
 }
Пример #21
0
        // Detours ZNetScene.Awake
        private void ZNetSceneAwake(On.ZNetScene.orig_Awake orig, ZNetScene self)
        {
            ModifyItems();

            Prefabs.ModifyExistingPieces(self);
            if (AllPrefabs.Value)
            {
                Prefabs.RegisterPrefabs(self);
            }

            orig(self);
        }
Пример #22
0
 public static void HarmonyPrefix(ZNetScene __instance)
 {
     if (PlantingPlus.enableOtherResources.Value && __instance != null && PlantingPlus.birchConeObject != null && PlantingPlus.oakSeedsObject != null && PlantingPlus.ancientSeedsObject != null && PlantingPlus.birchTreeSaplingObject != null && PlantingPlus.oakTreeSaplingObject != null && PlantingPlus.swampTreeSaplingObject != null)
     {
         __instance.m_prefabs.Add(PlantingPlus.birchConeObject);
         __instance.m_prefabs.Add(PlantingPlus.oakSeedsObject);
         __instance.m_prefabs.Add(PlantingPlus.ancientSeedsObject);
         __instance.m_prefabs.Add(PlantingPlus.birchTreeSaplingObject);
         __instance.m_prefabs.Add(PlantingPlus.oakTreeSaplingObject);
         __instance.m_prefabs.Add(PlantingPlus.swampTreeSaplingObject);
     }
 }
Пример #23
0
        public static void TryRegisterPrefabs(ZNetScene zNetScene)
        {
            if (zNetScene == null)
            {
                return;
            }

            foreach (var prefab in Prefabs.Values)
            {
                zNetScene.m_prefabs.Add(prefab);
            }
        }
Пример #24
0
        public static void Init()
        {
            zns  = ZNetScene.instance;
            Root = new GameObject("OdinPrefab");
            Root.transform.SetParent(OdinPlus.PrefabParent.transform);

            CreateLegacyChest();
            CreateHuntTargetMonster();

            OdinPlus.OdinPostRegister(PrefabList);
            isInit = true;
        }
Пример #25
0
        public static void TryRegisterPrefabs(ZNetScene zNetScene)
        {
            if (zNetScene == null)
            {
                return;
            }

            Debug.Log("Register prefabs: " + Prefabs.Values.Count);
            foreach (var prefab in Prefabs.Values)
            {
                zNetScene.m_prefabs.Add(prefab);
            }
        }
Пример #26
0
        public static void Init()
        {
            zns  = ZNetScene.instance;
            Root = new GameObject("PetPrefab");
            Root.transform.SetParent(OdinPlus.PrefabParent.transform);


            InitTroll();
            InitWolf();

            OdinPlus.OdinPostRegister(PetList);
            isInit = true;
        }
Пример #27
0
 static void ZNetScene_GetPrefab_Postfix(ZNetScene __instance, int hash, ref GameObject __result)
 {
     if (__result == null &&
         interceptGetPrefab &&
         !checkedHashes.Contains(hash))
     {
         interceptGetPrefab = false;
         checkedHashes.Add(hash);
         PlanBuildPlugin.Instance.ScanHammer(true);
         __result           = __instance.GetPrefab(hash);
         interceptGetPrefab = true;
     }
 }
Пример #28
0
        public static void TryRegisterPrefabs(ZNetScene zNetScene)
        {
            if (zNetScene == null)
            {
                Debug.LogWarning($"[Jam] Did not register prefabs: ZNetScene.instance {ZNetScene.instance}");
                return;
            }

            foreach (var prefab in Prefabs.Values)
            {
                zNetScene.m_prefabs.Add(prefab);
            }
        }
Пример #29
0
            public static void Postfix(ZNetScene __instance)
            {
                if (__instance == null)
                {
                    return;
                }

                foreach (GameObject prefab in Instance.ItemPrefabs)
                {
                    AddItemToZNetScene(prefab);
                }

                Instance.ZNetSceneLoaded = true;
            }
Пример #30
0
        /// <summary>
        ///     Register all custom prefabs to m_prefabs/m_namedPrefabs in <see cref="ZNetScene" />.
        /// </summary>
        private void RegisterAllToZNetScene(On.ZNetScene.orig_Awake orig, ZNetScene self)
        {
            orig(self);

            Logger.LogInfo($"---- Adding custom prefabs to {self} ----");

            if (self && Instance.Prefabs.Count > 0)
            {
                foreach (var prefab in Instance.Prefabs)
                {
                    RegisterToZNetScene(prefab.Value);
                }
            }
        }