fix: Cleanup IPoint3D calls (#704)
This commit is contained in:
parent
788b04b958
commit
3293ffcf06
33 changed files with 158 additions and 264 deletions
|
|
@ -21,12 +21,6 @@ namespace Server
|
|||
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(Point2D start, Point2D end)
|
||||
{
|
||||
m_Start = start;
|
||||
|
|
@ -141,7 +135,8 @@ namespace Server
|
|||
public readonly 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 readonly bool Contains(IPoint2D p) => m_Start <= p && m_End > p;
|
||||
public readonly bool Contains(int x, int y) =>
|
||||
m_Start.m_X <= x && m_Start.m_Y <= y && m_End.m_X > x && m_End.m_Y > y;
|
||||
|
||||
public override string ToString() => $"({X}, {Y})+({Width}, {Height})";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,18 @@ namespace Server
|
|||
&& p.m_Z >= m_Start.m_Z
|
||||
&& p.m_Z < m_End.m_Z;
|
||||
|
||||
public bool Contains(Point2D 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;
|
||||
|
||||
public bool Contains(IPoint2D 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;
|
||||
|
||||
public bool Contains(IPoint3D p) =>
|
||||
p.X >= m_Start.m_X
|
||||
&& p.X < m_End.m_X
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
public WorldLocation(Point2D p, Map map) : this(p.X, p.Y, 0, map)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
public WorldLocation(IPoint3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
public WorldLocation(Point3D p, Map map) : this(p.X, p.Y, p.Z, map)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ namespace Server
|
|||
|
||||
bool InRange(Point3D p, int range);
|
||||
|
||||
bool InRange(IPoint2D p, int range);
|
||||
|
||||
void RemoveItem(Item item);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1606,23 +1606,9 @@ namespace Server
|
|||
set => Location = new Point3D(m_Location.m_X, m_Location.m_Y, value);
|
||||
}
|
||||
|
||||
public virtual bool InRange(Point2D p, int range) =>
|
||||
p.m_X >= Location.m_X - range
|
||||
&& p.m_X <= Location.m_X + range
|
||||
&& p.m_Y >= Location.m_Y - range
|
||||
&& p.m_Y <= Location.m_Y + range;
|
||||
public virtual bool InRange(Point2D p, int range) => Utility.InRange(p.X, p.Y, X, Y, range);
|
||||
|
||||
public virtual bool InRange(Point3D p, int range) =>
|
||||
p.m_X >= Location.m_X - range
|
||||
&& p.m_X <= Location.m_X + range
|
||||
&& p.m_Y >= Location.m_Y - range
|
||||
&& p.m_Y <= Location.m_Y + range;
|
||||
|
||||
public virtual bool InRange(IPoint2D p, int range) =>
|
||||
p.X >= Location.m_X - range
|
||||
&& p.X <= Location.m_X + range
|
||||
&& p.Y >= Location.m_Y - range
|
||||
&& p.Y <= Location.m_Y + range;
|
||||
public virtual bool InRange(Point3D p, int range) => Utility.InRange(p.X, p.Y, X, Y, range);
|
||||
|
||||
public ExpandFlag GetExpandFlags()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Server
|
|||
|
||||
public static IEnumerable<NetState> SelectClients(Sector s, Rectangle2D bounds)
|
||||
{
|
||||
return s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile));
|
||||
return s.Clients.Where(o => o?.Mobile?.Deleted == false && bounds.Contains(o.Mobile.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<IEntity> SelectEntities(Sector s, Rectangle2D bounds) =>
|
||||
|
|
@ -73,18 +73,18 @@ namespace Server
|
|||
eable = eable.Union(s.Items.Where(o => o?.Deleted == false && o.Parent == null));
|
||||
}
|
||||
|
||||
return eable.Where(bounds.Contains);
|
||||
return eable.Where(o => bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SelectMobiles<T>(Sector s, Rectangle2D bounds) where T : Mobile
|
||||
{
|
||||
return s.Mobiles.OfType<T>().Where(o => !o.Deleted && bounds.Contains(o));
|
||||
return s.Mobiles.OfType<T>().Where(o => !o.Deleted && bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<T> SelectItems<T>(Sector s, Rectangle2D bounds) where T : Item
|
||||
{
|
||||
return s.Items.OfType<T>()
|
||||
.Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o));
|
||||
.Where(o => o.Deleted == false && o.Parent == null && bounds.Contains(o.Location));
|
||||
}
|
||||
|
||||
public static IEnumerable<BaseMulti> SelectMultis(Sector s, Rectangle2D bounds)
|
||||
|
|
@ -806,7 +806,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnClientChange(oldState, newState);
|
||||
GetSector(m.Location).OnClientChange(oldState, newState);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnEnter(m);
|
||||
GetSector(m.Location).OnEnter(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -825,7 +825,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
GetSector(item).OnEnter(item);
|
||||
GetSector(item.Location).OnEnter(item);
|
||||
|
||||
if (item is BaseMulti m)
|
||||
{
|
||||
|
|
@ -842,7 +842,7 @@ namespace Server
|
|||
{
|
||||
if (this != Internal)
|
||||
{
|
||||
GetSector(m).OnLeave(m);
|
||||
GetSector(m.Location).OnLeave(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
GetSector(item).OnLeave(item);
|
||||
GetSector(item.Location).OnLeave(item);
|
||||
|
||||
if (item is BaseMulti m)
|
||||
{
|
||||
|
|
@ -1192,7 +1192,7 @@ namespace Server
|
|||
|
||||
public Sector GetSector(Point2D p) => InternalGetSector(p.m_X >> SectorShift, p.m_Y >> SectorShift);
|
||||
|
||||
public Sector GetSector(IPoint2D p) => InternalGetSector(p.X >> SectorShift, p.Y >> SectorShift);
|
||||
// public Sector GetSector(IPoint2D p) => InternalGetSector(p.X >> SectorShift, p.Y >> SectorShift);
|
||||
|
||||
public Sector GetSector(int x, int y) => InternalGetSector(x >> SectorShift, y >> SectorShift);
|
||||
|
||||
|
|
|
|||
|
|
@ -1119,8 +1119,7 @@ namespace Server
|
|||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Container Corpse { get; set; }
|
||||
|
||||
public static char[] GhostChars { get; set; } = { 'o', 'O' };
|
||||
|
||||
public static char[] GhostChars { get; set; }
|
||||
public static bool NoSpeechLOS { get; set; }
|
||||
|
||||
public static TimeSpan AutoManifestTimeout { get; set; } = TimeSpan.FromSeconds(5.0);
|
||||
|
|
@ -2108,7 +2107,6 @@ namespace Server
|
|||
if (Stam < StamMax)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else if (Stam > StamMax)
|
||||
|
|
@ -2167,7 +2165,6 @@ namespace Server
|
|||
if (Mana < ManaMax)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else if (Mana > ManaMax)
|
||||
|
|
@ -2234,17 +2231,14 @@ namespace Server
|
|||
DamageEntries.Clear(); // reset damage entries on full HP
|
||||
}
|
||||
}
|
||||
else if (CanRegenHits)
|
||||
{
|
||||
m_HitsTimer ??= new HitsTimer(this);
|
||||
m_HitsTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenHits)
|
||||
{
|
||||
m_HitsTimer ??= new HitsTimer(this);
|
||||
m_HitsTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_HitsTimer?.Stop();
|
||||
}
|
||||
m_HitsTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Hits != value)
|
||||
|
|
@ -2279,22 +2273,14 @@ namespace Server
|
|||
|
||||
value = Math.Clamp(value, 0, StamMax);
|
||||
|
||||
if (value == StamMax)
|
||||
if (CanRegenStam && value < StamMax)
|
||||
{
|
||||
m_StamTimer?.Stop();
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenStam)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StamTimer?.Stop();
|
||||
}
|
||||
m_StamTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Stam != value)
|
||||
|
|
@ -2342,18 +2328,14 @@ namespace Server
|
|||
SendLocalizedMessage(501846); // You are at peace.
|
||||
}
|
||||
}
|
||||
else if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ManaTimer?.Stop();
|
||||
}
|
||||
m_ManaTimer?.Stop();
|
||||
}
|
||||
|
||||
if (m_Mana != value)
|
||||
|
|
@ -3874,7 +3856,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(this, m) && CanSee(m) && InLOS(m);
|
||||
public virtual bool CheckAttack(Mobile m) => Utility.InUpdateRange(Location, m.Location) && CanSee(m) && InLOS(m);
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Virtual event invoked after the <see cref="Combatant" /> property has changed.
|
||||
|
|
@ -5041,7 +5023,7 @@ namespace Server
|
|||
var root = item.RootParent;
|
||||
var okay = false;
|
||||
|
||||
if (!Utility.InUpdateRange(this, item.GetWorldLocation()))
|
||||
if (!Utility.InUpdateRange(Location, item.GetWorldLocation()))
|
||||
{
|
||||
item.OnDoubleClickOutOfRange(this);
|
||||
}
|
||||
|
|
@ -5111,7 +5093,7 @@ namespace Server
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Utility.InUpdateRange(this, m))
|
||||
if (!Utility.InUpdateRange(Location, m.Location))
|
||||
{
|
||||
m.OnDoubleClickOutOfRange(this);
|
||||
}
|
||||
|
|
@ -5525,7 +5507,7 @@ namespace Server
|
|||
using var sb = new ValueStringBuilder(stackalloc char[Math.Min(text.Length, 256)]);
|
||||
for (var i = 0; i < text.Length; ++i)
|
||||
{
|
||||
sb.Append(text[i] != ' ' ? GhostChars.RandomElement() : ' ');
|
||||
sb.Append(text[i] != ' ' ? (GhostChars ?? DefaultGhostChars).RandomElement() : ' ');
|
||||
}
|
||||
|
||||
text = sb.ToString();
|
||||
|
|
@ -6586,7 +6568,6 @@ namespace Server
|
|||
if (CanRegenStam)
|
||||
{
|
||||
m_StamTimer ??= new StamTimer(this);
|
||||
|
||||
m_StamTimer.Start();
|
||||
}
|
||||
else
|
||||
|
|
@ -6604,7 +6585,6 @@ namespace Server
|
|||
if (CanRegenMana)
|
||||
{
|
||||
m_ManaTimer ??= new ManaTimer(this);
|
||||
|
||||
m_ManaTimer.Start();
|
||||
}
|
||||
else
|
||||
|
|
@ -7986,7 +7966,7 @@ namespace Server
|
|||
/// <param name="from"></param>
|
||||
public virtual void OnStatsQuery(Mobile from)
|
||||
{
|
||||
if (from.Map == Map && Utility.InUpdateRange(this, from) && from.CanSee(this))
|
||||
if (from.Map == Map && Utility.InUpdateRange(Location, from.Location) && from.CanSee(this))
|
||||
{
|
||||
from.m_NetState.SendMobileStatus(from, this);
|
||||
}
|
||||
|
|
@ -8156,6 +8136,8 @@ namespace Server
|
|||
|
||||
public static TimeSpan GetManaRegenRate(Mobile m) => ManaRegenRateHandler?.Invoke(m) ?? DefaultManaRate;
|
||||
|
||||
public static char[] DefaultGhostChars = { 'o', 'O' };
|
||||
|
||||
public Prompt BeginPrompt(PromptCallback callback, PromptCallback cancelCallback) =>
|
||||
Prompt = new SimplePrompt(callback, cancelCallback);
|
||||
|
||||
|
|
@ -9309,11 +9291,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public ManaTimer(Mobile m)
|
||||
: base(GetManaRegenRate(m), GetManaRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public ManaTimer(Mobile m) : base(GetManaRegenRate(m), GetManaRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
@ -9330,11 +9308,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public HitsTimer(Mobile m)
|
||||
: base(GetHitsRegenRate(m), GetHitsRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public HitsTimer(Mobile m) : base(GetHitsRegenRate(m), GetHitsRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
@ -9351,11 +9325,7 @@ namespace Server
|
|||
{
|
||||
private readonly Mobile m_Owner;
|
||||
|
||||
public StamTimer(Mobile m)
|
||||
: base(GetStamRegenRate(m), GetStamRegenRate(m))
|
||||
{
|
||||
m_Owner = m;
|
||||
}
|
||||
public StamTimer(Mobile m) : base(GetStamRegenRate(m), GetStamRegenRate(m)) => m_Owner = m;
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
if (SingleClickProps)
|
||||
{
|
||||
|
|
@ -173,7 +173,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
m.SendPropertiesTo(from);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(s);
|
||||
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m))
|
||||
if (m != null && from.CanSee(m) && Utility.InUpdateRange(from.Location, m.Location))
|
||||
{
|
||||
m.SendPropertiesTo(from);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace Server.Network
|
|||
{
|
||||
var m = World.FindMobile(reader.ReadUInt32());
|
||||
|
||||
if (m != null && Utility.InUpdateRange(state.Mobile, m) && state.Mobile.CanSee(m))
|
||||
if (m != null && Utility.InUpdateRange(state.Mobile.Location, m.Location) && state.Mobile.CanSee(m))
|
||||
{
|
||||
state.SendMobileName(m);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Server.Network
|
|||
|
||||
var flag = reader.ReadByte();
|
||||
|
||||
if (!vendor.Deleted && Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10) && flag == 0x02)
|
||||
if (!vendor.Deleted && Utility.InRange(vendor.Location, state.Mobile.Location, 10) && flag == 0x02)
|
||||
{
|
||||
var msgSize = packetLength - 8; // Remaining bytes
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
|
||||
if (vendor.Deleted || !Utility.InRange(vendor.Location, state.Mobile.Location, 10))
|
||||
{
|
||||
state.SendEndVendorSell(vendor.Serial);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Collections;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -141,11 +141,15 @@ namespace Server
|
|||
{
|
||||
if (m_Mobiles != null)
|
||||
{
|
||||
var sandbox = new List<Mobile>(m_Mobiles);
|
||||
|
||||
foreach (var mob in sandbox)
|
||||
using var queue = PooledRefQueue<Mobile>.Create(m_Mobiles.Count);
|
||||
foreach (var mob in m_Mobiles)
|
||||
{
|
||||
mob.UpdateRegion();
|
||||
queue.Enqueue(mob);
|
||||
}
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
queue.Dequeue().UpdateRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +166,7 @@ namespace Server
|
|||
|
||||
public void Activate()
|
||||
{
|
||||
if (!Active && Owner != Map.Internal)
|
||||
if (!Active)
|
||||
{
|
||||
if (m_Items != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ using System.Collections.Generic;
|
|||
#endif
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
|
|
|
|||
|
|
@ -571,10 +571,14 @@ namespace Server
|
|||
|
||||
public static bool InsensitiveStartsWith(string first, string second) => first.InsensitiveStartsWith(second);
|
||||
|
||||
public static Direction GetDirection(IPoint2D from, IPoint2D to)
|
||||
public static Direction GetDirection(Point3D from, Point3D to) => GetDirection(from.X, from.Y, to.X, to.Y);
|
||||
|
||||
public static Direction GetDirection(Point2D from, Point2D to) => GetDirection(from.X, from.Y, to.X, to.Y);
|
||||
|
||||
public static Direction GetDirection(int fromX, int fromY, int toX, int toY)
|
||||
{
|
||||
var dx = to.X - from.X;
|
||||
var dy = to.Y - from.Y;
|
||||
var dx = toX - fromX;
|
||||
var dy = toY - fromY;
|
||||
|
||||
var adx = Abs(dx);
|
||||
var ady = Abs(dy);
|
||||
|
|
@ -615,32 +619,20 @@ namespace Server
|
|||
{
|
||||
if (bottom.m_X < top.m_X)
|
||||
{
|
||||
var swap = top.m_X;
|
||||
top.m_X = bottom.m_X;
|
||||
bottom.m_X = swap;
|
||||
(top.m_X, bottom.m_X) = (bottom.m_X, top.m_X);
|
||||
}
|
||||
|
||||
if (bottom.m_Y < top.m_Y)
|
||||
{
|
||||
var swap = top.m_Y;
|
||||
top.m_Y = bottom.m_Y;
|
||||
bottom.m_Y = swap;
|
||||
(top.m_Y, bottom.m_Y) = (bottom.m_Y, top.m_Y);
|
||||
}
|
||||
|
||||
if (bottom.m_Z < top.m_Z)
|
||||
{
|
||||
var swap = top.m_Z;
|
||||
top.m_Z = bottom.m_Z;
|
||||
bottom.m_Z = swap;
|
||||
(top.m_Z, bottom.m_Z) = (bottom.m_Z, top.m_Z);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RangeCheck(IPoint2D p1, IPoint2D p2, int range) =>
|
||||
p1.X >= p2.X - range
|
||||
&& p1.X <= p2.X + range
|
||||
&& p1.Y >= p2.Y - range
|
||||
&& p2.Y <= p2.Y + range;
|
||||
|
||||
public static void FormatBuffer(TextWriter output, Stream input, int length)
|
||||
{
|
||||
output.WriteLine(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
|
||||
|
|
@ -874,9 +866,7 @@ namespace Server
|
|||
{
|
||||
if (bound1 > bound2)
|
||||
{
|
||||
var i = bound1;
|
||||
bound1 = bound2;
|
||||
bound2 = i;
|
||||
(bound1, bound2) = (bound2, bound1);
|
||||
}
|
||||
|
||||
return num < bound2 + allowance && num > bound1 - allowance;
|
||||
|
|
@ -1063,29 +1053,26 @@ namespace Server
|
|||
|
||||
public static string GetText(XmlElement node, string defaultValue) => node?.InnerText ?? defaultValue;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(int p1X, int p1Y, int p2X, int p2Y, int range) =>
|
||||
p1X >= p2X - range
|
||||
&& p1X <= p2X + range
|
||||
&& p1Y >= p2Y - range
|
||||
&& p1Y <= p2Y + range;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(Point2D p1, Point2D p2, int range) =>
|
||||
InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InUpdateRange(Point2D p1, Point2D p2) => InRange(p1, p2, 18);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InRange(Point3D p1, Point3D p2, int range) =>
|
||||
p1.m_X >= p2.m_X - range
|
||||
&& p1.m_X <= p2.m_X + range
|
||||
&& p1.m_Y >= p2.m_Y - range
|
||||
&& p1.m_Y <= p2.m_Y + range;
|
||||
InRange(p1.m_X, p1.m_Y, p2.m_X, p2.m_Y, range);
|
||||
|
||||
public static bool InUpdateRange(Point3D p1, Point3D p2) =>
|
||||
p1.m_X >= p2.m_X - 18
|
||||
&& p1.m_X <= p2.m_X + 18
|
||||
&& p1.m_Y >= p2.m_Y - 18
|
||||
&& p1.m_Y <= p2.m_Y + 18;
|
||||
|
||||
public static bool InUpdateRange(Point2D p1, Point2D p2) =>
|
||||
p1.m_X >= p2.m_X - 18
|
||||
&& p1.m_X <= p2.m_X + 18
|
||||
&& p1.m_Y >= p2.m_Y - 18
|
||||
&& p1.m_Y <= p2.m_Y + 18;
|
||||
|
||||
public static bool InUpdateRange(IPoint2D p1, IPoint2D p2) =>
|
||||
p1.X >= p2.X - 18
|
||||
&& p1.X <= p2.X + 18
|
||||
&& p1.Y >= p2.Y - 18
|
||||
&& p1.Y <= p2.Y + 18;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, 18);
|
||||
|
||||
// 4d6+8 would be: Utility.Dice( 4, 6, 8 )
|
||||
public static int Dice(uint amount, uint sides, int bonus)
|
||||
|
|
@ -1106,9 +1093,7 @@ namespace Server
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var r = RandomMinMax(i, count - 1);
|
||||
var swap = list[r];
|
||||
list[r] = list[i];
|
||||
list[i] = swap;
|
||||
(list[r], list[i]) = (list[i], list[r]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1118,9 +1103,7 @@ namespace Server
|
|||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var r = RandomMinMax(i, count - 1);
|
||||
var swap = list[r];
|
||||
list[r] = list[i];
|
||||
list[i] = swap;
|
||||
(list[r], list[i]) = (list[i], list[r]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1208,9 +1191,7 @@ namespace Server
|
|||
{
|
||||
if (min > max)
|
||||
{
|
||||
var copy = min;
|
||||
min = max;
|
||||
max = copy;
|
||||
(min, max) = (max, min);
|
||||
}
|
||||
else if (min == max)
|
||||
{
|
||||
|
|
@ -1225,9 +1206,7 @@ namespace Server
|
|||
{
|
||||
if (min > max)
|
||||
{
|
||||
var copy = min;
|
||||
min = max;
|
||||
max = copy;
|
||||
(min, max) = (max, min);
|
||||
}
|
||||
else if (min == max)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue