Supercell.GUT/Supercell.GUT.Logic/Base/LogicBase.cs

43 lines
889 B
C#
Raw Normal View History

using Supercell.GUT.Titan.Logic.DataStream;
namespace Supercell.GUT.Logic.Base;
public abstract class LogicBase
{
public int LogicDataVersion { get; set; }
public LogicBase(int logicDataVersion)
{
this.LogicDataVersion = logicDataVersion;
}
public virtual void Encode(ChecksumEncoder checksumEncoder)
{
checksumEncoder.WriteInt(this.LogicDataVersion);
}
public virtual void Decode(ByteStream byteStream)
{
this.LogicDataVersion = byteStream.ReadInt();
}
public virtual void Destruct()
{
this.LogicDataVersion = 0;
}
public virtual void Copy(LogicBase logicBase)
{
this.Destruct();
ByteStream byteStream = new ByteStream();
logicBase.Encode(byteStream);
byteStream.ResetOffset();
this.Decode(byteStream);
byteStream.Destruct();
}
}