Skip to main content

TypeSerializationHelper

A static class in Root.Township, the global namespace.

Picks the network serializer for a field's type, used by ClassSerializationHelper and the Sync attributes to build read and write delegates. Built-in types are registered up front; enums, hashed values, logic data, save data and other classes get one made on first use.

Fields​

4 private and internal fields
MemberWhat it is
private static Type hashedTypeHashedGeneralValue, for spotting hashed value types.
private static Type logicValueDataTypeILogicValueData, for spotting logic data types.
private static Dictionary<Type, TypeSerializationHelper.ITypeSerialization> mapCache of type to serializer.
private static Type saveDataTypeSaveData, for spotting save data types.

Methods​

MemberWhat it is
static TypeSerializationHelper.ObjectActivator GetActivator(Type type)Compiles a fast delegate that calls the type's first constructor. Also used by SavingSystem.
static TypeSerializationHelper.ITypeSerialization GetSerialization(Type type)Returns the cached serializer for a type, making one for enums, hashed values, logic data, save data or classes. Logs an error and returns a do-nothing one otherwise.
2 private and internal methods
MemberWhat it is
private static void Add(Type type, TypeSerializationHelper.ITypeSerialization serialization)Registers a serializer for a type and calls its Initialize.
private static void Add<T>(TypeSerializationHelper.TypeSerialization<T> serialization)Registers a serializer for a type and calls its Initialize.