using System; using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Text; namespace CodeImp.DoomBuilder.Map { internal class Sidedef : IDisposable { #region ================== Constants #endregion #region ================== Variables // Map private MapManager map; // List items private LinkedListNode mainlistitem; private LinkedListNode 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; // Disposing private bool isdisposed = false; #endregion #region ================== Properties 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; } } #endregion #region ================== Constructor / Disposer // Constructor public Sidedef(MapManager map, LinkedListNode listitem, Linedef l, bool front, Sector s) { // Initialize 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); // We have no destructor GC.SuppressFinalize(this); } // Diposer public void Dispose() { // Not already disposed? if(!isdisposed) { // Already set isdisposed so that changes can be prohibited isdisposed = true; // 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; } } #endregion #region ================== Methods #endregion } }