コード例 #1
0
ファイル: Plugin.cs プロジェクト: buzzhoot/buzzvalheimmods
        public static void CfgMangerGet()
        {
            var name = configManager.CfgName;

            if (name == "")
            {
                Plugin.configManager.debugInfo = "name can't be empty!";
                return;
            }
            if (cfgList.ContainsKey(name))
            {
                configManager.obj = (TameTable)cfgList[name].Clone();
                CfgTable          = (TameTable)configManager.obj;
                Plugin.configManager.debugInfo = name + " is Loaded";
                return;
            }
            Plugin.configManager.debugInfo = name + " is not exsit, use Add";
        }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: buzzhoot/buzzvalheimmods
        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");
        }
コード例 #3
0
ファイル: Plugin.cs プロジェクト: buzzhoot/buzzvalheimmods
        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);
        }