bishou
Initiate
I'm working on an Account Values System similar to ServUO's Points System but I have a few questions.
Is it possible serialize/deserialize an account? How?
This is my first try:
Thanks for the help!
Is it possible serialize/deserialize an account? How?
This is my first try:
Code:
namespace Customs.Engines
{
public abstract class AccountValuesSystem
{
public static string FilePath = Path.Combine("Saves/Custom/AccountValuesSystem", "Persistence.bin");
}
public class AccountValuesEntry
{
public Account m_Account { get; set; }
public double Points { get; set; }
public AccountValuesEntry(Account acct)
{
m_Account = acct;
}
public AccountValuesEntry(Account acct, double points)
{
m_Account = acct;
Points = points;
}
public override bool Equals(object o)
{
if (o == null || !(o is AccountValuesEntry))
{
return false;
}
return ((AccountValuesEntry)o).m_Account == m_Account;
}
public override int GetHashCode()
{
if (m_Account != null)
return m_Account.GetHashCode();
return base.GetHashCode();
}
public virtual void Serialize(GenericWriter writer)
{
writer.Write(0);
//writer.Write(m_Account); // Error Here
writer.Write(Points);
}
public virtual void Deserialize(GenericReader reader)
{
int version = reader.ReadInt();
//m_Account = reader.ReadMobile() as Account;// Error Here
Points = reader.ReadDouble();
}
}
}
Thanks for the help!