fix: Fixes Point2D ctor (#1340)

This commit is contained in:
Kamron Batman 2023-02-13 23:28:23 -08:00 • committed by GitHub
parent f24c6a08dd
commit 65c196a8ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 35 deletions

View file

@ -41,16 +41,27 @@ public struct Point2D
set => m_Y = value; set => m_Y = value;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point2D(IPoint2D p) : this(p.X, p.Y)
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point2D(Point3D p) : this(p.X, p.Y)
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point2D(Point2D p) : this(p.X, p.Y)
{
}
public Point2D(int x, int y) public Point2D(int x, int y)
{ {
m_X = x; m_X = x;
m_Y = y; m_Y = y;
} }
public Point2D(Point2D p) : this(p.X, p.Y)
{
}
public bool Equals(Point2D other) => m_X == other.m_X && m_Y == other.m_Y; public bool Equals(Point2D other) => m_X == other.m_X && m_Y == other.m_Y;
public bool Equals(IPoint2D other) => m_X == other?.X && m_Y == other.Y; public bool Equals(IPoint2D other) => m_X == other?.X && m_Y == other.Y;

View file

@ -54,10 +54,12 @@ public struct Point3D
{ {
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point3D(Point3D p) : this(p.X, p.Y, p.Z) public Point3D(Point3D p) : this(p.X, p.Y, p.Z)
{ {
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Point3D(Point2D p, int z) : this(p.X, p.Y, z) public Point3D(Point2D p, int z) : this(p.X, p.Y, z)
{ {
} }

View file

@ -336,8 +336,8 @@ public class Region : IComparable<Region>
{ {
var rect = Area[i]; var rect = Area[i];
var start = Map.Bound(new Point2D(rect.Start.X, rect.Start.Y)); var start = Map.Bound(new Point2D(rect.Start));
var end = Map.Bound(new Point2D(rect.End.X, rect.End.Y)); var end = Map.Bound(new Point2D(rect.End));
var startSector = Map.GetSector(start); var startSector = Map.GetSector(start);
var endSector = Map.GetSector(end); var endSector = Map.GetSector(end);

View file

@ -115,7 +115,7 @@ namespace Server.Gumps
{ {
case 1: // Current location case 1: // Current location
{ {
toSet = new Point2D(m_Mobile.Location.X, m_Mobile.Location.Y); toSet = new Point2D(m_Mobile.Location);
shouldSet = true; shouldSet = true;
shouldSend = true; shouldSend = true;
@ -198,7 +198,7 @@ namespace Server.Gumps
{ {
try try
{ {
var p = new Point2D(point3D.X, point3D.Y); var p = new Point2D(point3D);
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, p.ToString()); CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, p.ToString());
m_Property.SetValue(m_Object, p, null); m_Property.SetValue(m_Object, p, null);
m_PropertiesGump.OnValueChanged(m_Object, m_Property); m_PropertiesGump.OnValueChanged(m_Object, m_Property);

View file

@ -125,35 +125,32 @@ namespace Server.Items
protected override void OnTarget(Mobile from, object targ) protected override void OnTarget(Mobile from, object targ)
{ {
if (targ is IPoint2D p) if (targ is not IPoint2D p)
{ {
var min = m_Creature.MinTameSkill - 30; return;
var max = m_Creature.MinTameSkill + 30 + Utility.Random(10); }
if (max <= from.Skills.Herding.Value) var min = m_Creature.MinTameSkill - 30;
{ var max = m_Creature.MinTameSkill + 30 + Utility.Random(10);
m_Creature.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
502471, // That wasn't even challenging.
from.NetState
);
}
if (from.CheckTargetSkill(SkillName.Herding, m_Creature, min, max)) if (max <= from.Skills.Herding.Value)
{ {
if (p != from) m_Creature.PrivateOverheadMessage(
{ MessageType.Regular,
p = new Point2D(p.X, p.Y); 0x3B2,
} 502471, // That wasn't even challenging.
from.NetState
);
}
m_Creature.TargetLocation = p; if (from.CheckTargetSkill(SkillName.Herding, m_Creature, min, max))
from.SendLocalizedMessage(502479); // The animal walks where it was instructed to. {
} m_Creature.TargetLocation = targ != from ? new Point2D(p) : p;
else from.SendLocalizedMessage(502479); // The animal walks where it was instructed to.
{ }
from.SendLocalizedMessage(502472); // You don't seem to be able to persuade that to move. else
} {
from.SendLocalizedMessage(502472); // You don't seem to be able to persuade that to move.
} }
} }
} }

View file

@ -1352,7 +1352,7 @@ public abstract class BaseAI
var distance = m_Mobile.GetDistanceToSqrt(target); var distance = m_Mobile.GetDistanceToSqrt(target);
if (!(distance is < 1 or > 15)) if (distance is not (< 1 or > 15))
{ {
DoMove(m_Mobile.GetDirectionTo(target)); DoMove(m_Mobile.GetDirectionTo(target));
return true; return true;

View file

@ -79,7 +79,7 @@ namespace Server.SkillHandlers
{ {
m_Tracker = tracker; m_Tracker = tracker;
m_Target = target; m_Target = target;
m_Location = new Point2D(target.X, target.Y); m_Location = new Point2D(target);
m_Map = target.Map; m_Map = target.Map;
} }
} }