mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 03:41:47 +00:00
renamed MapManager to MapSet and added clone methods
This commit is contained in:
parent
da08ae2fa7
commit
e222927480
7 changed files with 132 additions and 19 deletions
|
@ -60,7 +60,7 @@
|
|||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Map\Linedef.cs" />
|
||||
<Compile Include="Map\MapManager.cs" />
|
||||
<Compile Include="Map\MapSet.cs" />
|
||||
<Compile Include="Map\Sector.cs" />
|
||||
<Compile Include="Map\Sidedef.cs" />
|
||||
<Compile Include="Map\Thing.cs" />
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Variables
|
||||
|
||||
// Map
|
||||
private MapManager map;
|
||||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Linedef> mainlistitem;
|
||||
|
@ -61,6 +61,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
public Vertex Start { get { return start; } }
|
||||
public Vertex End { get { return end; } }
|
||||
public Sidedef Front { get { return front; } }
|
||||
public Sidedef Back { get { return back; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
@ -70,7 +72,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public Linedef(MapManager map, LinkedListNode<Linedef> listitem, Vertex start, Vertex end)
|
||||
public Linedef(MapSet map, LinkedListNode<Linedef> listitem, Vertex start, Vertex end)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
|
@ -145,6 +147,16 @@ namespace CodeImp.DoomBuilder.Map
|
|||
length = (float)Math.Sqrt(lengthsq);
|
||||
//angle = delta.GetAngle();
|
||||
}
|
||||
|
||||
// This copies all properties to another line
|
||||
public void CopyPropertiesTo(Linedef l)
|
||||
{
|
||||
// Copy properties
|
||||
l.action = action;
|
||||
l.args = (byte[])args.Clone();
|
||||
l.flags = flags;
|
||||
l.tag = tag;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
internal class MapManager : IDisposable
|
||||
internal class MapSet : IDisposable
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor for new empty map
|
||||
public MapManager()
|
||||
public MapSet()
|
||||
{
|
||||
// Initialize
|
||||
vertices = new LinkedList<Vertex>();
|
||||
|
@ -113,6 +113,73 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Management
|
||||
|
||||
// This makes a deep copy and returns a new MapSet
|
||||
public MapSet Clone()
|
||||
{
|
||||
Dictionary<Vertex, Vertex> vertexlink = new Dictionary<Vertex,Vertex>(vertices.Count);
|
||||
Dictionary<Linedef, Linedef> linedeflink = new Dictionary<Linedef, Linedef>(linedefs.Count);
|
||||
Dictionary<Sector, Sector> sectorlink = new Dictionary<Sector, Sector>(sectors.Count);
|
||||
|
||||
// Create the map set
|
||||
MapSet newset = new MapSet();
|
||||
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in vertices)
|
||||
{
|
||||
// Make new vertex
|
||||
Vertex nv = newset.CreateVertex(v.Position);
|
||||
vertexlink.Add(v, nv);
|
||||
}
|
||||
|
||||
// Go for all linedefs
|
||||
foreach(Linedef l in linedefs)
|
||||
{
|
||||
// Make new linedef
|
||||
Linedef nl = newset.CreateLinedef(vertexlink[l.Start], vertexlink[l.End]);
|
||||
linedeflink.Add(l, nl);
|
||||
|
||||
// Copy properties
|
||||
l.CopyPropertiesTo(nl);
|
||||
|
||||
// Recalculate
|
||||
l.Recalculate();
|
||||
}
|
||||
|
||||
// Go for all sectors
|
||||
foreach(Sector s in sectors)
|
||||
{
|
||||
// Make new sector
|
||||
Sector ns = newset.CreateSector();
|
||||
sectorlink.Add(s, ns);
|
||||
|
||||
// Copy properties
|
||||
s.CopyPropertiesTo(ns);
|
||||
}
|
||||
|
||||
// Go for all sidedefs
|
||||
foreach(Sidedef d in sidedefs)
|
||||
{
|
||||
// Make new sidedef
|
||||
Sidedef nd = newset.CreateSidedef(linedeflink[d.Line], d.IsFront, sectorlink[d.Sector]);
|
||||
|
||||
// Copy properties
|
||||
d.CopyPropertiesTo(nd);
|
||||
}
|
||||
|
||||
// Go for all things
|
||||
foreach(Thing t in things)
|
||||
{
|
||||
// Make new thing
|
||||
Thing nt = newset.CreateThing(t.Type, t.Position);
|
||||
|
||||
// Copy properties
|
||||
t.CopyPropertiesTo(nt);
|
||||
}
|
||||
|
||||
// Return the new set
|
||||
return newset;
|
||||
}
|
||||
|
||||
// This creates a new vertex
|
||||
public Vertex CreateVertex(Vector2D pos)
|
||||
{
|
||||
|
@ -270,11 +337,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Tools
|
||||
|
||||
// This finds the line closest to the specified position
|
||||
public Linedef NearestLinedef(Vector2D pos) { return MapManager.NearestLinedef(linedefs, pos); }
|
||||
public Linedef NearestLinedef(Vector2D pos) { return MapSet.NearestLinedef(linedefs, pos); }
|
||||
|
||||
// This finds the vertex closest to the specified position
|
||||
public Vertex NearestVertex(Vector2D pos) { return MapManager.NearestVertex(vertices, pos); }
|
||||
|
||||
public Vertex NearestVertex(Vector2D pos) { return MapSet.NearestVertex(vertices, pos); }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Variables
|
||||
|
||||
// Map
|
||||
private MapManager map;
|
||||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Sector> mainlistitem;
|
||||
|
@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public Sector(MapManager map, LinkedListNode<Sector> listitem)
|
||||
public Sector(MapSet map, LinkedListNode<Sector> listitem)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
|
@ -119,6 +119,18 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This detaches a thing
|
||||
public void DetachThing(LinkedListNode<Thing> l) { if(!isdisposed) things.Remove(l); }
|
||||
|
||||
// This copies all properties to another sector
|
||||
public void CopyPropertiesTo(Sector s)
|
||||
{
|
||||
// Copy properties
|
||||
s.ceilheight = ceilheight;
|
||||
s.ceiltexname = ceiltexname;
|
||||
s.floorheight = floorheight;
|
||||
s.floortexname = floortexname;
|
||||
s.special = special;
|
||||
s.tag = tag;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Variables
|
||||
|
||||
// Map
|
||||
private MapManager map;
|
||||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Sidedef> mainlistitem;
|
||||
|
@ -41,6 +41,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
public bool IsFront { get { return (this == linedef.Front); } }
|
||||
public Linedef Line { get { return linedef; } }
|
||||
public Sidedef Other { get { if(this == linedef.Front) return linedef.Back; else return linedef.Front; } }
|
||||
public Sector Sector { get { return sector; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
@ -50,7 +52,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public Sidedef(MapManager map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s)
|
||||
public Sidedef(MapSet map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
|
@ -97,8 +99,19 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
#region ================== Management
|
||||
|
||||
// This copies all properties to another sidedef
|
||||
public void CopyPropertiesTo(Sidedef s)
|
||||
{
|
||||
// Copy properties
|
||||
s.offsetx = offsetx;
|
||||
s.offsety = offsety;
|
||||
s.texnamehigh = texnamehigh;
|
||||
s.texnamelow = texnamelow;
|
||||
s.texnamemid = texnamemid;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Variables
|
||||
|
||||
// Map
|
||||
private MapManager map;
|
||||
private MapSet map;
|
||||
|
||||
// Sector
|
||||
private Sector sector = null;
|
||||
|
@ -37,7 +37,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
// Disposing
|
||||
public int Type { get { return type; } }
|
||||
public Vector2D Position { get { return pos; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
||||
#endregion
|
||||
|
@ -45,7 +46,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public Thing(MapManager map, LinkedListNode<Thing> listitem, int type, Vector2D pos)
|
||||
public Thing(MapSet map, LinkedListNode<Thing> listitem, int type, Vector2D pos)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
|
@ -134,6 +135,14 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
}
|
||||
|
||||
// This copies all properties to another thing
|
||||
public void CopyPropertiesTo(Thing t)
|
||||
{
|
||||
// Copy properties
|
||||
t.type = type;
|
||||
t.angle = angle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Variables
|
||||
|
||||
// Map
|
||||
private MapManager map;
|
||||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Vertex> mainlistitem;
|
||||
|
@ -55,7 +55,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public Vertex(MapManager map, LinkedListNode<Vertex> listitem, Vector2D pos)
|
||||
public Vertex(MapSet map, LinkedListNode<Vertex> listitem, Vector2D pos)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
|
@ -146,7 +146,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Tools
|
||||
|
||||
// This finds the line closest to the specified position
|
||||
public Linedef NearestLinedef(Vector2D pos) { return MapManager.NearestLinedef(linedefs, pos); }
|
||||
public Linedef NearestLinedef(Vector2D pos) { return MapSet.NearestLinedef(linedefs, pos); }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue