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;
}
[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)
{
m_X = x;
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(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)
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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 start = Map.Bound(new Point2D(rect.Start.X, rect.Start.Y));
var end = Map.Bound(new Point2D(rect.End.X, rect.End.Y));
var start = Map.Bound(new Point2D(rect.Start));
var end = Map.Bound(new Point2D(rect.End));
var startSector = Map.GetSector(start);
var endSector = Map.GetSector(end);

View file

@ -115,7 +115,7 @@ namespace Server.Gumps
{
case 1: // Current location
{
toSet = new Point2D(m_Mobile.Location.X, m_Mobile.Location.Y);
toSet = new Point2D(m_Mobile.Location);
shouldSet = true;
shouldSend = true;
@ -198,7 +198,7 @@ namespace Server.Gumps
{
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());
m_Property.SetValue(m_Object, p, null);
m_PropertiesGump.OnValueChanged(m_Object, m_Property);

View file

@ -125,35 +125,32 @@ namespace Server.Items
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;
var max = m_Creature.MinTameSkill + 30 + Utility.Random(10);
return;
}
if (max <= from.Skills.Herding.Value)
{
m_Creature.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
502471, // That wasn't even challenging.
from.NetState
);
}
var min = m_Creature.MinTameSkill - 30;
var max = m_Creature.MinTameSkill + 30 + Utility.Random(10);
if (from.CheckTargetSkill(SkillName.Herding, m_Creature, min, max))
{
if (p != from)
{
p = new Point2D(p.X, p.Y);
}
if (max <= from.Skills.Herding.Value)
{
m_Creature.PrivateOverheadMessage(
MessageType.Regular,
0x3B2,
502471, // That wasn't even challenging.
from.NetState
);
}
m_Creature.TargetLocation = p;
from.SendLocalizedMessage(502479); // The animal walks where it was instructed to.
}
else
{
from.SendLocalizedMessage(502472); // You don't seem to be able to persuade that to move.
}
if (from.CheckTargetSkill(SkillName.Herding, m_Creature, min, max))
{
m_Creature.TargetLocation = targ != from ? new Point2D(p) : p;
from.SendLocalizedMessage(502479); // The animal walks where it was instructed to.
}
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);
if (!(distance is < 1 or > 15))
if (distance is not (< 1 or > 15))
{
DoMove(m_Mobile.GetDirectionTo(target));
return true;

View file

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