示例#1
0
        // This changes sidedefs (used for joining lines)
        // target:		The linedef on which to remove or create a new sidedef
        // front:		Side on which to remove or create the sidedef (true for front side)
        // newside:		The side from which to copy the properties to the new sidedef.
        //				If this is null, no sidedef will be created (only removed)
        // Returns false when the operation could not be completed.
        private bool JoinChangeSidedefs(Linedef target, bool front, Sidedef newside)
        {
            // Change sidedefs
            if (front)
            {
                if (target.front != null)
                {
                    target.front.Dispose();
                }
            }
            else
            {
                if (target.back != null)
                {
                    target.back.Dispose();
                }
            }

            if (newside != null)
            {
                Sidedef sd = map.CreateSidedef(target, front, newside.Sector);
                if (sd == null)
                {
                    return(false);
                }
                newside.CopyPropertiesTo(sd);
                sd.Marked = newside.Marked;
            }

            return(true);
        }
示例#2
0
        // This splits this line by vertex v
        // Returns the new line resulting from the split, or null when it failed
        public Linedef Split(Vertex v)
        {
            // Copy linedef and change vertices
            Linedef nl = map.CreateLinedef(v, end);

            if (nl == null)
            {
                return(null);
            }
            CopyPropertiesTo(nl);
            SetEndVertex(v);
            nl.Selected = this.Selected;
            nl.marked   = this.marked;

            // Copy front wall if exists
            if (front != null)
            {
                Sidedef nsd = map.CreateSidedef(nl, true, front.Sector);
                if (nsd == null)
                {
                    return(null);
                }
                front.CopyPropertiesTo(nsd);
                nsd.Marked = front.Marked;

                // Make texture offset adjustments
                //TODO: works differently in Build...
                nsd.OffsetX += (int)Vector2D.Distance(this.start.Position, this.end.Position);
            }

            // Copy back wall if exists
            if (back != null)
            {
                Sidedef nsd = map.CreateSidedef(nl, false, back.Sector);
                if (nsd == null)
                {
                    return(null);
                }
                back.CopyPropertiesTo(nsd);
                nsd.Marked = back.Marked;

                // Make texture offset adjustments
                //TODO: works differently in Build...
                back.OffsetX += (int)Vector2D.Distance(nl.start.Position, nl.end.Position);
            }

            // Return result
            General.Map.IsChanged = true;
            return(nl);
        }