コード例 #1
0
ファイル: WorldHooks.cs プロジェクト: nilfisk/tModLoader
        public static void ReceiveCustomData(BinaryReader reader)
        {
            int count = reader.ReadUInt16();

            for (int k = 0; k < count; k++)
            {
                string   modName  = reader.ReadString();
                string   name     = reader.ReadString();
                byte[]   data     = reader.ReadBytes(reader.ReadUInt16());
                Mod      mod      = ModLoader.GetMod(modName);
                ModWorld modWorld = mod == null ? null : mod.GetModWorld(name);
                if (modWorld != null)
                {
                    using (MemoryStream stream = new MemoryStream(data))
                    {
                        using (BinaryReader customReader = new BinaryReader(stream))
                        {
                            try
                            {
                                modWorld.ReceiveCustomData(customReader);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
        }