Fixes formatting (#200)
This commit is contained in:
parent
1f651992d7
commit
86b7b3aed1
209 changed files with 51326 additions and 50397 deletions
|
|
@ -1,122 +1,123 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct Point2D :
|
||||
IPoint2D, IComparable<Point2D>, IComparable<IPoint2D>, IEquatable<object>, IEquatable<Point2D>, IEquatable<IPoint2D>
|
||||
{
|
||||
internal int m_X;
|
||||
internal int m_Y;
|
||||
|
||||
public static readonly Point2D Zero = new Point2D(0, 0);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_X;
|
||||
set => m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Y;
|
||||
set => m_Y = value;
|
||||
}
|
||||
|
||||
public Point2D(int x, int y)
|
||||
{
|
||||
m_X = x;
|
||||
m_Y = y;
|
||||
}
|
||||
|
||||
public Point2D(IPoint2D p) : this(p.X, p.Y)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => $"({m_X}, {m_Y})";
|
||||
|
||||
public static Point2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int y);
|
||||
|
||||
return new Point2D(x, y);
|
||||
}
|
||||
|
||||
public bool Equals(Point2D other) => m_X == other.m_X && m_Y == other.m_Y;
|
||||
|
||||
public bool Equals(IPoint2D other) =>
|
||||
!ReferenceEquals(other, null) && m_X == other.X && m_Y == other.Y;
|
||||
|
||||
public override bool Equals(object obj) => obj is Point2D other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_X, m_Y);
|
||||
|
||||
public static bool operator ==(Point2D l, Point2D r) => l.m_X == r.m_X && l.m_Y == r.m_Y;
|
||||
|
||||
public static bool operator !=(Point2D l, Point2D r) => l.m_X != r.m_X || l.m_Y != r.m_Y;
|
||||
|
||||
public static bool operator ==(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y;
|
||||
|
||||
public static bool operator !=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y);
|
||||
|
||||
public static bool operator >(Point2D l, Point2D r) => l.m_X > r.m_X && l.m_Y > r.m_Y;
|
||||
|
||||
public static bool operator >(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y;
|
||||
|
||||
public static bool operator <(Point2D l, Point2D r) => l.m_X < r.m_X && l.m_Y < r.m_Y;
|
||||
|
||||
public static bool operator <(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y;
|
||||
|
||||
public static bool operator >=(Point2D l, Point2D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y;
|
||||
|
||||
public static bool operator >=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y;
|
||||
|
||||
public static bool operator <=(Point2D l, Point2D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y;
|
||||
|
||||
public static bool operator <=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y;
|
||||
|
||||
public int CompareTo(Point2D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.m_X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
return m_Y.CompareTo(other.m_Y);
|
||||
}
|
||||
|
||||
public int CompareTo(IPoint2D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
return m_Y.CompareTo(other.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct Point2D
|
||||
: IPoint2D, IComparable<Point2D>, IComparable<IPoint2D>, IEquatable<object>, IEquatable<Point2D>,
|
||||
IEquatable<IPoint2D>
|
||||
{
|
||||
internal int m_X;
|
||||
internal int m_Y;
|
||||
|
||||
public static readonly Point2D Zero = new Point2D(0, 0);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_X;
|
||||
set => m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Y;
|
||||
set => m_Y = value;
|
||||
}
|
||||
|
||||
public Point2D(int x, int y)
|
||||
{
|
||||
m_X = x;
|
||||
m_Y = y;
|
||||
}
|
||||
|
||||
public Point2D(IPoint2D p) : this(p.X, p.Y)
|
||||
{
|
||||
}
|
||||
|
||||
public override string ToString() => $"({m_X}, {m_Y})";
|
||||
|
||||
public static Point2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
|
||||
return new Point2D(x, y);
|
||||
}
|
||||
|
||||
public bool Equals(Point2D other) => m_X == other.m_X && m_Y == other.m_Y;
|
||||
|
||||
public bool Equals(IPoint2D other) =>
|
||||
!ReferenceEquals(other, null) && m_X == other.X && m_Y == other.Y;
|
||||
|
||||
public override bool Equals(object obj) => obj is Point2D other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_X, m_Y);
|
||||
|
||||
public static bool operator ==(Point2D l, Point2D r) => l.m_X == r.m_X && l.m_Y == r.m_Y;
|
||||
|
||||
public static bool operator !=(Point2D l, Point2D r) => l.m_X != r.m_X || l.m_Y != r.m_Y;
|
||||
|
||||
public static bool operator ==(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y;
|
||||
|
||||
public static bool operator !=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y);
|
||||
|
||||
public static bool operator >(Point2D l, Point2D r) => l.m_X > r.m_X && l.m_Y > r.m_Y;
|
||||
|
||||
public static bool operator >(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y;
|
||||
|
||||
public static bool operator <(Point2D l, Point2D r) => l.m_X < r.m_X && l.m_Y < r.m_Y;
|
||||
|
||||
public static bool operator <(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y;
|
||||
|
||||
public static bool operator >=(Point2D l, Point2D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y;
|
||||
|
||||
public static bool operator >=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y;
|
||||
|
||||
public static bool operator <=(Point2D l, Point2D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y;
|
||||
|
||||
public static bool operator <=(Point2D l, IPoint2D r) => !ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y;
|
||||
|
||||
public int CompareTo(Point2D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.m_X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
return m_Y.CompareTo(other.m_Y);
|
||||
}
|
||||
|
||||
public int CompareTo(IPoint2D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
return m_Y.CompareTo(other.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,150 +1,151 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct Point3D :
|
||||
IPoint3D, IComparable<Point3D>, IComparable<IPoint3D>, IEquatable<object>, IEquatable<Point3D>, IEquatable<IPoint3D>
|
||||
{
|
||||
internal int m_X;
|
||||
internal int m_Y;
|
||||
internal int m_Z;
|
||||
|
||||
public static readonly Point3D Zero = new Point3D(0, 0, 0);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_X;
|
||||
set => m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Y;
|
||||
set => m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Z;
|
||||
set => m_Z = value;
|
||||
}
|
||||
|
||||
public Point3D(IPoint3D p) : this(p.X, p.Y, p.Z)
|
||||
{
|
||||
}
|
||||
|
||||
public Point3D(IPoint2D p, int z) : this(p.X, p.Y, z)
|
||||
{
|
||||
}
|
||||
|
||||
public Point3D(int x, int y, int z)
|
||||
{
|
||||
m_X = x;
|
||||
m_Y = y;
|
||||
m_Z = z;
|
||||
}
|
||||
|
||||
public override string ToString() => $"({m_X}, {m_Y}, {m_Z})";
|
||||
|
||||
public bool Equals(Point3D other) => m_X == other.m_X && m_Y == other.m_Y && m_Z == other.m_Z;
|
||||
|
||||
public bool Equals(IPoint3D other) =>
|
||||
!ReferenceEquals(other, null) && m_X == other.X && m_Y == other.Y && m_Z == other.Z;
|
||||
|
||||
public override bool Equals(object obj) => obj is Point3D other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_X, m_Y, m_Z);
|
||||
|
||||
public static Point3D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int z);
|
||||
|
||||
return new Point3D(x, y, z);
|
||||
}
|
||||
|
||||
public static bool operator ==(Point3D l, Point3D r) => l.m_X == r.m_X && l.m_Y == r.m_Y && l.m_Z == r.m_Z;
|
||||
|
||||
public static bool operator ==(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z;
|
||||
|
||||
public static bool operator !=(Point3D l, Point3D r) => l.m_X != r.m_X || l.m_Y != r.m_Y || l.m_Z != r.m_Z;
|
||||
|
||||
public static bool operator !=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z);
|
||||
|
||||
public static bool operator >(Point3D l, Point3D r) => l.m_X > r.m_X && l.m_Y > r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator >(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator <(Point3D l, Point3D r) => l.m_X < r.m_X && l.m_Y < r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator <(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator >=(Point3D l, Point3D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator >=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator <=(Point3D l, Point3D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator <=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y && l.m_Z > r.Z;
|
||||
|
||||
public int CompareTo(Point3D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.m_X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
var yComparison = m_Y.CompareTo(other.m_Y);
|
||||
if (yComparison != 0) return yComparison;
|
||||
return m_Z.CompareTo(other.m_Z);
|
||||
}
|
||||
|
||||
public int CompareTo(IPoint3D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
var yComparison = m_Y.CompareTo(other.Y);
|
||||
if (yComparison != 0) return yComparison;
|
||||
return m_Z.CompareTo(other.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct Point3D
|
||||
: IPoint3D, IComparable<Point3D>, IComparable<IPoint3D>, IEquatable<object>, IEquatable<Point3D>,
|
||||
IEquatable<IPoint3D>
|
||||
{
|
||||
internal int m_X;
|
||||
internal int m_Y;
|
||||
internal int m_Z;
|
||||
|
||||
public static readonly Point3D Zero = new Point3D(0, 0, 0);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_X;
|
||||
set => m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Y;
|
||||
set => m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Z;
|
||||
set => m_Z = value;
|
||||
}
|
||||
|
||||
public Point3D(IPoint3D p) : this(p.X, p.Y, p.Z)
|
||||
{
|
||||
}
|
||||
|
||||
public Point3D(IPoint2D p, int z) : this(p.X, p.Y, z)
|
||||
{
|
||||
}
|
||||
|
||||
public Point3D(int x, int y, int z)
|
||||
{
|
||||
m_X = x;
|
||||
m_Y = y;
|
||||
m_Z = z;
|
||||
}
|
||||
|
||||
public override string ToString() => $"({m_X}, {m_Y}, {m_Z})";
|
||||
|
||||
public bool Equals(Point3D other) => m_X == other.m_X && m_Y == other.m_Y && m_Z == other.m_Z;
|
||||
|
||||
public bool Equals(IPoint3D other) =>
|
||||
!ReferenceEquals(other, null) && m_X == other.X && m_Y == other.Y && m_Z == other.Z;
|
||||
|
||||
public override bool Equals(object obj) => obj is Point3D other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_X, m_Y, m_Z);
|
||||
|
||||
public static Point3D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var z);
|
||||
|
||||
return new Point3D(x, y, z);
|
||||
}
|
||||
|
||||
public static bool operator ==(Point3D l, Point3D r) => l.m_X == r.m_X && l.m_Y == r.m_Y && l.m_Z == r.m_Z;
|
||||
|
||||
public static bool operator ==(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z;
|
||||
|
||||
public static bool operator !=(Point3D l, Point3D r) => l.m_X != r.m_X || l.m_Y != r.m_Y || l.m_Z != r.m_Z;
|
||||
|
||||
public static bool operator !=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z);
|
||||
|
||||
public static bool operator >(Point3D l, Point3D r) => l.m_X > r.m_X && l.m_Y > r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator >(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X > r.X && l.m_Y > r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator <(Point3D l, Point3D r) => l.m_X < r.m_X && l.m_Y < r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator <(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X < r.X && l.m_Y < r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator >=(Point3D l, Point3D r) => l.m_X >= r.m_X && l.m_Y >= r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator >=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X >= r.X && l.m_Y >= r.Y && l.m_Z > r.Z;
|
||||
|
||||
public static bool operator <=(Point3D l, Point3D r) => l.m_X <= r.m_X && l.m_Y <= r.m_Y && l.m_Z > r.m_Z;
|
||||
|
||||
public static bool operator <=(Point3D l, IPoint3D r) =>
|
||||
!ReferenceEquals(r, null) && l.m_X <= r.X && l.m_Y <= r.Y && l.m_Z > r.Z;
|
||||
|
||||
public int CompareTo(Point3D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.m_X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
var yComparison = m_Y.CompareTo(other.m_Y);
|
||||
if (yComparison != 0) return yComparison;
|
||||
return m_Z.CompareTo(other.m_Z);
|
||||
}
|
||||
|
||||
public int CompareTo(IPoint3D other)
|
||||
{
|
||||
var xComparison = m_X.CompareTo(other.X);
|
||||
if (xComparison != 0) return xComparison;
|
||||
var yComparison = m_Y.CompareTo(other.Y);
|
||||
if (yComparison != 0) return yComparison;
|
||||
return m_Z.CompareTo(other.Z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,94 +1,96 @@
|
|||
/***************************************************************************
|
||||
* Point3DList.cs
|
||||
* -------------------
|
||||
* begin : May 1, 2002
|
||||
* copyright : (C) The RunUO Software Team
|
||||
* email : info@runuo.com
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class Point3DList
|
||||
{
|
||||
private static readonly Point3D[] m_EmptyList = System.Array.Empty<Point3D>();
|
||||
private Point3D[] m_List;
|
||||
|
||||
public Point3DList()
|
||||
{
|
||||
m_List = new Point3D[8];
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public Point3D Last => m_List[Count - 1];
|
||||
|
||||
public Point3D this[int index] => m_List[index];
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
public void Add(int x, int y, int z)
|
||||
{
|
||||
if (Count + 1 > m_List.Length)
|
||||
{
|
||||
var old = m_List;
|
||||
m_List = new Point3D[old.Length * 2];
|
||||
|
||||
for (var i = 0; i < old.Length; ++i)
|
||||
m_List[i] = old[i];
|
||||
}
|
||||
|
||||
m_List[Count].m_X = x;
|
||||
m_List[Count].m_Y = y;
|
||||
m_List[Count].m_Z = z;
|
||||
++Count;
|
||||
}
|
||||
|
||||
public void Add(Point3D p)
|
||||
{
|
||||
if (Count + 1 > m_List.Length)
|
||||
{
|
||||
var old = m_List;
|
||||
m_List = new Point3D[old.Length * 2];
|
||||
|
||||
for (var i = 0; i < old.Length; ++i)
|
||||
m_List[i] = old[i];
|
||||
}
|
||||
|
||||
m_List[Count].m_X = p.m_X;
|
||||
m_List[Count].m_Y = p.m_Y;
|
||||
m_List[Count].m_Z = p.m_Z;
|
||||
++Count;
|
||||
}
|
||||
|
||||
public Point3D[] ToArray()
|
||||
{
|
||||
if (Count == 0)
|
||||
return m_EmptyList;
|
||||
|
||||
var list = new Point3D[Count];
|
||||
|
||||
for (var i = 0; i < Count; ++i)
|
||||
list[i] = m_List[i];
|
||||
|
||||
Count = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************************************************
|
||||
* Point3DList.cs
|
||||
* -------------------
|
||||
* begin : May 1, 2002
|
||||
* copyright : (C) The RunUO Software Team
|
||||
* email : info@runuo.com
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class Point3DList
|
||||
{
|
||||
private static readonly Point3D[] m_EmptyList = Array.Empty<Point3D>();
|
||||
private Point3D[] m_List;
|
||||
|
||||
public Point3DList()
|
||||
{
|
||||
m_List = new Point3D[8];
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public Point3D Last => m_List[Count - 1];
|
||||
|
||||
public Point3D this[int index] => m_List[index];
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
public void Add(int x, int y, int z)
|
||||
{
|
||||
if (Count + 1 > m_List.Length)
|
||||
{
|
||||
var old = m_List;
|
||||
m_List = new Point3D[old.Length * 2];
|
||||
|
||||
for (var i = 0; i < old.Length; ++i)
|
||||
m_List[i] = old[i];
|
||||
}
|
||||
|
||||
m_List[Count].m_X = x;
|
||||
m_List[Count].m_Y = y;
|
||||
m_List[Count].m_Z = z;
|
||||
++Count;
|
||||
}
|
||||
|
||||
public void Add(Point3D p)
|
||||
{
|
||||
if (Count + 1 > m_List.Length)
|
||||
{
|
||||
var old = m_List;
|
||||
m_List = new Point3D[old.Length * 2];
|
||||
|
||||
for (var i = 0; i < old.Length; ++i)
|
||||
m_List[i] = old[i];
|
||||
}
|
||||
|
||||
m_List[Count].m_X = p.m_X;
|
||||
m_List[Count].m_Y = p.m_Y;
|
||||
m_List[Count].m_Z = p.m_Z;
|
||||
++Count;
|
||||
}
|
||||
|
||||
public Point3D[] ToArray()
|
||||
{
|
||||
if (Count == 0)
|
||||
return m_EmptyList;
|
||||
|
||||
var list = new Point3D[Count];
|
||||
|
||||
for (var i = 0; i < Count; ++i)
|
||||
list[i] = m_List[i];
|
||||
|
||||
Count = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,141 +1,141 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle2D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[Parsable]
|
||||
[PropertyObject]
|
||||
public struct Rectangle2D
|
||||
{
|
||||
private Point2D m_Start;
|
||||
private Point2D m_End;
|
||||
|
||||
public Rectangle2D(IPoint2D start, IPoint2D end)
|
||||
{
|
||||
m_Start = new Point2D(start);
|
||||
m_End = new Point2D(end);
|
||||
}
|
||||
|
||||
public Rectangle2D(int x, int y, int width, int height)
|
||||
{
|
||||
m_Start = new Point2D(x, y);
|
||||
m_End = new Point2D(x + width, y + height);
|
||||
}
|
||||
|
||||
public void Set(int x, int y, int width, int height)
|
||||
{
|
||||
m_Start = new Point2D(x, y);
|
||||
m_End = new Point2D(x + width, y + height);
|
||||
}
|
||||
|
||||
public static Rectangle2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int w);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int h);
|
||||
|
||||
return new Rectangle2D(x, y, w, h);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point2D Start
|
||||
{
|
||||
get => m_Start;
|
||||
set => m_Start = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point2D End
|
||||
{
|
||||
get => m_End;
|
||||
set => m_End = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Start.m_X;
|
||||
set => m_Start.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Start.m_Y;
|
||||
set => m_Start.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Width
|
||||
{
|
||||
get => m_End.m_X - m_Start.m_X;
|
||||
set => m_End.m_X = m_Start.m_X + value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Height
|
||||
{
|
||||
get => m_End.m_Y - m_Start.m_Y;
|
||||
set => m_End.m_Y = m_Start.m_Y + value;
|
||||
}
|
||||
|
||||
public void MakeHold(Rectangle2D r)
|
||||
{
|
||||
if (r.m_Start.m_X < m_Start.m_X)
|
||||
m_Start.m_X = r.m_Start.m_X;
|
||||
|
||||
if (r.m_Start.m_Y < m_Start.m_Y)
|
||||
m_Start.m_Y = r.m_Start.m_Y;
|
||||
|
||||
if (r.m_End.m_X > m_End.m_X)
|
||||
m_End.m_X = r.m_End.m_X;
|
||||
|
||||
if (r.m_End.m_Y > m_End.m_Y)
|
||||
m_End.m_Y = r.m_End.m_Y;
|
||||
}
|
||||
|
||||
public bool Contains(Point3D p) =>
|
||||
m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y;
|
||||
|
||||
public bool Contains(Point2D p) =>
|
||||
m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y;
|
||||
|
||||
public bool Contains(IPoint2D p) => m_Start <= p && m_End > p;
|
||||
|
||||
public override string ToString() => $"({X}, {Y})+({Width}, {Height})";
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle2D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[Parsable]
|
||||
[PropertyObject]
|
||||
public struct Rectangle2D
|
||||
{
|
||||
private Point2D m_Start;
|
||||
private Point2D m_End;
|
||||
|
||||
public Rectangle2D(IPoint2D start, IPoint2D end)
|
||||
{
|
||||
m_Start = new Point2D(start);
|
||||
m_End = new Point2D(end);
|
||||
}
|
||||
|
||||
public Rectangle2D(int x, int y, int width, int height)
|
||||
{
|
||||
m_Start = new Point2D(x, y);
|
||||
m_End = new Point2D(x + width, y + height);
|
||||
}
|
||||
|
||||
public void Set(int x, int y, int width, int height)
|
||||
{
|
||||
m_Start = new Point2D(x, y);
|
||||
m_End = new Point2D(x + width, y + height);
|
||||
}
|
||||
|
||||
public static Rectangle2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var w);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var h);
|
||||
|
||||
return new Rectangle2D(x, y, w, h);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point2D Start
|
||||
{
|
||||
get => m_Start;
|
||||
set => m_Start = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point2D End
|
||||
{
|
||||
get => m_End;
|
||||
set => m_End = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Start.m_X;
|
||||
set => m_Start.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Start.m_Y;
|
||||
set => m_Start.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Width
|
||||
{
|
||||
get => m_End.m_X - m_Start.m_X;
|
||||
set => m_End.m_X = m_Start.m_X + value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Height
|
||||
{
|
||||
get => m_End.m_Y - m_Start.m_Y;
|
||||
set => m_End.m_Y = m_Start.m_Y + value;
|
||||
}
|
||||
|
||||
public void MakeHold(Rectangle2D r)
|
||||
{
|
||||
if (r.m_Start.m_X < m_Start.m_X)
|
||||
m_Start.m_X = r.m_Start.m_X;
|
||||
|
||||
if (r.m_Start.m_Y < m_Start.m_Y)
|
||||
m_Start.m_Y = r.m_Start.m_Y;
|
||||
|
||||
if (r.m_End.m_X > m_End.m_X)
|
||||
m_End.m_X = r.m_End.m_X;
|
||||
|
||||
if (r.m_End.m_Y > m_End.m_Y)
|
||||
m_End.m_Y = r.m_End.m_Y;
|
||||
}
|
||||
|
||||
public bool Contains(Point3D p) =>
|
||||
m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y;
|
||||
|
||||
public bool Contains(Point2D p) =>
|
||||
m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y;
|
||||
|
||||
public bool Contains(IPoint2D p) => m_Start <= p && m_End > p;
|
||||
|
||||
public override string ToString() => $"({X}, {Y})+({Width}, {Height})";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,123 +1,123 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[PropertyObject]
|
||||
public struct Rectangle3D
|
||||
{
|
||||
private Point3D m_Start;
|
||||
private Point3D m_End;
|
||||
|
||||
public Rectangle3D(Point3D start, Point3D end)
|
||||
{
|
||||
m_Start = start;
|
||||
m_End = end;
|
||||
}
|
||||
|
||||
public Rectangle3D(int x, int y, int z, int width, int height, int depth)
|
||||
{
|
||||
m_Start = new Point3D(x, y, z);
|
||||
m_End = new Point3D(x + width, y + height, z + depth);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Start
|
||||
{
|
||||
get => m_Start;
|
||||
set => m_Start = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D End
|
||||
{
|
||||
get => m_End;
|
||||
set => m_End = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Start.m_X;
|
||||
set => m_Start.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Start.m_Y;
|
||||
set => m_Start.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Start.m_Z;
|
||||
set => m_Start.m_Z = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Width => m_End.X - m_Start.X;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Height => m_End.Y - m_Start.Y;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Depth => m_End.Z - m_Start.Z;
|
||||
|
||||
public void MakeHold(Rectangle3D r)
|
||||
{
|
||||
if (r.m_Start.m_X < m_Start.m_X)
|
||||
m_Start.m_X = r.m_Start.m_X;
|
||||
|
||||
if (r.m_Start.m_Y < m_Start.m_Y)
|
||||
m_Start.m_Y = r.m_Start.m_Y;
|
||||
|
||||
if (r.m_Start.m_Z < m_Start.m_Z)
|
||||
m_Start.m_Z = r.m_Start.m_Z;
|
||||
|
||||
if (r.m_End.m_X > m_End.m_X)
|
||||
m_End.m_X = r.m_End.m_X;
|
||||
|
||||
if (r.m_End.m_Y > m_End.m_Y)
|
||||
m_End.m_Y = r.m_End.m_Y;
|
||||
|
||||
if (r.m_End.m_Z < m_End.m_Z)
|
||||
m_End.m_Z = r.m_End.m_Z;
|
||||
}
|
||||
|
||||
public bool Contains(Point3D p) =>
|
||||
p.m_X >= m_Start.m_X
|
||||
&& p.m_X < m_End.m_X
|
||||
&& p.m_Y >= m_Start.m_Y
|
||||
&& p.m_Y < m_End.m_Y
|
||||
&& p.m_Z >= m_Start.m_Z
|
||||
&& p.m_Z < m_End.m_Z;
|
||||
|
||||
public bool Contains(IPoint3D p) =>
|
||||
p.X >= m_Start.m_X
|
||||
&& p.X < m_End.m_X
|
||||
&& p.Y >= m_Start.m_Y
|
||||
&& p.Y < m_End.m_Y
|
||||
&& p.Z >= m_Start.m_Z
|
||||
&& p.Z < m_End.m_Z;
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3D.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[PropertyObject]
|
||||
public struct Rectangle3D
|
||||
{
|
||||
private Point3D m_Start;
|
||||
private Point3D m_End;
|
||||
|
||||
public Rectangle3D(Point3D start, Point3D end)
|
||||
{
|
||||
m_Start = start;
|
||||
m_End = end;
|
||||
}
|
||||
|
||||
public Rectangle3D(int x, int y, int z, int width, int height, int depth)
|
||||
{
|
||||
m_Start = new Point3D(x, y, z);
|
||||
m_End = new Point3D(x + width, y + height, z + depth);
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Start
|
||||
{
|
||||
get => m_Start;
|
||||
set => m_Start = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D End
|
||||
{
|
||||
get => m_End;
|
||||
set => m_End = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Start.m_X;
|
||||
set => m_Start.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Start.m_Y;
|
||||
set => m_Start.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Start.m_Z;
|
||||
set => m_Start.m_Z = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Width => m_End.X - m_Start.X;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Height => m_End.Y - m_Start.Y;
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Depth => m_End.Z - m_Start.Z;
|
||||
|
||||
public void MakeHold(Rectangle3D r)
|
||||
{
|
||||
if (r.m_Start.m_X < m_Start.m_X)
|
||||
m_Start.m_X = r.m_Start.m_X;
|
||||
|
||||
if (r.m_Start.m_Y < m_Start.m_Y)
|
||||
m_Start.m_Y = r.m_Start.m_Y;
|
||||
|
||||
if (r.m_Start.m_Z < m_Start.m_Z)
|
||||
m_Start.m_Z = r.m_Start.m_Z;
|
||||
|
||||
if (r.m_End.m_X > m_End.m_X)
|
||||
m_End.m_X = r.m_End.m_X;
|
||||
|
||||
if (r.m_End.m_Y > m_End.m_Y)
|
||||
m_End.m_Y = r.m_End.m_Y;
|
||||
|
||||
if (r.m_End.m_Z < m_End.m_Z)
|
||||
m_End.m_Z = r.m_End.m_Z;
|
||||
}
|
||||
|
||||
public bool Contains(Point3D p) =>
|
||||
p.m_X >= m_Start.m_X
|
||||
&& p.m_X < m_End.m_X
|
||||
&& p.m_Y >= m_Start.m_Y
|
||||
&& p.m_Y < m_End.m_Y
|
||||
&& p.m_Z >= m_Start.m_Z
|
||||
&& p.m_Z < m_End.m_Z;
|
||||
|
||||
public bool Contains(IPoint3D p) =>
|
||||
p.X >= m_Start.m_X
|
||||
&& p.X < m_End.m_X
|
||||
&& p.Y >= m_Start.m_Y
|
||||
&& p.Y < m_End.m_Y
|
||||
&& p.Z >= m_Start.m_Z
|
||||
&& p.Z < m_End.m_Z;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,173 +1,174 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocation.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct WorldLocation : IPoint3D, IComparable<WorldLocation>, IEquatable<object>, IEquatable<WorldLocation>, IEquatable<IEntity>
|
||||
{
|
||||
internal Point3D m_Loc;
|
||||
internal Map m_Map;
|
||||
|
||||
public static readonly WorldLocation Zero = new WorldLocation(0, 0, 0, Map.Internal);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Location
|
||||
{
|
||||
get => m_Loc;
|
||||
set => m_Loc = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Loc.m_X;
|
||||
set => m_Loc.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Loc.m_Y;
|
||||
set => m_Loc.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Loc.m_Z;
|
||||
set => m_Loc.m_Z = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Map Map
|
||||
{
|
||||
get => m_Map;
|
||||
set => m_Map = value;
|
||||
}
|
||||
|
||||
public WorldLocation(IEntity e) : this(e.Location.X, e.Location.Y, e.Location.Z, e.Map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(int x, int y, Map map) : this(x, y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(int x, int y, int z, Map map)
|
||||
{
|
||||
m_Loc.m_X = x;
|
||||
m_Loc.m_Y = y;
|
||||
m_Loc.m_Z = z;
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"({m_Loc.m_X}, {m_Loc.m_Y}, {m_Loc.m_Z}, {m_Map?.ToString() ?? "(-null-)"})";
|
||||
|
||||
public bool Equals(WorldLocation other) =>
|
||||
m_Loc.Equals(other.m_Loc) && m_Map.MapID == other.m_Map.MapID;
|
||||
|
||||
public bool Equals(IEntity other) =>
|
||||
!ReferenceEquals(other, null) && m_Loc == other.Location &&
|
||||
m_Map.MapID == other.Map.MapID;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is WorldLocation other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_Loc, m_Map);
|
||||
|
||||
public int CompareTo(WorldLocation other)
|
||||
{
|
||||
var locComparison = m_Loc.CompareTo(other.m_Loc);
|
||||
if (locComparison != 0) return locComparison;
|
||||
return Comparer<Map>.Default.Compare(m_Map, other.m_Map);
|
||||
}
|
||||
|
||||
public static implicit operator Point3D(WorldLocation worldLocation) => worldLocation.Location;
|
||||
|
||||
public static bool operator ==(WorldLocation l, WorldLocation r) =>
|
||||
l.m_Loc == r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator ==(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc == r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, WorldLocation r) => l.m_Loc != r.m_Loc && l.m_Map != r.m_Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc != r.Location && l.m_Map != r.Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, WorldLocation r) => l.m_Loc > r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc > r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, WorldLocation r) => l.m_Loc < r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc < r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, WorldLocation r) => l.m_Loc >= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc >= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <=(WorldLocation l, WorldLocation r) => l.m_Loc <= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator <=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc <= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static WorldLocation Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out int z);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
var map = Map.Parse(value.Substring(start + 1, end - (start + 1)).Trim());
|
||||
|
||||
return new WorldLocation(x, y, z, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocation.cs - Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[Parsable]
|
||||
public struct WorldLocation
|
||||
: IPoint3D, IComparable<WorldLocation>, IEquatable<object>, IEquatable<WorldLocation>, IEquatable<IEntity>
|
||||
{
|
||||
internal Point3D m_Loc;
|
||||
internal Map m_Map;
|
||||
|
||||
public static readonly WorldLocation Zero = new WorldLocation(0, 0, 0, Map.Internal);
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Point3D Location
|
||||
{
|
||||
get => m_Loc;
|
||||
set => m_Loc = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int X
|
||||
{
|
||||
get => m_Loc.m_X;
|
||||
set => m_Loc.m_X = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Y
|
||||
{
|
||||
get => m_Loc.m_Y;
|
||||
set => m_Loc.m_Y = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public int Z
|
||||
{
|
||||
get => m_Loc.m_Z;
|
||||
set => m_Loc.m_Z = value;
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.Counselor)]
|
||||
public Map Map
|
||||
{
|
||||
get => m_Map;
|
||||
set => m_Map = value;
|
||||
}
|
||||
|
||||
public WorldLocation(IEntity e) : this(e.Location.X, e.Location.Y, e.Location.Z, e.Map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(int x, int y, Map map) : this(x, y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
|
||||
public WorldLocation(int x, int y, int z, Map map)
|
||||
{
|
||||
m_Loc.m_X = x;
|
||||
m_Loc.m_Y = y;
|
||||
m_Loc.m_Z = z;
|
||||
m_Map = map;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
$"({m_Loc.m_X}, {m_Loc.m_Y}, {m_Loc.m_Z}, {m_Map?.ToString() ?? "(-null-)"})";
|
||||
|
||||
public bool Equals(WorldLocation other) =>
|
||||
m_Loc.Equals(other.m_Loc) && m_Map.MapID == other.m_Map.MapID;
|
||||
|
||||
public bool Equals(IEntity other) =>
|
||||
!ReferenceEquals(other, null) && m_Loc == other.Location &&
|
||||
m_Map.MapID == other.Map.MapID;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is WorldLocation other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(m_Loc, m_Map);
|
||||
|
||||
public int CompareTo(WorldLocation other)
|
||||
{
|
||||
var locComparison = m_Loc.CompareTo(other.m_Loc);
|
||||
if (locComparison != 0) return locComparison;
|
||||
return Comparer<Map>.Default.Compare(m_Map, other.m_Map);
|
||||
}
|
||||
|
||||
public static implicit operator Point3D(WorldLocation worldLocation) => worldLocation.Location;
|
||||
|
||||
public static bool operator ==(WorldLocation l, WorldLocation r) =>
|
||||
l.m_Loc == r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator ==(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc == r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, WorldLocation r) => l.m_Loc != r.m_Loc && l.m_Map != r.m_Map;
|
||||
|
||||
public static bool operator !=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc != r.Location && l.m_Map != r.Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, WorldLocation r) => l.m_Loc > r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc > r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, WorldLocation r) => l.m_Loc < r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator <(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc < r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, WorldLocation r) => l.m_Loc >= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator >=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc >= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static bool operator <=(WorldLocation l, WorldLocation r) => l.m_Loc <= r.m_Loc && l.m_Map == r.m_Map;
|
||||
|
||||
public static bool operator <=(WorldLocation l, IEntity r) =>
|
||||
!ReferenceEquals(r, null) && l.m_Loc <= r.Location && l.m_Map == r.Map;
|
||||
|
||||
public static WorldLocation Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var y);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var z);
|
||||
|
||||
start = end;
|
||||
end = value.IndexOf(')', start + 1);
|
||||
|
||||
var map = Map.Parse(value.Substring(start + 1, end - (start + 1)).Trim());
|
||||
|
||||
return new WorldLocation(x, y, z, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue