2008-05-30 08:41:13 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using SlimDX.Direct3D9;
|
|
|
|
using System.Drawing;
|
2008-12-06 13:20:47 +00:00
|
|
|
using CodeImp.DoomBuilder.IO;
|
2008-05-30 08:41:13 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Map
|
|
|
|
{
|
|
|
|
public abstract class MapElement : IDisposable
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
|
|
|
|
|
|
|
// Univeral fields
|
|
|
|
private UniFields fields;
|
2008-10-16 08:45:23 +00:00
|
|
|
|
|
|
|
// Marking
|
|
|
|
protected bool marked;
|
|
|
|
|
2008-05-30 08:41:13 +00:00
|
|
|
// Disposing
|
|
|
|
protected bool isdisposed = false;
|
|
|
|
|
|
|
|
#endregion
|
2008-10-16 08:45:23 +00:00
|
|
|
|
2008-05-30 08:41:13 +00:00
|
|
|
#region ================== Properties
|
2008-10-16 08:45:23 +00:00
|
|
|
|
2008-05-30 08:41:13 +00:00
|
|
|
public UniFields Fields { get { return fields; } }
|
2008-10-16 08:45:23 +00:00
|
|
|
public bool Marked { get { return marked; } set { marked = value; } }
|
2008-05-30 08:41:13 +00:00
|
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
internal MapElement()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
fields = new UniFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public virtual void Dispose()
|
|
|
|
{
|
2009-03-30 19:02:56 +00:00
|
|
|
// Clean up
|
|
|
|
fields = null;
|
|
|
|
|
|
|
|
// Done
|
|
|
|
isdisposed = true;
|
2008-05-30 08:41:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2008-10-16 08:45:23 +00:00
|
|
|
#region ================== Methods
|
|
|
|
|
2008-12-06 13:20:47 +00:00
|
|
|
// Serialize / deserialize
|
|
|
|
internal void ReadWrite(IReadWriteStream s)
|
|
|
|
{
|
|
|
|
int c = fields.Count;
|
|
|
|
s.rwInt(ref c);
|
|
|
|
|
|
|
|
if(s.IsWriting)
|
|
|
|
{
|
|
|
|
foreach(KeyValuePair<string, UniValue> f in fields)
|
|
|
|
{
|
|
|
|
s.wString(f.Key);
|
|
|
|
f.Value.ReadWrite(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fields = new UniFields(c);
|
|
|
|
for(int i = 0; i < c; i++)
|
|
|
|
{
|
|
|
|
string t; s.rString(out t);
|
|
|
|
UniValue v = new UniValue(); v.ReadWrite(s);
|
|
|
|
fields.Add(t, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 08:45:23 +00:00
|
|
|
// This copies properties to any other element
|
|
|
|
public void CopyPropertiesTo(MapElement element)
|
2008-05-30 08:41:13 +00:00
|
|
|
{
|
|
|
|
element.fields = new UniFields(this.fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|