Esempio n. 1
0
        protected override void Read(BinaryReader br)
        {
            var cRegions = br.ReadInt32();

            for (int l = 0; l < cRegions; ++l)
            {
                var ri = new RegionData();

                ri.Id      = br.ReadInt32();
                ri.GroupId = br.ReadInt32();
                ri.X1      = br.ReadInt32();
                ri.Y1      = br.ReadInt32();
                ri.X2      = br.ReadInt32();
                ri.Y2      = br.ReadInt32();

                var cAreas = br.ReadInt32();
                ri.Areas = new Dictionary <int, AreaData>();
                for (int i = 0; i < cAreas; ++i)
                {
                    var ai = new AreaData();

                    ai.Id = br.ReadInt32();
                    ai.X1 = br.ReadInt32();
                    ai.Y1 = br.ReadInt32();
                    ai.X2 = br.ReadInt32();
                    ai.Y2 = br.ReadInt32();

                    var cProps = br.ReadInt32();
                    ai.Props = new Dictionary <long, PropData>();
                    for (int j = 0; j < cProps; ++j)
                    {
                        var pi = new PropData();
                        pi.EntityId  = br.ReadInt64();
                        pi.Id        = br.ReadInt32();
                        pi.X         = br.ReadSingle();
                        pi.Y         = br.ReadSingle();
                        pi.Direction = br.ReadSingle();
                        pi.Scale     = br.ReadSingle();

                        var cShapes = br.ReadInt32();
                        pi.Shapes = new List <ShapeData>();
                        for (int k = 0; k < cShapes; ++k)
                        {
                            var si = new ShapeData();
                            si.X1 = br.ReadInt32();
                            si.Y1 = br.ReadInt32();
                            si.X2 = br.ReadInt32();
                            si.Y2 = br.ReadInt32();
                            si.X3 = br.ReadInt32();
                            si.Y3 = br.ReadInt32();
                            si.X4 = br.ReadInt32();
                            si.Y4 = br.ReadInt32();

                            pi.Shapes.Add(si);
                        }

                        var cElements = br.ReadInt32();
                        pi.Parameters = new List <RegionElementData>();
                        for (int k = 0; k < cElements; ++k)
                        {
                            var red = new RegionElementData();
                            red.EventType  = br.ReadInt32();
                            red.SignalType = br.ReadInt32();
                            red.Name       = br.ReadString();
                            red.XML        = br.ReadString();

                            pi.Parameters.Add(red);
                        }

                        ai.Props.Add(pi.EntityId, pi);
                        this.PropEntries.Add(pi.EntityId, pi);
                    }

                    var cEvents = br.ReadInt32();
                    ai.Events = new Dictionary <long, EventData>();
                    for (int j = 0; j < cEvents; ++j)
                    {
                        var ei = new EventData();
                        ei.Id       = br.ReadInt64();
                        ei.RegionId = ri.Id;
                        ei.X        = br.ReadSingle();
                        ei.Y        = br.ReadSingle();
                        ei.Type     = (EventType)br.ReadInt32();

                        var cShapes = br.ReadInt32();
                        ei.Shapes = new List <ShapeData>();
                        for (int k = 0; k < cShapes; ++k)
                        {
                            var si = new ShapeData();
                            si.X1 = br.ReadInt32();
                            si.Y1 = br.ReadInt32();
                            si.X2 = br.ReadInt32();
                            si.Y2 = br.ReadInt32();
                            si.X3 = br.ReadInt32();
                            si.Y3 = br.ReadInt32();
                            si.X4 = br.ReadInt32();
                            si.Y4 = br.ReadInt32();

                            ei.Shapes.Add(si);
                        }

                        var cElements = br.ReadInt32();
                        ei.Parameters = new List <RegionElementData>();
                        for (int k = 0; k < cElements; ++k)
                        {
                            var red = new RegionElementData();
                            red.EventType  = br.ReadInt32();
                            red.SignalType = br.ReadInt32();
                            red.Name       = br.ReadString();
                            red.XML        = br.ReadString();

                            if (!ei.IsAltar && red.EventType == 2110 && red.SignalType == 103)
                            {
                                ei.IsAltar = true;
                            }

                            ei.Parameters.Add(red);
                        }

                        ai.Events.Add(ei.Id, ei);
                        this.EventEntries.Add(ei.Id, ei);
                    }

                    ri.Areas.Add(ai.Id, ai);
                }

                this.Entries.Add(ri.Id, ri);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads data.
        /// </summary>
        /// <param name="br"></param>
        protected override void Read(BinaryReader br)
        {
            var cRegions = br.ReadInt32();

            for (int l = 0; l < cRegions; ++l)
            {
                var ri = new RegionInfoData();

                ri.Id      = br.ReadInt32();
                ri.Name    = br.ReadString();
                ri.GroupId = br.ReadInt32();
                ri.X1      = br.ReadInt32();
                ri.Y1      = br.ReadInt32();
                ri.X2      = br.ReadInt32();
                ri.Y2      = br.ReadInt32();

                var cAreas = br.ReadInt32();
                for (int i = 0; i < cAreas; ++i)
                {
                    var ai = new AreaData();

                    ai.Id   = br.ReadInt32();
                    ai.Name = br.ReadString();
                    ai.X1   = br.ReadInt32();
                    ai.Y1   = br.ReadInt32();
                    ai.X2   = br.ReadInt32();
                    ai.Y2   = br.ReadInt32();

                    var cProps = br.ReadInt32();
                    for (int j = 0; j < cProps; ++j)
                    {
                        var pi = new PropData();
                        pi.EntityId  = br.ReadInt64();
                        pi.Id        = br.ReadInt32();
                        pi.Name      = br.ReadString();
                        pi.X         = br.ReadSingle();
                        pi.Y         = br.ReadSingle();
                        pi.Direction = br.ReadSingle();
                        pi.Scale     = br.ReadSingle();

                        var cShapes = br.ReadInt32();
                        for (int k = 0; k < cShapes; ++k)
                        {
                            var si = new ShapeData();
                            si.DirX1 = br.ReadSingle();
                            si.DirX2 = br.ReadSingle();
                            si.DirY1 = br.ReadSingle();
                            si.DirY2 = br.ReadSingle();
                            si.LenX  = br.ReadSingle();
                            si.LenY  = br.ReadSingle();
                            si.PosX  = br.ReadSingle();
                            si.PosY  = br.ReadSingle();

                            pi.Shapes.Add(si);
                        }

                        var cElements = br.ReadInt32();
                        for (int k = 0; k < cElements; ++k)
                        {
                            var red = new RegionElementData();
                            red.EventType  = (EventType)br.ReadInt32();
                            red.SignalType = (SignalType)br.ReadInt32();
                            red.Name       = br.ReadString();

                            var xml = br.ReadString();
                            red.XML = !string.IsNullOrWhiteSpace(xml) ? XElement.Parse(xml) : null;

                            pi.Parameters.Add(red);
                        }

                        ai.Props.Add(pi.EntityId, pi);
                    }

                    var cEvents = br.ReadInt32();
                    for (int j = 0; j < cEvents; ++j)
                    {
                        var ei = new EventData();
                        ei.Id       = br.ReadInt64();
                        ei.Name     = br.ReadString();
                        ei.Path     = string.Format("{0}/{1}/{2}", ri.Name, ai.Name, ei.Name);
                        ei.RegionId = ri.Id;
                        ei.X        = br.ReadSingle();
                        ei.Y        = br.ReadSingle();
                        ei.Type     = (EventType)br.ReadInt32();

                        var cShapes = br.ReadInt32();
                        for (int k = 0; k < cShapes; ++k)
                        {
                            var si = new ShapeData();
                            si.DirX1 = br.ReadSingle();
                            si.DirX2 = br.ReadSingle();
                            si.DirY1 = br.ReadSingle();
                            si.DirY2 = br.ReadSingle();
                            si.LenX  = br.ReadSingle();
                            si.LenY  = br.ReadSingle();
                            si.PosX  = br.ReadSingle();
                            si.PosY  = br.ReadSingle();

                            ei.Shapes.Add(si);
                        }

                        var cElements = br.ReadInt32();
                        for (int k = 0; k < cElements; ++k)
                        {
                            var red = new RegionElementData();
                            red.EventType  = (EventType)br.ReadInt32();
                            red.SignalType = (SignalType)br.ReadInt32();
                            red.Name       = br.ReadString();

                            var xml = br.ReadString();
                            red.XML = !string.IsNullOrWhiteSpace(xml) ? XElement.Parse(xml) : null;

                            if (!ei.IsAltar && red.EventType == EventType.Altar && red.SignalType == SignalType.StepOn)
                            {
                                ei.IsAltar = true;
                            }

                            ei.Parameters.Add(red);
                        }

                        ai.Events.Add(ei.Id, ei);
                    }

                    ri.Areas.Add(ai);
                }

                this.Entries.Add(ri.Id, ri);
            }
        }