Example #1
0
 public static void PreRegister(Dictionary <string, GameObject> list, string name)
 {
     foreach (var item in list)
     {
         odbRegList.Add(item.Key.GetStableHashCode(), item.Value);
     }
     DBG.blogWarning("Register " + name + " for ODB");
 }
Example #2
0
        public static T CopyBroComponet <T, TU>(this Component comp, TU other) where T : Component
        {
            Type btype = comp.GetType().BaseType;
            IEnumerable <FieldInfo> finfos = btype.GetFields(bindingFlags);

            foreach (var finfo in finfos)
            {
                finfo.SetValue(comp, finfo.GetValue(other));
                DBG.blogWarning(finfo + " , " + finfo.GetType() + " , " + finfo.Name);
            }
            return(comp as T);
        }
Example #3
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;
        }
Example #4
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);
                }
            }
        }
Example #5
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);
        }