Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
80
Server/Customs Framework/Central Core/Base Types/BaseCore.cs
Normal file
80
Server/Customs Framework/Central Core/Base Types/BaseCore.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
#region References
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public class BaseCore : SaveData, ICustomsEntity, ISerializable
|
||||
{
|
||||
public static event BaseCoreEventHandler OnEnabledChanged;
|
||||
|
||||
private bool _Enabled;
|
||||
|
||||
public BaseCore()
|
||||
{ }
|
||||
|
||||
public BaseCore(CustomSerial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
[CommandProperty(AccessLevel.Developer)]
|
||||
public bool Enabled
|
||||
{
|
||||
get { return _Enabled; }
|
||||
set
|
||||
{
|
||||
if (value != _Enabled)
|
||||
{
|
||||
_Enabled = value;
|
||||
|
||||
if (OnEnabledChanged != null)
|
||||
{
|
||||
OnEnabledChanged(new BaseCoreEventArgs(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name { get { return @"Base Core"; } }
|
||||
public virtual string Description { get { return @"Base Core, inherit from this class and override the interface items."; } }
|
||||
public virtual string Version { get { return "1.0"; } }
|
||||
public virtual AccessLevel EditLevel { get { return AccessLevel.Developer; } }
|
||||
// TODO: Implement Custom Systems Control
|
||||
public virtual Gump SettingsGump { get { return null; } }
|
||||
public virtual bool ShardControlEnabled { get { return false; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public override void Prep()
|
||||
{ }
|
||||
|
||||
public override void Delete()
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteVersion(0);
|
||||
|
||||
// Version 0
|
||||
writer.Write(_Enabled);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
_Enabled = reader.ReadBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
188
Server/Customs Framework/Central Core/Base Types/BaseModule.cs
Normal file
188
Server/Customs Framework/Central Core/Base Types/BaseModule.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public class BaseModule : SaveData, ICustomsEntity, ISerializable
|
||||
{
|
||||
private Mobile _LinkedMobile;
|
||||
private Item _LinkedItem;
|
||||
private DateTime _CreatedTime;
|
||||
private DateTime _LastEditedTime;
|
||||
|
||||
public BaseModule()
|
||||
{ }
|
||||
|
||||
public BaseModule(Mobile from)
|
||||
{
|
||||
LinkMobile(from);
|
||||
}
|
||||
|
||||
public BaseModule(Item item)
|
||||
{
|
||||
LinkItem(item);
|
||||
}
|
||||
|
||||
public BaseModule(CustomSerial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override string Name { get { return @"Base Module"; } }
|
||||
|
||||
public virtual string Description { get { return "Base Module, inherit from this class and override all interface items."; } }
|
||||
|
||||
public virtual string Version { get { return "1.0"; } }
|
||||
|
||||
public virtual AccessLevel EditLevel { get { return AccessLevel.Developer; } }
|
||||
|
||||
public virtual Gump SettingsGump { get { return null; } }
|
||||
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public Mobile LinkedMobile { get { return _LinkedMobile; } set { LinkMobile(value); } }
|
||||
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public Item LinkedItem { get { return _LinkedItem; } set { LinkItem(value); } }
|
||||
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public DateTime CreatedTime { get { return _CreatedTime; } }
|
||||
|
||||
[CommandProperty(AccessLevel.Administrator)]
|
||||
public DateTime LastEditedTime { get { return _LastEditedTime; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public override void Prep()
|
||||
{ }
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (_LinkedMobile != null)
|
||||
{
|
||||
_LinkedMobile.Modules.Remove(this);
|
||||
_LinkedMobile = null;
|
||||
}
|
||||
|
||||
if (_LinkedItem != null)
|
||||
{
|
||||
_LinkedItem.Modules.Remove(this);
|
||||
_LinkedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
_LastEditedTime = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public bool LinkMobile(Mobile from)
|
||||
{
|
||||
if (_LinkedMobile != null || _LinkedMobile == from)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!from.Modules.Contains(this))
|
||||
{
|
||||
from.Modules.Add(this);
|
||||
}
|
||||
|
||||
_LinkedMobile = from;
|
||||
Update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LinkItem(Item item)
|
||||
{
|
||||
if (_LinkedItem != null || _LinkedItem == item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!item.Modules.Contains(this))
|
||||
{
|
||||
item.Modules.Add(this);
|
||||
}
|
||||
|
||||
_LinkedItem = item;
|
||||
Update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UnlinkMobile()
|
||||
{
|
||||
if (_LinkedMobile == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_LinkedMobile.Modules.Contains(this))
|
||||
{
|
||||
_LinkedMobile.Modules.Remove(this);
|
||||
}
|
||||
|
||||
_LinkedMobile = null;
|
||||
Update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UnlinkItem()
|
||||
{
|
||||
if (_LinkedItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_LinkedItem.Modules.Contains(this))
|
||||
{
|
||||
_LinkedItem.Modules.Remove(this);
|
||||
}
|
||||
|
||||
_LinkedItem = null;
|
||||
Update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteVersion(0);
|
||||
|
||||
// Version 0
|
||||
writer.Write(_LinkedMobile);
|
||||
writer.Write(_LinkedItem);
|
||||
writer.Write(_CreatedTime);
|
||||
writer.Write(_LastEditedTime);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
LinkedMobile = reader.ReadMobile();
|
||||
LinkedItem = reader.ReadItem();
|
||||
_CreatedTime = reader.ReadDateTime();
|
||||
_LastEditedTime = reader.ReadDateTime();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#region References
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public class BaseService : SaveData, ICustomsEntity, ISerializable
|
||||
{
|
||||
public BaseService()
|
||||
{ }
|
||||
|
||||
public BaseService(CustomSerial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override string Name { get { return @"Base Service"; } }
|
||||
public virtual string Description { get { return @"Base Service, inherit from this class and override the interface items."; } }
|
||||
public virtual string Version { get { return "1.0"; } }
|
||||
public virtual AccessLevel EditLevel { get { return AccessLevel.Developer; } }
|
||||
public virtual Gump SettingsGump { get { return null; } }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public override void Prep()
|
||||
{ }
|
||||
|
||||
public override void Delete()
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteVersion(0);
|
||||
//Version 0
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
34
Server/Customs Framework/Central Core/Base Types/Events.cs
Normal file
34
Server/Customs Framework/Central Core/Base Types/Events.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
#region References
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public delegate void BaseCoreEventHandler(BaseCoreEventArgs e);
|
||||
|
||||
public delegate void BaseModuleEventHandler(BaseModuleEventArgs e);
|
||||
|
||||
public class BaseCoreEventArgs : EventArgs
|
||||
{
|
||||
private readonly BaseCore m_Core;
|
||||
|
||||
public BaseCoreEventArgs(BaseCore core)
|
||||
{
|
||||
m_Core = core;
|
||||
}
|
||||
|
||||
public BaseCore Core { get { return m_Core; } }
|
||||
}
|
||||
|
||||
public class BaseModuleEventArgs : EventArgs
|
||||
{
|
||||
private readonly BaseModule m_Module;
|
||||
|
||||
public BaseModuleEventArgs(BaseModule module)
|
||||
{
|
||||
m_Module = module;
|
||||
}
|
||||
|
||||
public BaseModule Module { get { return m_Module; } }
|
||||
}
|
||||
}
|
||||
113
Server/Customs Framework/Central Core/Base Types/SaveData.cs
Normal file
113
Server/Customs Framework/Central Core/Base Types/SaveData.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public class SaveData : ICustomsEntity, IComparable<SaveData>, ISerializable
|
||||
{
|
||||
#region CompareTo
|
||||
public int CompareTo(ICustomsEntity other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _Serial.CompareTo(other.Serial);
|
||||
}
|
||||
|
||||
public int CompareTo(SaveData other)
|
||||
{
|
||||
return CompareTo((ICustomsEntity)other);
|
||||
}
|
||||
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other == null || other is ICustomsEntity)
|
||||
{
|
||||
return CompareTo((ICustomsEntity)other);
|
||||
}
|
||||
|
||||
throw new ArgumentException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal int _TypeID;
|
||||
|
||||
int ISerializable.TypeReference { get { return _TypeID; } }
|
||||
|
||||
int ISerializable.SerialIdentity { get { return _Serial; } }
|
||||
|
||||
private bool _Deleted;
|
||||
private CustomSerial _Serial;
|
||||
|
||||
[CommandProperty(AccessLevel.Developer)]
|
||||
public bool Deleted { get { return _Deleted; } set { _Deleted = value; } }
|
||||
|
||||
[CommandProperty(AccessLevel.Developer)]
|
||||
public CustomSerial Serial { get { return _Serial; } set { _Serial = value; } }
|
||||
|
||||
public virtual string Name { get { return @"Save Data"; } }
|
||||
|
||||
public SaveData(CustomSerial serial)
|
||||
{
|
||||
_Serial = serial;
|
||||
|
||||
Type dataType = GetType();
|
||||
_TypeID = World._DataTypes.IndexOf(dataType);
|
||||
|
||||
if (_TypeID == -1)
|
||||
{
|
||||
World._DataTypes.Add(dataType);
|
||||
_TypeID = World._DataTypes.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public SaveData()
|
||||
{
|
||||
_Serial = CustomSerial.NewCustom;
|
||||
|
||||
World.AddData(this);
|
||||
|
||||
Type dataType = GetType();
|
||||
_TypeID = World._DataTypes.IndexOf(dataType);
|
||||
|
||||
if (_TypeID == -1)
|
||||
{
|
||||
World._DataTypes.Add(dataType);
|
||||
_TypeID = World._DataTypes.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Prep()
|
||||
{ }
|
||||
|
||||
public virtual void Delete()
|
||||
{ }
|
||||
|
||||
public virtual void Serialize(GenericWriter writer)
|
||||
{
|
||||
writer.WriteVersion(0);
|
||||
|
||||
// Version 0
|
||||
writer.Write(_Deleted);
|
||||
}
|
||||
|
||||
public virtual void Deserialize(GenericReader reader)
|
||||
{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
_Deleted = reader.ReadBool();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
Server/Customs Framework/Central Core/CustomSerial.cs
Normal file
116
Server/Customs Framework/Central Core/CustomSerial.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
#region References
|
||||
using System;
|
||||
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public struct CustomSerial : IComparable, IComparable<CustomSerial>
|
||||
{
|
||||
public static readonly CustomSerial MinusOne = new CustomSerial(-1);
|
||||
public static readonly CustomSerial Zero = new CustomSerial(0);
|
||||
private static CustomSerial _LastCustom = Zero;
|
||||
private readonly int _Serial;
|
||||
|
||||
private CustomSerial(int serial)
|
||||
{
|
||||
_Serial = serial;
|
||||
}
|
||||
|
||||
public static CustomSerial LastCore { get { return _LastCustom; } }
|
||||
|
||||
public static CustomSerial NewCustom
|
||||
{
|
||||
get
|
||||
{
|
||||
while (World.GetData(_LastCustom = (_LastCustom + 1)) != null)
|
||||
{ }
|
||||
|
||||
return _LastCustom;
|
||||
}
|
||||
}
|
||||
|
||||
public int Value { get { return _Serial; } }
|
||||
public bool IsValid { get { return (_Serial > 0); } }
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _Serial;
|
||||
}
|
||||
|
||||
public int CompareTo(CustomSerial other)
|
||||
{
|
||||
return _Serial.CompareTo(other._Serial);
|
||||
}
|
||||
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other is CustomSerial)
|
||||
{
|
||||
return CompareTo((CustomSerial)other);
|
||||
}
|
||||
else if (other == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || !(obj is CustomSerial))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((CustomSerial)obj)._Serial == _Serial;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("0x{0:X8}", _Serial);
|
||||
}
|
||||
|
||||
public static bool operator ==(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial == second._Serial;
|
||||
}
|
||||
|
||||
public static bool operator !=(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial != second._Serial;
|
||||
}
|
||||
|
||||
public static bool operator >(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial > second._Serial;
|
||||
}
|
||||
|
||||
public static bool operator <(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial < second._Serial;
|
||||
}
|
||||
|
||||
public static bool operator >=(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial >= second._Serial;
|
||||
}
|
||||
|
||||
public static bool operator <=(CustomSerial first, CustomSerial second)
|
||||
{
|
||||
return first._Serial <= second._Serial;
|
||||
}
|
||||
|
||||
public static implicit operator int(CustomSerial serial)
|
||||
{
|
||||
return serial._Serial;
|
||||
}
|
||||
|
||||
public static implicit operator CustomSerial(int serial)
|
||||
{
|
||||
return new CustomSerial(serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Server/Customs Framework/Central Core/Interfaces.cs
Normal file
23
Server/Customs Framework/Central Core/Interfaces.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
#region References
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace CustomsFramework
|
||||
{
|
||||
public interface ICustomsEntry
|
||||
{
|
||||
CustomSerial Serial { get; }
|
||||
int TypeID { get; }
|
||||
long Position { get; }
|
||||
int Length { get; }
|
||||
}
|
||||
|
||||
public interface ICustomsEntity : IComparable, IComparable<ICustomsEntity>
|
||||
{
|
||||
CustomSerial Serial { get; }
|
||||
string Name { get; }
|
||||
void Delete();
|
||||
|
||||
void Prep();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user