2009-04-19 18:07:22 +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
|
|
|
|
|
2015-07-28 15:04:21 +00:00
|
|
|
using System.Collections.Generic;
|
2009-04-19 18:07:22 +00:00
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Types;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
public class Association
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-07-28 15:04:21 +00:00
|
|
|
private HashSet<int> tags;
|
2012-09-17 21:57:08 +00:00
|
|
|
private Vector2D center;
|
2015-07-28 15:04:21 +00:00
|
|
|
private UniversalType type;
|
|
|
|
|
|
|
|
public HashSet<int> Tags { get { return tags; } }
|
|
|
|
public Vector2D Center { get { return center; } }
|
|
|
|
public UniversalType Type { get { return type; } }
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2015-09-04 12:44:09 +00:00
|
|
|
//mxd. This sets up the association
|
|
|
|
public Association()
|
|
|
|
{
|
|
|
|
this.tags = new HashSet<int> { 0 };
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This sets up the association
|
2012-09-17 21:57:08 +00:00
|
|
|
public Association(Vector2D center, int tag, int type)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
this.tags = new HashSet<int> { tag }; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.type = (UniversalType)type;
|
2012-09-17 21:57:08 +00:00
|
|
|
this.center = center;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This sets up the association
|
2012-09-17 21:57:08 +00:00
|
|
|
public Association(Vector2D center, int tag, UniversalType type)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
this.tags = new HashSet<int> { tag }; //mxd
|
2015-07-28 15:04:21 +00:00
|
|
|
this.type = type;
|
|
|
|
this.center = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This also sets up the association
|
|
|
|
public Association(Vector2D center, IEnumerable<int> tags, int type)
|
|
|
|
{
|
|
|
|
this.tags = new HashSet<int>(tags); //mxd
|
|
|
|
this.type = (UniversalType)type;
|
|
|
|
this.center = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This also sets up the association
|
|
|
|
public Association(Vector2D center, IEnumerable<int> tags, UniversalType type)
|
|
|
|
{
|
|
|
|
this.tags = new HashSet<int>(tags); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.type = type;
|
2012-09-17 21:57:08 +00:00
|
|
|
this.center = center;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This sets up the association
|
2012-09-17 21:57:08 +00:00
|
|
|
public void Set(Vector2D center, int tag, int type)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
this.tags = new HashSet<int> { tag }; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.type = (UniversalType)type;
|
2012-09-17 21:57:08 +00:00
|
|
|
this.center = center;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This sets up the association
|
2012-09-17 21:57:08 +00:00
|
|
|
public void Set(Vector2D center, int tag, UniversalType type)
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
this.tags = new HashSet<int> { tag }; //mxd
|
2015-07-28 15:04:21 +00:00
|
|
|
this.type = type;
|
|
|
|
this.center = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This also sets up the association
|
|
|
|
public void Set(Vector2D center, IEnumerable<int> tags, int type)
|
|
|
|
{
|
|
|
|
this.tags = new HashSet<int>(tags); //mxd
|
|
|
|
this.type = (UniversalType)type;
|
|
|
|
this.center = center;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd. This also sets up the association
|
|
|
|
public void Set(Vector2D center, IEnumerable<int> tags, UniversalType type)
|
|
|
|
{
|
|
|
|
this.tags = new HashSet<int>(tags); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
this.type = type;
|
2012-09-17 21:57:08 +00:00
|
|
|
this.center = center;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This compares an association
|
|
|
|
public static bool operator ==(Association a, Association b)
|
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
if(!(a is Association) || !(b is Association)) return false; //mxd
|
2015-07-28 15:04:21 +00:00
|
|
|
return (a.type == b.type) && a.tags.SetEquals(b.tags);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This compares an association
|
|
|
|
public static bool operator !=(Association a, Association b)
|
|
|
|
{
|
2015-09-04 12:44:09 +00:00
|
|
|
if(!(a is Association) || !(b is Association)) return true; //mxd
|
2015-07-28 15:04:21 +00:00
|
|
|
return (a.type != b.type) || !a.tags.SetEquals(b.tags);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2013-03-18 13:52:27 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
return base.GetHashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
|
|
|
if(!(obj is Association)) return false;
|
|
|
|
|
|
|
|
Association b = (Association)obj;
|
2015-07-28 15:04:21 +00:00
|
|
|
return (type == b.type) && tags.SetEquals(b.tags);
|
2013-03-18 13:52:27 +00:00
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|