Skip to main content

TypeSerializationHelper.TypeSerialization<TType>

An abstract class in Root.Township, the global namespace.

Base for a serializer of one value type (float, vector, prefab, save data and so on) used to build read and write delegates for synced save fields.

Constructors​

MemberWhat it is
protected TypeSerialization()Creates a TypeSerializationHelper.TypeSerialization with default values.

Methods​

MemberWhat it is
virtual void Handle<T>(Type type, Delegate get, Delegate set, ref Action<T, Stream, ChunkVersioning> syncWrite, ref Action<T, Stream, ChunkVersioning> syncRead)Adds read and write steps for a single field of this type, given its getter and setter. Logs an error on a type mismatch.
virtual void HandleArray<T>(Type type, Delegate get, Delegate set, ref Action<T, Stream, ChunkVersioning> syncWrite, ref Action<T, Stream, ChunkVersioning> syncRead)Same as Handle for an array field: writes the length, then each element.
virtual void Initialize()Optional setup hook. Empty by default.
protected abstract void Serialize(Type type, ref TType value, Stream stream, ChunkVersioning versioning)Subclasses read or write one value of the type to the stream here.

Used in​

Members of other types that take, return or hold a TypeSerialization&lt;TType>: