コード例 #1
0
        private static GameObject SpawnMini(GameObject prefab)
        {
            var        pgo  = prefab;
            var        name = prefab.name;
            GameObject go   = GameObject.Instantiate(zns.GetPrefab(name), Root.transform);

            go.name = "Mini" + name;
            go.transform.localScale            *= 0.5f;
            go.GetComponent <Humanoid>().m_name = "Mini " + go.GetComponent <Humanoid>().m_name;
            if (go.GetComponent <MonsterAI>() != null)
            {
                GameObject.DestroyImmediate(go.GetComponent <MonsterAI>());
            }
            if (go.GetComponent <VisEquipment>() != null)
            {
                GameObject.DestroyImmediate(go.GetComponent <VisEquipment>());
            }
            if (go.GetComponent <CharacterDrop>() != null)
            {
                GameObject.DestroyImmediate(go.GetComponent <CharacterDrop>());
            }
            if (go.GetComponent <Tameable>() != null)
            {
                GameObject.DestroyImmediate(go.GetComponent <Tameable>());
            }
            if (go.GetComponent <Procreation>() != null)
            {
                GameObject.DestroyImmediate(go.GetComponent <Procreation>());
            }
            var mai = pgo.GetComponent <MonsterAI>();
            var aai = go.AddComponent <AnimalAI>();

            aai.CopyBroComponet <AnimalAI, MonsterAI>(mai);

            var gu = go.AddComponent <Growup>();

            gu.m_grownPrefab = zns.GetPrefab(name);
            gu.m_growTime    = Plugin.cfgList[name].growTime;

            PrefabManager.PostRegister(go);

            return(go);
        }
コード例 #2
0
ファイル: Patches.cs プロジェクト: jsza/ValheimMods-3
 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;
     }
 }
コード例 #3
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;
     }
 }
コード例 #4
0
 private static void LoadAllArmorData(ZNetScene scene)
 {
     armorDatas = GetArmorDataFromFiles();
     foreach (var armor in armorDatas)
     {
         GameObject go = scene.GetPrefab(armor.name);
         if (go == null)
         {
             continue;
         }
         ItemDrop.ItemData item = go.GetComponent <ItemDrop>().m_itemData;
         SetArmorData(ref item, armor);
         go.GetComponent <ItemDrop>().m_itemData = item;
     }
 }
コード例 #5
0
 private static void LoadAllWeaponData(ZNetScene scene)
 {
     weaponDatas = GetWeaponDataFromFiles();
     foreach (var weapon in weaponDatas)
     {
         GameObject go = scene.GetPrefab(weapon.name);
         if (go == null)
         {
             continue;
         }
         ItemDrop.ItemData item = go.GetComponent <ItemDrop>().m_itemData;
         SetWeaponData(ref item, weapon);
         go.GetComponent <ItemDrop>().m_itemData = item;
     }
 }
コード例 #6
0
        public static void Init()
        {
            zns   = ZNetScene.instance;
            wtame = zns.GetPrefab("Wolf").GetComponent <Tameable>();
            if (Plugin.HatchingEgg.Value)
            {
                InitDrakeEgg();
            }
            var list = Plugin.cfgList;

            foreach (var obj in list)
            {
                string name = obj.Key;
                if (zns.GetPrefab(name) == null)
                {
                    DBG.blogWarning("Cant find Prefab Check your name : " + name);
                    Plugin.configManager.debugInfo += "  Cant find Prefab Check your name : " + name;
                }
                AddTame(zns.GetPrefab(name), obj.Value);
            }


            isInit = true;
        }
コード例 #7
0
        private static void CreateTrollPrefab(string name)
        {
            if (zns.GetPrefab(name) == null)
            {
                DBG.blogWarning("can't find the prefab zns :" + name);
                return;
            }
            var go = Instantiate(zns.GetPrefab(name), Root.transform);

            go.name = name + "Pet";
            Tameable tame;

            if (!go.TryGetComponent <Tameable>(out tame))
            {
                tame = go.AddComponent <Tameable>();
            }
            go.AddComponent <PetTroll>();
            var hd  = go.GetComponent <Humanoid>();
            var mai = go.GetComponent <MonsterAI>();

            DestroyImmediate(go.GetComponent <CharacterDrop>());

            hd.m_name    = hd.m_name + " Pet";         //trans
            hd.m_faction = Character.Faction.Players;

            mai.m_consumeItems.Clear();

            SetColor(go);

            if (hd.m_randomSets.Length > 1)
            {
                hd.m_randomSets = hd.m_randomSets.Skip(hd.m_randomSets.Length - 1).ToArray();
            }
            PetList.Add(name + "Pet", go);
            return;
        }
コード例 #8
0
ファイル: Items.cs プロジェクト: mrStorrs/valheim-brawler
        public static void Postfix(ref ZNetScene __instance)
        {
            try {
                Plugin.Logger.LogInfo("Setting up fx.");

                foreach (GameObject resource in UnityBundle.Database.Items)
                {
                    var club     = __instance.GetPrefab("Club").GetComponent <ItemDrop>();
                    var itemDrop = resource.GetComponent <ItemDrop>();

                    itemDrop.m_itemData.m_shared.m_hitEffect        = club.m_itemData.m_shared.m_hitEffect;
                    itemDrop.m_itemData.m_shared.m_blockEffect      = club.m_itemData.m_shared.m_blockEffect;
                    itemDrop.m_itemData.m_shared.m_triggerEffect    = club.m_itemData.m_shared.m_triggerEffect;
                    itemDrop.m_itemData.m_shared.m_trailStartEffect = club.m_itemData.m_shared.m_trailStartEffect;
                }
            }catch (Exception exc) {
                Plugin.Logger.LogError(exc);
            }
        }
コード例 #9
0
        static void PrefabPostfix(ref ZNetScene __instance)
        {
            GameObject wishbonePrefab = __instance.GetPrefab("Wishbone");

            CustomSlotManager.ApplyCustomSlotItem(wishbonePrefab, "wishbone");
        }