servuo/Server/Serial.cs
VitaNex 7851c5e88c + Removed most file header regions.
+ Add MONO to Makefile compile definitions.
+ Update Ultima SDK to support MONO compile definition.
+ Rename Properties Gump parent directory to prevent VS issues.
+ Console error messages will now use red instead of dark red font.
+ Add crash state handler function to Core.
+ AI optimizations and housekeeping.
+ Context Menu optimizations and housekeeping.
+ Add ability to drop throttled packets.
+ Add string parsing support to Rectangle3D.
+ Optimize guild messages and chat.
+ IAddon implements IChopable.
+ Add more flexibility for altering Mobile names.
+ Add ability to enable or disable OPL for individual mobiles.
+ Optimize damaging regions and ensure timers are removed properly.
+ Update Welcome Timer with more intuitive message groups.
+ Normalize all virtue related objects to the Server.Services.Virtues namespace.
+ Add ability for ISpawner to append OPL and Context Menus to their spawn.
+ Add EventSink events for obtaining items, equipping items, context menus, and world broadcasts.
+ Add ability to lock a creature's direction and movement regardless of AI manipulation.
+ Add ability to dynamically change a creature's approach range and wait state.
+ Add extended enumeration features for AOS attributes.
+ Add ability to control whether creatures have blood, and its color.
+ Expose corpse flag manipulation methods.
+ Add ability to prevent criminal action when looting a corpse.
+ Corpse will now be permanently tagged as murderer at time of death if owner is a murderer.
+ Add TextDefinition support for Commodity Deed descriptions.
+ House add-on and component optimizations and housekeeping.
+ Item light is no longer backed by the direction property.
+ ITool implements IEntity.
+ Prevent trading of Siege Bless items.
+ Guards are naturally be immune to guards.
+ Siege Shard initialization housekeeping.
+ Character Creation housekeeping.
+ Generic commands housekeeping.
+ Add Mark command for staff.
2018-07-19 22:12:52 +01:00

143 lines
No EOL
2.7 KiB
C#

#region References
using System;
#endregion
namespace Server
{
public struct Serial : IComparable, IComparable<Serial>
{
private readonly int m_Serial;
private static Serial m_LastMobile = Zero;
private static Serial m_LastItem = 0x40000000;
public static Serial LastMobile { get { return m_LastMobile; } }
public static Serial LastItem { get { return m_LastItem; } }
public static readonly Serial MinusOne = new Serial(-1);
public static readonly Serial Zero = new Serial(0);
public static Serial NewMobile
{
get
{
while (World.FindMobile(m_LastMobile = (m_LastMobile + 1)) != null)
{
;
}
return m_LastMobile;
}
}
public static Serial NewItem
{
get
{
while (World.FindItem(m_LastItem = (m_LastItem + 1)) != null)
{
;
}
return m_LastItem;
}
}
private Serial(int serial)
{
m_Serial = serial;
}
public int Value { get { return m_Serial; } }
public bool IsMobile { get { return (m_Serial > 0 && m_Serial < 0x40000000); } }
public bool IsItem { get { return (m_Serial >= 0x40000000 && m_Serial <= 0x7FFFFFFF); } }
public bool IsValid { get { return (m_Serial > 0); } }
public override int GetHashCode()
{
return m_Serial;
}
public int CompareTo(Serial other)
{
return m_Serial.CompareTo(other.m_Serial);
}
public int CompareTo(object other)
{
if (other is Serial)
{
return CompareTo((Serial)other);
}
else if (other == null)
{
return -1;
}
throw new ArgumentException();
}
public override bool Equals(object o)
{
if (o == null || !(o is Serial))
{
return false;
}
return ((Serial)o).m_Serial == m_Serial;
}
public static bool operator ==(Serial l, Serial r)
{
return l.m_Serial == r.m_Serial;
}
public static bool operator !=(Serial l, Serial r)
{
return l.m_Serial != r.m_Serial;
}
public static bool operator >(Serial l, Serial r)
{
return l.m_Serial > r.m_Serial;
}
public static bool operator <(Serial l, Serial r)
{
return l.m_Serial < r.m_Serial;
}
public static bool operator >=(Serial l, Serial r)
{
return l.m_Serial >= r.m_Serial;
}
public static bool operator <=(Serial l, Serial r)
{
return l.m_Serial <= r.m_Serial;
}
/*public static Serial operator ++ ( Serial l )
{
return new Serial( l + 1 );
}*/
public override string ToString()
{
return String.Format("0x{0:X8}", m_Serial);
}
public static implicit operator int(Serial a)
{
return a.m_Serial;
}
public static implicit operator Serial(int a)
{
return new Serial(a);
}
}
}