Esempio n. 1
0
        public override MapObject Copy(IDGenerator generator)
        {
            var group = new Group(generator.GetNextObjectID());

            CopyBase(group, generator);
            return(group);
        }
Esempio n. 2
0
        public override MapObject Copy(IDGenerator generator)
        {
            var e = new World(generator.GetNextObjectID())
            {
                EntityData = EntityData.Clone(),
            };

            e.Paths.AddRange(Paths.Select(x => x.Clone()));
            CopyBase(e, generator);
            return(e);
        }
Esempio n. 3
0
        public override MapObject Copy(IDGenerator generator)
        {
            var e = new Entity(generator.GetNextObjectID())
            {
                GameData   = GameData,
                EntityData = EntityData.Clone(),
                Origin     = Origin.Clone()
            };

            CopyBase(e, generator);
            return(e);
        }
Esempio n. 4
0
        public Map()
        {
            Version      = 1;
            Visgroups    = new List <Visgroup>();
            Cameras      = new List <Camera>();
            ActiveCamera = null;
            IDGenerator  = new IDGenerator();
            WorldSpawn   = new World(IDGenerator.GetNextObjectID());

            Show2DGrid             = SnapToGrid = true;
            TextureLock            = true;
            HideDisplacementSolids = true;
            CordonBounds           = new Box(Coordinate.One * -1024, Coordinate.One * 1024);
        }
Esempio n. 5
0
        public override MapObject Copy(IDGenerator generator)
        {
            var e = new Solid(generator.GetNextObjectID());

            foreach (var f in Faces.Select(x => x.Copy(generator)))
            {
                f.Parent = e;
                e.Faces.Add(f);
                f.UpdateBoundingBox();
                f.CalculateTextureCoordinates(true);
            }
            CopyBase(e, generator);
            return(e);
        }
Esempio n. 6
0
        public static Solid CreateFromIntersectingPlanes(IEnumerable <Plane> planes, IDGenerator generator)
        {
            var solid = new Solid(generator.GetNextObjectID());
            var list  = planes.ToList();

            for (var i = 0; i < list.Count; i++)
            {
                // Split the polygon by all the other planes
                var poly = new Polygon(list[i]);
                for (var j = 0; j < list.Count; j++)
                {
                    if (i != j)
                    {
                        poly.Split(list[j]);
                    }
                }

                // The final polygon is the face
                var face = new Face(generator.GetNextFaceID())
                {
                    Plane = poly.Plane, Parent = solid
                };
                face.Vertices.AddRange(poly.Vertices.Select(x => new Vertex(x.Round(2), face))); // Round vertices a bit for sanity
                face.UpdateBoundingBox();
                face.AlignTextureToWorld();
                solid.Faces.Add(face);
            }

            // Ensure all the faces point outwards
            var origin = solid.GetOrigin();

            foreach (var face in solid.Faces)
            {
                if (face.Plane.OnPlane(origin) >= 0)
                {
                    face.Flip();
                }
            }

            solid.UpdateBoundingBox();
            return(solid);
        }