Пример #1
0
        public static void LockWorld()
        {
            var mymod    = HamstarHelpersMod.Instance;
            var modlock  = mymod.ModLockHelpers;
            var modworld = mymod.GetModWorld <HamstarHelpersWorld>();

            IEnumerable <Mod> all_mods  = ModHelpers.GetAllMods();
            ISet <string>     mod_names = new HashSet <string>();

            foreach (Mod mod in all_mods)
            {
                mod_names.Add(mod.Name);
            }

            modlock.WorldModLocks[modworld.ObsoleteID2] = mod_names;

            modlock.ScanMods(modworld);

            if (mymod.Config.WorldModLockMinimumOnly)
            {
                Main.NewText("Your world now requires exactly these mods: " + string.Join(", ", mod_names));
            }
            else
            {
                Main.NewText("Your world now requires at least these mods: " + string.Join(", ", mod_names));
            }
        }
Пример #2
0
        ////////////////

        internal void DrawWarning(SpriteBatch sb)
        {
            if (!this.IsInitialized)
            {
                return;
            }
            if (!this.IsMismatched)
            {
                return;
            }

            int eta = this.ExitDuration / 60;
            IEnumerable <Mod> mods = ModHelpers.GetAllMods();

            string warning = "World mod mismatch! Auto-exiting in " + eta;

            Vector2 pos      = new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);
            Vector2 dim      = Main.fontDeathText.MeasureString(warning);
            Vector2 main_pos = pos - (dim / 2);

            sb.DrawString(Main.fontDeathText, warning, main_pos, Color.Red);

            if (this.FoundModNames.Count > 0)
            {
                string needed = "Needed mods: " + string.Join(", ", this.FoundModNames.ToArray());
                main_pos.X += 128;
                main_pos.Y += 48;
                sb.DrawString(Main.fontMouseText, needed, main_pos, Color.White);
            }

            if (this.MissingModNames.Count > 0)
            {
                string missing = "Missing mods: " + string.Join(", ", this.MissingModNames.ToArray());
                main_pos.Y += 24;
                sb.DrawString(Main.fontMouseText, missing, main_pos, Color.White);
            }

            if (this.ExtraModNames.Count > 0)
            {
                string extra = "Extra mods: " + string.Join(", ", this.ExtraModNames.ToArray());
                main_pos.Y += 24;
                sb.DrawString(Main.fontMouseText, extra, main_pos, Color.White);
            }
        }
Пример #3
0
        ////////////////

        private void ScanMods(HamstarHelpersWorld modworld)
        {
            this.FoundModNames   = new HashSet <string>();
            this.MissingModNames = new HashSet <string>();
            this.ExtraModNames   = new HashSet <string>();

            if (!this.WorldModLocks.ContainsKey(modworld.ObsoleteID2))
            {
                this.IsMismatched = false;
                return;
            }

            ISet <string>     req_mod_names     = this.WorldModLocks[modworld.ObsoleteID2];
            ISet <string>     checked_mod_names = new HashSet <string>();
            IEnumerable <Mod> all_mods          = ModHelpers.GetAllMods();

            foreach (Mod mod in all_mods)
            {
                if (!req_mod_names.Contains(mod.Name))
                {
                    this.ExtraModNames.Add(mod.Name);
                }
                else
                {
                    this.FoundModNames.Add(mod.Name);
                }
                checked_mod_names.Add(mod.Name);
            }

            foreach (string mod_name in req_mod_names)
            {
                if (!checked_mod_names.Contains(mod_name))
                {
                    this.MissingModNames.Add(mod_name);
                }
            }

            this.IsMismatched = ModLockHelpers.IsModMismatchFound();
//LogHelpers.Log( "req_mod_names:"+string.Join(",",req_mod_names)+
//", extra:"+string.Join(",",this.ExtraModNames)+
//", found:"+string.Join(",",this.FoundModNames)+
//", missing:"+string.Join(",",this.MissingModNames ) );
//LogHelpers.Log( "IsInitialized:"+this.IsInitialized+" IsMismatched:"+this.IsMismatched+ ", ExitDuration:" + this.ExitDuration);
        }