Esempio n. 1
0
        internal void Deserialize <T>(List <T> all_cells, BinaryReader r) where T : Cell, new()
        {
            GlobalId = r.ReadInt32();
            Id       = r.ReadInt32();
            AABB.Deserialize(r);
            Flags            = (MovementFlag)r.ReadInt32();
            Replacement      = r.ReadBoolean();
            Disabled         = r.ReadBoolean();
            MovementCostMult = r.ReadSingle();

            T temp_cell = new T();

            Cell.CompareByGlobalId comp_by_global_id = new Cell.CompareByGlobalId();

            int neighbours_num = r.ReadInt32();

            for (int i = 0; i < neighbours_num; ++i)
            {
                Neighbour neighbour = new Neighbour(null, null, MovementFlag.None);

                int neighbour_global_id = r.ReadInt32();
                temp_cell.GlobalId = neighbour_global_id;
                neighbour.cell     = all_cells.ElementAt(all_cells.BinarySearch((T)temp_cell, comp_by_global_id));

                if (r.ReadBoolean())
                {
                    neighbour.border_point = new Vec3(r);
                }

                neighbour.connection_flags = (MovementFlag)r.ReadInt32();

                Neighbours.Add(neighbour);
            }
        }
Esempio n. 2
0
        internal void Deserialize <T>(HashSet <T> all_cells, BinaryReader r) where T : Cell, new()
        {
            GlobalId = r.ReadInt32();
            Id       = r.ReadInt32();
            AABB.Deserialize(r);
            Flags            = (MovementFlag)r.ReadInt32();
            Replacement      = r.ReadBoolean();
            Disabled         = r.ReadBoolean();
            MovementCostMult = r.ReadSingle();

            int neighbours_num = r.ReadInt32();

            for (int i = 0; i < neighbours_num; ++i)
            {
                Neighbour neighbour = new Neighbour(null, null, null, MovementFlag.None);

                int neighbour_global_id = r.ReadInt32();
                neighbour.cell = all_cells.FirstOrDefault(x => x.GlobalId == neighbour_global_id);

                if (r.ReadBoolean())
                {
                    neighbour.border_point = new Vec3(r);
                }

                if (r.ReadBoolean())
                {
                    neighbour.border_segment = new Tuple <Vec3, Vec3>(new Vec3(r), new Vec3(r));
                }

                neighbour.connection_flags = (MovementFlag)r.ReadInt32();

                if (neighbour.cell != null)
                {
                    Neighbours.Add(neighbour);
                }
                else
                {
                    Console.WriteLine("Oops!");
                }
            }

            AlignPlaneDirty = true;
        }