Ejemplo n.º 1
0
        public void Serialize(BinaryWriter bw)
        {
            bw.Write(this.Name);
            bw.Write(this.Description);
            bw.Write(this.NumberLocals.Count);
            foreach (KeyValuePair <string, Tuple <int, int> > kv in this.NumberLocals)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.Item1);
                bw.Write(kv.Value.Item2);
            }

            bw.Write(this.RealLocals.Count);
            foreach (KeyValuePair <string, Tuple <float, float> > kv in this.RealLocals)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.Item1);
                bw.Write(kv.Value.Item2);
            }

            bw.Write(this.StringLocals.Count);
            foreach (KeyValuePair <string, Tuple <string, string> > kv in this.StringLocals)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.Item1);
                bw.Write(kv.Value.Item2);
            }

            bw.Write(this.BoolLocals.Count);
            foreach (KeyValuePair <string, Tuple <bool, bool> > kv in this.BoolLocals)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.Item1);
                bw.Write(kv.Value.Item2);
            }

            bw.Write(this.ItemsLinked.Count);
            foreach (KeyValuePair <string, Guid> kv in this.ItemsLinked)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.ToByteArray());
            }

            bw.Write(this.SpellsLinked.Count);
            foreach (KeyValuePair <string, Guid> kv in this.SpellsLinked)
            {
                bw.Write(kv.Key);
                bw.Write(kv.Value.ToByteArray());
            }

            bw.Write(this.Actions.Count);
            foreach (MacroAction ma in this.Actions)
            {
                MacroSerializer.WriteMacroAction(bw, ma);
            }
        }
Ejemplo n.º 2
0
        public void Deserialize(BinaryReader br)
        {
            this.Name        = br.ReadString();
            this.Description = br.ReadString();
            int i = br.ReadInt32();

            this.NumberLocals.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                int    n1 = br.ReadInt32();
                int    n2 = br.ReadInt32();
                this.NumberLocals.Add(s, new Tuple <int, int>(n1, n2));
            }

            i = br.ReadInt32();
            this.RealLocals.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                float  n1 = br.ReadSingle();
                float  n2 = br.ReadSingle();
                this.RealLocals.Add(s, new Tuple <float, float>(n1, n2));
            }

            i = br.ReadInt32();
            this.StringLocals.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                string n1 = br.ReadString();
                string n2 = br.ReadString();
                this.StringLocals.Add(s, new Tuple <string, string>(n1, n2));
            }

            i = br.ReadInt32();
            this.BoolLocals.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                bool   n1 = br.ReadBoolean();
                bool   n2 = br.ReadBoolean();
                this.BoolLocals.Add(s, new Tuple <bool, bool>(n1, n2));
            }

            i = br.ReadInt32();
            this.ItemsLinked.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                Guid   id = new Guid(br.ReadBytes(16));
                this.ItemsLinked.Add(s, id);
            }

            i = br.ReadInt32();
            this.SpellsLinked.Clear();
            while (i-- > 0)
            {
                string s  = br.ReadString();
                Guid   id = new Guid(br.ReadBytes(16));
                this.SpellsLinked.Add(s, id);
            }

            i = br.ReadInt32();
            this.Actions.Clear();
            while (i-- > 0)
            {
                this.Actions.AddLast(MacroSerializer.ReadMacroAction(br));
            }
        }