2007-06-14 14:44:18 +00:00
|
|
|
|
2007-06-14 23:31:57 +00:00
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
2007-06-14 14:44:18 +00:00
|
|
|
/*
|
|
|
|
* 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-14 12:37:46 +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-14 12:37:46 +00:00
|
|
|
namespace CodeImp.DoomBuilder.Map
|
|
|
|
{
|
|
|
|
internal class Sector : IDisposable
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Map
|
2007-06-14 13:09:55 +00:00
|
|
|
private MapSet map;
|
2007-06-14 12:37:46 +00:00
|
|
|
|
|
|
|
// List items
|
|
|
|
private LinkedListNode<Sector> mainlistitem;
|
|
|
|
|
|
|
|
// Sidedefs
|
|
|
|
private LinkedList<Sidedef> sidedefs;
|
|
|
|
|
|
|
|
// Things
|
|
|
|
private LinkedList<Thing> things;
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
private int floorheight;
|
|
|
|
private int ceilheight;
|
|
|
|
private string floortexname;
|
|
|
|
private string ceiltexname;
|
|
|
|
private int special;
|
|
|
|
private int tag;
|
2007-10-14 15:44:55 +00:00
|
|
|
private int brightness;
|
2007-06-14 12:37:46 +00:00
|
|
|
|
|
|
|
// Disposing
|
|
|
|
private bool isdisposed = false;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
2007-07-07 09:40:34 +00:00
|
|
|
public MapSet Map { get { return map; } }
|
2007-06-14 12:37:46 +00:00
|
|
|
public bool IsDisposed { get { return isdisposed; } }
|
2007-10-14 15:44:55 +00:00
|
|
|
public int FloorHeight { get { return floorheight; } }
|
|
|
|
public int CeilHeight { get { return ceilheight; } }
|
|
|
|
public string FloorTexture { get { return floortexname; } }
|
|
|
|
public string CeilTexture { get { return ceiltexname; } }
|
|
|
|
public int Special { get { return special; } }
|
|
|
|
public int Tag { get { return tag; } }
|
|
|
|
public int Brightness { get { return brightness; } }
|
2007-06-14 12:37:46 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
2007-06-14 13:09:55 +00:00
|
|
|
public Sector(MapSet map, LinkedListNode<Sector> listitem)
|
2007-06-14 12:37:46 +00:00
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.map = map;
|
|
|
|
this.mainlistitem = listitem;
|
|
|
|
this.sidedefs = new LinkedList<Sidedef>();
|
|
|
|
this.things = new LinkedList<Thing>();
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
// Dispose the sidedefs that are attached to this sector
|
|
|
|
// because a sidedef cannot exist without reference to its sector.
|
|
|
|
foreach(Sidedef sd in sidedefs) sd.Dispose();
|
|
|
|
|
|
|
|
// Determine new sector references on things
|
|
|
|
foreach(Thing t in things) t.DetermineSector();
|
|
|
|
|
|
|
|
// Clean up
|
|
|
|
mainlistitem = null;
|
|
|
|
sidedefs = null;
|
|
|
|
things = null;
|
|
|
|
map = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Management
|
|
|
|
|
|
|
|
// This attaches a sidedef and returns the listitem
|
|
|
|
public LinkedListNode<Sidedef> AttachSidedef(Sidedef sd) { return sidedefs.AddLast(sd); }
|
|
|
|
|
|
|
|
// This detaches a sidedef
|
|
|
|
public void DetachSidedef(LinkedListNode<Sidedef> l)
|
|
|
|
{
|
|
|
|
// Not disposing?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Remove sidedef
|
|
|
|
sidedefs.Remove(l);
|
|
|
|
|
|
|
|
// No more sidedefs left?
|
|
|
|
if(sidedefs.Count == 0)
|
|
|
|
{
|
|
|
|
// This sector is now useless, dispose it
|
|
|
|
this.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This attaches a thing and returns the listitem
|
|
|
|
public LinkedListNode<Thing> AttachThing(Thing t) { return things.AddLast(t); }
|
|
|
|
|
|
|
|
// This detaches a thing
|
|
|
|
public void DetachThing(LinkedListNode<Thing> l) { if(!isdisposed) things.Remove(l); }
|
|
|
|
|
2007-06-14 13:09:55 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2007-06-14 12:37:46 +00:00
|
|
|
#endregion
|
2007-06-24 18:56:43 +00:00
|
|
|
|
|
|
|
#region ================== Changes
|
|
|
|
|
|
|
|
// This updates all properties
|
2007-10-14 15:44:55 +00:00
|
|
|
public void Update(int hfloor, int hceil, string tfloor, string tceil, int special, int tag, int brightness)
|
2007-06-24 18:56:43 +00:00
|
|
|
{
|
|
|
|
// Apply changes
|
|
|
|
this.floorheight = hfloor;
|
|
|
|
this.ceilheight = hceil;
|
|
|
|
this.floortexname = tfloor;
|
|
|
|
this.ceiltexname = tceil;
|
|
|
|
this.special = special;
|
|
|
|
this.tag = tag;
|
2007-10-14 15:44:55 +00:00
|
|
|
this.brightness = brightness;
|
2007-06-24 18:56:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2007-06-14 12:37:46 +00:00
|
|
|
}
|
|
|
|
}
|