fix: Cleans up core code (#1187)
**Only one functional change** * Fixes a bug in LogFactory where `Warning` is being logged as `Information` Non-functional changes: * Updates/Fixes copyright headers * Removes namespace scopes for core files. View with [whitespace off](https://github.com/modernuo/ModernUO/pull/1187/files?w=1).
This commit is contained in:
parent
0138d40bda
commit
f268d5d4e2
262 changed files with 28527 additions and 28646 deletions
|
|
@ -3,205 +3,204 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Server
|
||||
namespace Server;
|
||||
|
||||
public class AggressorInfo
|
||||
{
|
||||
public class AggressorInfo
|
||||
private static readonly Queue<AggressorInfo> m_Pool = new();
|
||||
private Mobile m_Attacker, m_Defender;
|
||||
private bool m_CanReportMurder;
|
||||
private bool m_CriminalAggression;
|
||||
private DateTime m_LastCombatTime;
|
||||
|
||||
private bool m_Queued;
|
||||
private bool m_Reported;
|
||||
|
||||
private AggressorInfo(Mobile attacker, Mobile defender, bool criminal)
|
||||
{
|
||||
private static readonly Queue<AggressorInfo> m_Pool = new();
|
||||
private Mobile m_Attacker, m_Defender;
|
||||
private bool m_CanReportMurder;
|
||||
private bool m_CriminalAggression;
|
||||
private DateTime m_LastCombatTime;
|
||||
m_Attacker = attacker;
|
||||
m_Defender = defender;
|
||||
|
||||
private bool m_Queued;
|
||||
private bool m_Reported;
|
||||
m_CanReportMurder = criminal;
|
||||
m_CriminalAggression = criminal;
|
||||
|
||||
private AggressorInfo(Mobile attacker, Mobile defender, bool criminal)
|
||||
{
|
||||
m_Attacker = attacker;
|
||||
m_Defender = defender;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
m_CanReportMurder = criminal;
|
||||
m_CriminalAggression = criminal;
|
||||
public static TimeSpan ExpireDelay { get; set; } = TimeSpan.FromMinutes(2.0);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public static TimeSpan ExpireDelay { get; set; } = TimeSpan.FromMinutes(2.0);
|
||||
|
||||
public bool Expired
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Attacker.Deleted || m_Defender.Deleted || Core.Now >= m_LastCombatTime + ExpireDelay;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CriminalAggression
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_CriminalAggression;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_CriminalAggression = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Attacker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Attacker;
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Defender
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Defender;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime LastCombatTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_LastCombatTime;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Reported
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Reported;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_Reported = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanReportMurder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_CanReportMurder;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_CanReportMurder = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static AggressorInfo Create(Mobile attacker, Mobile defender, bool criminal)
|
||||
{
|
||||
AggressorInfo info;
|
||||
|
||||
if (m_Pool.Count > 0)
|
||||
{
|
||||
info = m_Pool.Dequeue();
|
||||
|
||||
info.m_Attacker = attacker;
|
||||
info.m_Defender = defender;
|
||||
|
||||
info.m_CanReportMurder = criminal;
|
||||
info.m_CriminalAggression = criminal;
|
||||
|
||||
info.m_Queued = false;
|
||||
|
||||
info.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
info = new AggressorInfo(attacker, defender, criminal);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Queued = true;
|
||||
m_Pool.Enqueue(this);
|
||||
}
|
||||
|
||||
public static void DumpAccess()
|
||||
{
|
||||
using var op = new StreamWriter("warnings.log", true);
|
||||
op.WriteLine("Warning: Access to queued AggressorInfo:");
|
||||
op.WriteLine(new StackTrace());
|
||||
op.WriteLine();
|
||||
op.WriteLine();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
public bool Expired
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_LastCombatTime = Core.Now;
|
||||
m_Reported = false;
|
||||
return m_Attacker.Deleted || m_Defender.Deleted || Core.Now >= m_LastCombatTime + ExpireDelay;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CriminalAggression
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_CriminalAggression;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_CriminalAggression = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Attacker
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Attacker;
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile Defender
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Defender;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime LastCombatTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_LastCombatTime;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Reported
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_Reported;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_Reported = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanReportMurder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
return m_CanReportMurder;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_CanReportMurder = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static AggressorInfo Create(Mobile attacker, Mobile defender, bool criminal)
|
||||
{
|
||||
AggressorInfo info;
|
||||
|
||||
if (m_Pool.Count > 0)
|
||||
{
|
||||
info = m_Pool.Dequeue();
|
||||
|
||||
info.m_Attacker = attacker;
|
||||
info.m_Defender = defender;
|
||||
|
||||
info.m_CanReportMurder = criminal;
|
||||
info.m_CriminalAggression = criminal;
|
||||
|
||||
info.m_Queued = false;
|
||||
|
||||
info.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
info = new AggressorInfo(attacker, defender, criminal);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public void Free()
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_Queued = true;
|
||||
m_Pool.Enqueue(this);
|
||||
}
|
||||
|
||||
public static void DumpAccess()
|
||||
{
|
||||
using var op = new StreamWriter("warnings.log", true);
|
||||
op.WriteLine("Warning: Access to queued AggressorInfo:");
|
||||
op.WriteLine(new StackTrace());
|
||||
op.WriteLine();
|
||||
op.WriteLine();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (m_Queued)
|
||||
{
|
||||
DumpAccess();
|
||||
}
|
||||
|
||||
m_LastCombatTime = Core.Now;
|
||||
m_Reported = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,97 +1,96 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Server
|
||||
namespace Server;
|
||||
|
||||
public class BuyItemStateComparer : IComparer<BuyItemState>
|
||||
{
|
||||
public class BuyItemStateComparer : IComparer<BuyItemState>
|
||||
public int Compare(BuyItemState l, BuyItemState r)
|
||||
{
|
||||
public int Compare(BuyItemState l, BuyItemState r)
|
||||
if (l == null && r == null)
|
||||
{
|
||||
if (l == null && r == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (l == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (r == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return l.MySerial.CompareTo(r.MySerial);
|
||||
}
|
||||
}
|
||||
|
||||
public class BuyItemResponse
|
||||
{
|
||||
public BuyItemResponse(Serial serial, int amount)
|
||||
{
|
||||
Serial = serial;
|
||||
Amount = amount;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Serial Serial { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
}
|
||||
|
||||
public class SellItemResponse
|
||||
{
|
||||
public SellItemResponse(Item i, int amount)
|
||||
if (l == null)
|
||||
{
|
||||
Item = i;
|
||||
Amount = amount;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Item Item { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
}
|
||||
|
||||
public class SellItemState
|
||||
{
|
||||
public SellItemState(Item item, int price, string name)
|
||||
if (r == null)
|
||||
{
|
||||
Item = item;
|
||||
Price = price;
|
||||
Name = name;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Item Item { get; }
|
||||
|
||||
public int Price { get; }
|
||||
|
||||
public string Name { get; }
|
||||
}
|
||||
|
||||
public class BuyItemState
|
||||
{
|
||||
public BuyItemState(string name, Serial cont, Serial serial, int price, int amount, int itemID, int hue)
|
||||
{
|
||||
Description = name;
|
||||
ContainerSerial = cont;
|
||||
MySerial = serial;
|
||||
Price = price;
|
||||
Amount = amount;
|
||||
ItemID = itemID;
|
||||
Hue = hue;
|
||||
}
|
||||
|
||||
public int Price { get; }
|
||||
|
||||
public Serial MySerial { get; }
|
||||
|
||||
public Serial ContainerSerial { get; }
|
||||
|
||||
public int ItemID { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
|
||||
public int Hue { get; }
|
||||
|
||||
public string Description { get; }
|
||||
return l.MySerial.CompareTo(r.MySerial);
|
||||
}
|
||||
}
|
||||
|
||||
public class BuyItemResponse
|
||||
{
|
||||
public BuyItemResponse(Serial serial, int amount)
|
||||
{
|
||||
Serial = serial;
|
||||
Amount = amount;
|
||||
}
|
||||
|
||||
public Serial Serial { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
}
|
||||
|
||||
public class SellItemResponse
|
||||
{
|
||||
public SellItemResponse(Item i, int amount)
|
||||
{
|
||||
Item = i;
|
||||
Amount = amount;
|
||||
}
|
||||
|
||||
public Item Item { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
}
|
||||
|
||||
public class SellItemState
|
||||
{
|
||||
public SellItemState(Item item, int price, string name)
|
||||
{
|
||||
Item = item;
|
||||
Price = price;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Item Item { get; }
|
||||
|
||||
public int Price { get; }
|
||||
|
||||
public string Name { get; }
|
||||
}
|
||||
|
||||
public class BuyItemState
|
||||
{
|
||||
public BuyItemState(string name, Serial cont, Serial serial, int price, int amount, int itemID, int hue)
|
||||
{
|
||||
Description = name;
|
||||
ContainerSerial = cont;
|
||||
MySerial = serial;
|
||||
Price = price;
|
||||
Amount = amount;
|
||||
ItemID = itemID;
|
||||
Hue = hue;
|
||||
}
|
||||
|
||||
public int Price { get; }
|
||||
|
||||
public Serial MySerial { get; }
|
||||
|
||||
public Serial ContainerSerial { get; }
|
||||
|
||||
public int ItemID { get; }
|
||||
|
||||
public int Amount { get; }
|
||||
|
||||
public int Hue { get; }
|
||||
|
||||
public string Description { get; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IMount.cs *
|
||||
* *
|
||||
|
|
@ -13,16 +13,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
public interface IMount
|
||||
{
|
||||
Mobile Rider { get; set; }
|
||||
void OnRiderDamaged(int amount, Mobile from, bool willKill);
|
||||
}
|
||||
namespace Server.Mobiles;
|
||||
|
||||
public interface IMountItem
|
||||
{
|
||||
IMount Mount { get; }
|
||||
}
|
||||
public interface IMount
|
||||
{
|
||||
Mobile Rider { get; set; }
|
||||
void OnRiderDamaged(int amount, Mobile from, bool willKill);
|
||||
}
|
||||
|
||||
public interface IMountItem
|
||||
{
|
||||
IMount Mount { get; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IVendor.cs *
|
||||
* *
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Movement.cs *
|
||||
* *
|
||||
|
|
@ -13,95 +13,94 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
namespace Server.Movement
|
||||
namespace Server.Movement;
|
||||
|
||||
public static class Movement
|
||||
{
|
||||
public static class Movement
|
||||
// Movement implementation algorithm
|
||||
public static IMovementImpl Impl { get; set; }
|
||||
public static int WalkFootDelay { get; set; } = 400;
|
||||
public static int RunFootDelay { get; set; } = 200;
|
||||
public static int WalkMountDelay { get; set; } = 200;
|
||||
public static int RunMountDelay { get; set; } = 100;
|
||||
|
||||
public static bool EnableFastwalkPrevention { get; set; } = true;
|
||||
public static AccessLevel FastwalkExemptionLevel { get; set; } = AccessLevel.Counselor;
|
||||
|
||||
// If this is changed during runtime, then the steps array needs resizing.
|
||||
public static int MaxSteps { get; private set; } = 3;
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
// Movement implementation algorithm
|
||||
public static IMovementImpl Impl { get; set; }
|
||||
public static int WalkFootDelay { get; set; } = 400;
|
||||
public static int RunFootDelay { get; set; } = 200;
|
||||
public static int WalkMountDelay { get; set; } = 200;
|
||||
public static int RunMountDelay { get; set; } = 100;
|
||||
|
||||
public static bool EnableFastwalkPrevention { get; set; } = true;
|
||||
public static AccessLevel FastwalkExemptionLevel { get; set; } = AccessLevel.Counselor;
|
||||
|
||||
// If this is changed during runtime, then the steps array needs resizing.
|
||||
public static int MaxSteps { get; private set; } = 3;
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EnableFastwalkPrevention = ServerConfiguration.GetOrUpdateSetting("movement.enableFastWalkPrevention", EnableFastwalkPrevention);
|
||||
MaxSteps = ServerConfiguration.GetOrUpdateSetting("movement.maxSteps", MaxSteps);
|
||||
FastwalkExemptionLevel = ServerConfiguration.GetOrUpdateSetting("movement.fastwalkExemptionLevel", FastwalkExemptionLevel);
|
||||
WalkFootDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.walkFoot", WalkFootDelay);
|
||||
RunFootDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.runFoot", RunFootDelay);
|
||||
WalkMountDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.walkMount", WalkMountDelay);
|
||||
RunMountDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.runMount", RunMountDelay);
|
||||
}
|
||||
|
||||
public static bool CheckMovement(Mobile m, Direction d, out int newZ)
|
||||
{
|
||||
if (Impl != null)
|
||||
{
|
||||
return Impl.CheckMovement(m, d, out newZ);
|
||||
}
|
||||
|
||||
newZ = m.Z;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ)
|
||||
{
|
||||
if (Impl != null)
|
||||
{
|
||||
return Impl.CheckMovement(m, map, loc, d, out newZ);
|
||||
}
|
||||
|
||||
newZ = m.Z;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Offset(Direction d, ref int x, ref int y)
|
||||
{
|
||||
switch (d & Direction.Mask)
|
||||
{
|
||||
case Direction.North:
|
||||
--y;
|
||||
break;
|
||||
case Direction.South:
|
||||
++y;
|
||||
break;
|
||||
case Direction.West:
|
||||
--x;
|
||||
break;
|
||||
case Direction.East:
|
||||
++x;
|
||||
break;
|
||||
case Direction.Right:
|
||||
++x;
|
||||
--y;
|
||||
break;
|
||||
case Direction.Left:
|
||||
--x;
|
||||
++y;
|
||||
break;
|
||||
case Direction.Down:
|
||||
++x;
|
||||
++y;
|
||||
break;
|
||||
case Direction.Up:
|
||||
--x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EnableFastwalkPrevention = ServerConfiguration.GetOrUpdateSetting("movement.enableFastWalkPrevention", EnableFastwalkPrevention);
|
||||
MaxSteps = ServerConfiguration.GetOrUpdateSetting("movement.maxSteps", MaxSteps);
|
||||
FastwalkExemptionLevel = ServerConfiguration.GetOrUpdateSetting("movement.fastwalkExemptionLevel", FastwalkExemptionLevel);
|
||||
WalkFootDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.walkFoot", WalkFootDelay);
|
||||
RunFootDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.runFoot", RunFootDelay);
|
||||
WalkMountDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.walkMount", WalkMountDelay);
|
||||
RunMountDelay = ServerConfiguration.GetOrUpdateSetting("movement.delay.runMount", RunMountDelay);
|
||||
}
|
||||
|
||||
public interface IMovementImpl
|
||||
public static bool CheckMovement(Mobile m, Direction d, out int newZ)
|
||||
{
|
||||
bool CheckMovement(Mobile m, Direction d, out int newZ);
|
||||
bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ);
|
||||
if (Impl != null)
|
||||
{
|
||||
return Impl.CheckMovement(m, d, out newZ);
|
||||
}
|
||||
|
||||
newZ = m.Z;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ)
|
||||
{
|
||||
if (Impl != null)
|
||||
{
|
||||
return Impl.CheckMovement(m, map, loc, d, out newZ);
|
||||
}
|
||||
|
||||
newZ = m.Z;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Offset(Direction d, ref int x, ref int y)
|
||||
{
|
||||
switch (d & Direction.Mask)
|
||||
{
|
||||
case Direction.North:
|
||||
--y;
|
||||
break;
|
||||
case Direction.South:
|
||||
++y;
|
||||
break;
|
||||
case Direction.West:
|
||||
--x;
|
||||
break;
|
||||
case Direction.East:
|
||||
++x;
|
||||
break;
|
||||
case Direction.Right:
|
||||
++x;
|
||||
--y;
|
||||
break;
|
||||
case Direction.Left:
|
||||
--x;
|
||||
++y;
|
||||
break;
|
||||
case Direction.Down:
|
||||
++x;
|
||||
++y;
|
||||
break;
|
||||
case Direction.Up:
|
||||
--x;
|
||||
--y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMovementImpl
|
||||
{
|
||||
bool CheckMovement(Mobile m, Direction d, out int newZ);
|
||||
bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,32 @@
|
|||
namespace Server
|
||||
namespace Server;
|
||||
|
||||
public delegate int NotorietyHandler(Mobile source, Mobile target);
|
||||
|
||||
public static class Notoriety
|
||||
{
|
||||
public delegate int NotorietyHandler(Mobile source, Mobile target);
|
||||
public const int Innocent = 1;
|
||||
public const int Ally = 2;
|
||||
public const int CanBeAttacked = 3;
|
||||
public const int Criminal = 4;
|
||||
public const int Enemy = 5;
|
||||
public const int Murderer = 6;
|
||||
public const int Invulnerable = 7;
|
||||
|
||||
public static class Notoriety
|
||||
public static NotorietyHandler Handler { get; set; }
|
||||
|
||||
public static int[] Hues { get; set; } =
|
||||
{
|
||||
public const int Innocent = 1;
|
||||
public const int Ally = 2;
|
||||
public const int CanBeAttacked = 3;
|
||||
public const int Criminal = 4;
|
||||
public const int Enemy = 5;
|
||||
public const int Murderer = 6;
|
||||
public const int Invulnerable = 7;
|
||||
0x000,
|
||||
0x059,
|
||||
0x03F,
|
||||
0x3B2,
|
||||
0x3B2,
|
||||
0x090,
|
||||
0x022,
|
||||
0x035
|
||||
};
|
||||
|
||||
public static NotorietyHandler Handler { get; set; }
|
||||
public static int GetHue(int noto) => noto < 0 || noto >= Hues.Length ? 0 : Hues[noto];
|
||||
|
||||
public static int[] Hues { get; set; } =
|
||||
{
|
||||
0x000,
|
||||
0x059,
|
||||
0x03F,
|
||||
0x3B2,
|
||||
0x3B2,
|
||||
0x090,
|
||||
0x022,
|
||||
0x035
|
||||
};
|
||||
|
||||
public static int GetHue(int noto) => noto < 0 || noto >= Hues.Length ? 0 : Hues[noto];
|
||||
|
||||
public static int Compute(Mobile source, Mobile target) => Handler?.Invoke(source, target) ?? CanBeAttacked;
|
||||
}
|
||||
public static int Compute(Mobile source, Mobile target) => Handler?.Invoke(source, target) ?? CanBeAttacked;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SimplePrompt.cs *
|
||||
* *
|
||||
|
|
@ -15,77 +15,76 @@
|
|||
|
||||
using Server.Prompts;
|
||||
|
||||
namespace Server.Mobiles
|
||||
namespace Server.Mobiles;
|
||||
|
||||
public class SimplePrompt : Prompt
|
||||
{
|
||||
public class SimplePrompt : Prompt
|
||||
private readonly PromptCallback m_Callback;
|
||||
private readonly bool m_CallbackHandlesCancel;
|
||||
private readonly PromptCallback m_CancelCallback;
|
||||
|
||||
public SimplePrompt(PromptCallback callback, PromptCallback cancelCallback)
|
||||
{
|
||||
private readonly PromptCallback m_Callback;
|
||||
private readonly bool m_CallbackHandlesCancel;
|
||||
private readonly PromptCallback m_CancelCallback;
|
||||
|
||||
public SimplePrompt(PromptCallback callback, PromptCallback cancelCallback)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
}
|
||||
|
||||
public SimplePrompt(PromptCallback callback, bool callbackHandlesCancel = false)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CallbackHandlesCancel = callbackHandlesCancel;
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text);
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
if (m_CallbackHandlesCancel && m_Callback != null)
|
||||
{
|
||||
m_Callback(from, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CancelCallback?.Invoke(from, "");
|
||||
}
|
||||
}
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
}
|
||||
|
||||
public class SimpleStatePrompt<T> : Prompt
|
||||
public SimplePrompt(PromptCallback callback, bool callbackHandlesCancel = false)
|
||||
{
|
||||
private readonly PromptStateCallback<T> m_Callback;
|
||||
private readonly PromptStateCallback<T> m_CancelCallback;
|
||||
m_Callback = callback;
|
||||
m_CallbackHandlesCancel = callbackHandlesCancel;
|
||||
}
|
||||
|
||||
private readonly T m_State;
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text);
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, PromptStateCallback<T> cancelCallback, T state)
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
if (m_CallbackHandlesCancel && m_Callback != null)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
m_State = state;
|
||||
m_Callback(from, "");
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, bool callbackHandlesCancel, T state)
|
||||
else
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
m_CancelCallback = callbackHandlesCancel ? callback : null;
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, T state) : this(callback, false, state)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text, m_State);
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_CancelCallback?.Invoke(from, "", m_State);
|
||||
m_CancelCallback?.Invoke(from, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleStatePrompt<T> : Prompt
|
||||
{
|
||||
private readonly PromptStateCallback<T> m_Callback;
|
||||
private readonly PromptStateCallback<T> m_CancelCallback;
|
||||
|
||||
private readonly T m_State;
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, PromptStateCallback<T> cancelCallback, T state)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_CancelCallback = cancelCallback;
|
||||
m_State = state;
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, bool callbackHandlesCancel, T state)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
m_CancelCallback = callbackHandlesCancel ? callback : null;
|
||||
}
|
||||
|
||||
public SimpleStatePrompt(PromptStateCallback<T> callback, T state) : this(callback, false, state)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse(Mobile from, string text)
|
||||
{
|
||||
m_Callback?.Invoke(from, text, m_State);
|
||||
}
|
||||
|
||||
public override void OnCancel(Mobile from)
|
||||
{
|
||||
m_CancelCallback?.Invoke(from, "", m_State);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SimpleTarget.cs *
|
||||
* *
|
||||
|
|
@ -15,40 +15,39 @@
|
|||
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.Mobiles
|
||||
namespace Server.Mobiles;
|
||||
|
||||
public class SimpleTarget : Target
|
||||
{
|
||||
public class SimpleTarget : Target
|
||||
private readonly TargetCallback m_Callback;
|
||||
|
||||
public SimpleTarget(int range, TargetFlags flags, bool allowGround, TargetCallback callback)
|
||||
: base(range, allowGround, flags) =>
|
||||
m_Callback = callback;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
private readonly TargetCallback m_Callback;
|
||||
|
||||
public SimpleTarget(int range, TargetFlags flags, bool allowGround, TargetCallback callback)
|
||||
: base(range, allowGround, flags) =>
|
||||
m_Callback = callback;
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(from, targeted);
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleStateTarget<T> : Target
|
||||
{
|
||||
private readonly TargetStateCallback<T> m_Callback;
|
||||
private readonly T m_State;
|
||||
|
||||
public SimpleStateTarget(
|
||||
int range, TargetFlags flags, bool allowGround, TargetStateCallback<T> callback,
|
||||
T state
|
||||
)
|
||||
: base(range, allowGround, flags)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(from, targeted, m_State);
|
||||
}
|
||||
m_Callback?.Invoke(from, targeted);
|
||||
}
|
||||
}
|
||||
|
||||
public class SimpleStateTarget<T> : Target
|
||||
{
|
||||
private readonly TargetStateCallback<T> m_Callback;
|
||||
private readonly T m_State;
|
||||
|
||||
public SimpleStateTarget(
|
||||
int range, TargetFlags flags, bool allowGround, TargetStateCallback<T> callback,
|
||||
T state
|
||||
)
|
||||
: base(range, allowGround, flags)
|
||||
{
|
||||
m_Callback = callback;
|
||||
m_State = state;
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(from, targeted, m_State);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue