UltimateZoneBuilder/Source/Map/Sidedef.cs

159 lines
3.7 KiB
C#
Raw Normal View History

2007-06-14 23:31:57 +00:00
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
2007-06-14 23:31:57 +00:00
#endregion
#region ================== Namespaces
2007-06-13 19:39:38 +00:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
2007-06-14 23:31:57 +00:00
#endregion
2007-06-13 19:39:38 +00:00
namespace CodeImp.DoomBuilder.Map
{
2007-10-24 17:25:03 +00:00
public class Sidedef : IDisposable
2007-06-13 19:39:38 +00:00
{
#region ================== Constants
#endregion
#region ================== Variables
2007-06-14 12:37:46 +00:00
// Map
private MapSet map;
2007-06-14 12:37:46 +00:00
// List items
private LinkedListNode<Sidedef> mainlistitem;
private LinkedListNode<Sidedef> sectorlistitem;
// Owner
private Linedef linedef;
// Sector
private Sector sector;
// Properties
private int offsetx;
private int offsety;
private string texnamehigh;
private string texnamemid;
private string texnamelow;
2007-06-13 19:39:38 +00:00
// Disposing
private bool isdisposed = false;
#endregion
#region ================== Properties
public MapSet Map { get { return map; } }
public bool IsFront { get { return (this == linedef.Front); } }
public Linedef Line { get { return linedef; } }
2007-06-14 12:37:46 +00:00
public Sidedef Other { get { if(this == linedef.Front) return linedef.Back; else return linedef.Front; } }
public Sector Sector { get { return sector; } }
2007-06-13 19:39:38 +00:00
public bool IsDisposed { get { return isdisposed; } }
2007-10-14 15:44:55 +00:00
public int OffsetX { get { return offsetx; } }
public int OffsetY { get { return offsety; } }
public string HighTexture { get { return texnamehigh; } }
public string MiddleTexture { get { return texnamemid; } }
public string LowTexture { get { return texnamelow; } }
2007-06-13 19:39:38 +00:00
#endregion
#region ================== Constructor / Disposer
// Constructor
public Sidedef(MapSet map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s)
2007-06-13 19:39:38 +00:00
{
// Initialize
2007-06-14 12:37:46 +00:00
this.map = map;
this.mainlistitem = listitem;
this.linedef = l;
this.sector = s;
// Attach to the linedef
if(front) l.AttachFront(this); else l.AttachBack(this);
// Attach to sector
sectorlistitem = s.AttachSidedef(this);
2007-06-13 19:39:38 +00:00
// We have no destructor
GC.SuppressFinalize(this);
}
// Diposer
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
2007-06-14 12:37:46 +00:00
// Already set isdisposed so that changes can be prohibited
2007-06-13 19:39:38 +00:00
isdisposed = true;
2007-06-14 12:37:46 +00:00
// Remove from main list
mainlistitem.List.Remove(mainlistitem);
// Detach from linedef
linedef.DetachSidedef(this);
// Detach from sector
sector.DetachSidedef(sectorlistitem);
// Clean up
mainlistitem = null;
sectorlistitem = null;
linedef = null;
map = null;
sector = null;
2007-06-13 19:39:38 +00:00
}
}
#endregion
#region ================== Management
2007-06-13 19:39:38 +00:00
// 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;
}
2007-06-13 19:39:38 +00:00
#endregion
2007-06-24 18:56:43 +00:00
#region ================== Changes
// This updates all properties
public void Update(int offsetx, int offsety, string thigh, string tmid, string tlow)
{
// Apply changes
this.offsetx = offsetx;
this.offsety = offsety;
this.texnamehigh = thigh;
this.texnamemid = tmid;
this.texnamelow = tlow;
}
#endregion
2007-06-13 19:39:38 +00:00
}
}