Exemple #1
0
        private void Awake()
        {
            logger       = base.Logger;
            nexusID      = base.Config.Bind <int>("Nexus", "NexusID", 478, "Nexus mod ID for updates");
            HatchingTime = base.Config.Bind <int>("2DragonEgg", "hatching time", 300, "how long will egg become a drake");
            HatchingEgg  = base.Config.Bind <bool>("2DragonEgg", "enable egg hatching", true, "this alse enable tamed drake spawn eggs");
            cfg          = base.Config.Bind <string>("1General", "Settings",
                                                     "Hatchling,true,600,300,30,10,300,10,RawMeat,true,true,5,0.33,10,300",
                                                     "name,commandable,tamingTime,fedDuration,consumeRange,consumeSearchInterval,consumeHeal,consumeSearchRange,consumeItem:consumeItem,changeFaction,procretion,maxCreatures,pregnancyChance,pregnancyDuration,growTime,;next one;...;last one");

            loaded   = initCfg();
            CfgTable = new TameTable();
            string list = "Your list has: ";

            foreach (var item in cfgList.Keys)
            {
                list += item + "  ";
            }
            Root = new GameObject("AllTameable Root");

            prefabManager = Root.AddComponent <PrefabManager>();
            petManager    = Root.AddComponent <PetManager>();

            var SM_Root = new GameObject("ConfigManager").transform;

            SM_Root.SetParent(Plugin.Root.transform);
            SM_Root.gameObject.SetActive(false);
            configManager           = SM_Root.gameObject.AddComponent <ConfigManager>();
            configManager.debugInfo = list;
            configManager.obj       = CfgTable;
            configManager.title     = "All Tameable Setup " + (loaded ? "Loaded" : "!!Load Fail!!");
            //configManager.gameObject.SetActive(false);
            DontDestroyOnLoad(Root);

            Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), null);

            DBG.blogInfo("AllTameable Loadded");
        }
Exemple #2
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;
        }
Exemple #3
0
        private static void AddTame(GameObject go, Plugin.TameTable tb)
        {
            if (go.GetComponent <MonsterAI>() == null)
            {
                DBG.blogWarning(go.name + " can't be added,Remove it in your cfg");
                Plugin.configManager.debugInfo += go.name + " can't be added,Remove it in your cfg   ";
                return;
            }
            Tameable tame;

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

            tame.m_petEffect    = wtame.m_petEffect;
            tame.m_sootheEffect = wtame.m_sootheEffect;
            tame.m_petEffect    = wtame.m_petEffect;

            tame.m_commandable = tb.commandable;
            tame.m_tamingTime  = tb.tamingTime;
            tame.m_fedDuration = tb.fedDuration;

            ma.m_consumeRange          = tb.consumeRange;
            ma.m_consumeSearchInterval = tb.consumeSearchInterval;
            ma.m_consumeHeal           = tb.consumeHeal;
            ma.m_consumeSearchRange    = tb.consumeSearchRange;
            var consumeItems = new List <string>();
            var cis          = tb.consumeItems.Split(new char[] { ':' });

            foreach (var ci in cis)
            {
                consumeItems.Add(ci);
            }
            foreach (var itm in consumeItems)
            {
                var a = ObjectDB.instance.GetItemPrefab(itm);
                if (a == null)
                {
                    DBG.blogWarning("Wrong food name :" + itm);
                    Plugin.configManager.debugInfo += "   Wrong food name :" + itm;
                }
                else
                {
                    //--DBG.blogInfo("add " + itm + " to " + go.name);
                    ma.m_consumeItems.Add(a.GetComponent <ItemDrop>());
                }
            }

            if (tb.procretion)
            {
                bool        vanilla = true;
                Procreation pc;
                if (!go.TryGetComponent <Procreation>(out pc))
                {
                    pc      = go.AddComponent <Procreation>();
                    vanilla = false;
                }

                pc.m_maxCreatures      = tb.maxCreatures * 2;
                pc.m_pregnancyChance   = tb.pregnancyChance;
                pc.m_pregnancyDuration = tb.pregnancyDuration;
                pc.m_partnerCheckRange = 30;
                pc.m_totalCheckRange   = 30;
                if (vanilla && pc.m_offspring != null)
                {
                    var gu = pc.m_offspring.GetComponent <Growup>();
                    gu.m_growTime = tb.growTime;
                    return;
                }
                if (go.name == "Hatchling" && Plugin.HatchingEgg.Value)
                {
                    pc.m_offspring = DragonEgg;
                    return;
                    //!MiniDrake add here
                }
                else
                {
                    pc.m_offspring = SpawnMini(go);
                }
            }
        }
Exemple #4
0
        public bool initCfg()
        {
            if (cfg.Value == "")
            {
                DBG.blogWarning("CFG is empty");
                return(false);
            }
            string[] list = cfg.Value.Split(new char[] { ';' });
            foreach (string tt in list)
            {
                string[] set = tt.Split(new char[] { ',' });

                if (set.Length == 8 || set.Length == 9)
                {
                    DBG.blogWarning("Upadate your cfg : " + tt);
                    return(false);
                }
                if (set.Length != 15)
                {
                    DBG.blogWarning("Not enought args : " + tt);
                    return(false);
                }
                TameTable table = new TameTable();
                string    name  = set[0];
                if (set[1] == "true")
                {
                    table.commandable = true;
                }
                else
                {
                    table.commandable = false;
                }

                try
                {
                    table.tamingTime            = float.Parse(set[2]);
                    table.fedDuration           = float.Parse(set[3]);
                    table.consumeRange          = float.Parse(set[4]);
                    table.consumeSearchInterval = float.Parse(set[5]);
                    table.consumeHeal           = float.Parse(set[6]);
                    table.consumeSearchRange    = float.Parse(set[7]);
                }
                catch (Exception e)
                {
                    DBG.blogWarning("wrong syntax : " + tt);
                    logger.LogError(e);
                    return(false);
                }
                table.consumeItems = set[8];

                if (set[9] == "true")
                {
                    table.changeFaction = true;
                }
                if (set[10] == "true")
                {
                    table.procretion = true;
                }

                try
                {
                    float a = 0.33f;
                    table.maxCreatures = int.Parse(set[11]);
                    if (Single.TryParse(set[12], out a))
                    {
                        table.pregnancyChance = a;
                    }

                    table.pregnancyDuration = Single.Parse(set[13]);
                    table.growTime          = Single.Parse(set[14]);
                }
                catch (Exception e)
                {
                    DBG.blogWarning("wrong syntax : " + tt);
                    logger.LogError(e);
                    return(false);
                }
                cfgList.Add(name, table);
            }
            DBG.blogInfo("TameTable Loaded :" + cfgList.Count);
            return(true);
        }