Show / Hide Table of Contents

Class MCustom<T>

Base class for all custom mod-added mapper types.

Inheritance
Object
MapperType
MCustom<T>
Namespace: Modding.Mapper
Assembly: Assembly-CSharp.dll
Syntax
public abstract class MCustom<T> : MapperType
Type Parameters
Name Description
T

Constructors

MCustom(String, String, T)

Declaration
protected MCustom(string displayName, string key, T defaultValue)
Parameters
Type Name Description
String displayName
String key
T defaultValue

Fields

defaultValue

The default value this mapper type was created with.

Declaration
protected T defaultValue
Field Value
Type Description
T

loadValue

Load value of the mapper type. This is used for the undo system, and is normally handled completely automatically.

Declaration
protected T loadValue
Field Value
Type Description
T

value

Current value of the mapper type.

Declaration
protected T value
Field Value
Type Description
T

Properties

isDefaultValue

Default implementation compares value and defaultValue using .Equals(). If this is not suitable or ideal for type T, override this.

Declaration
public override bool isDefaultValue { get; }
Property Value
Type Description
Boolean
Overrides
MapperType.isDefaultValue

SerializationKey

This key should be used for all serialization of the mapper type.

Declaration
protected string SerializationKey { get; }
Property Value
Type Description
String

Value

Provides public access to the underlying value. Setting this automatically invokes the Changed event.

Declaration
public virtual T Value { get; set; }
Property Value
Type Description
T

Methods

ApplyValue()

Applies the load value to the value and invokes the Changed event.

Declaration
public override void ApplyValue()
Overrides
MapperType.ApplyValue()

DeSerialize(XData)

Deserializes the given data into both value and load value.

Declaration
public override void DeSerialize(XData raw)
Parameters
Type Name Description
XData raw
Overrides
MapperType.DeSerialize(XData)

DeSerializeValue(XData)

Override to specify how to deserialize from XData to a T.

Declaration
public abstract T DeSerializeValue(XData data)
Parameters
Type Name Description
XData data
Returns
Type Description
T
Remarks

This is used to provide default implementations for the other DeSerialize* methods.

InvokeChanged(T)

Be careful if you override this, it is called from the base constructor.

Declaration
public virtual void InvokeChanged(T value)
Parameters
Type Name Description
T value

ResetDefaults()

Resets the mapper type's value back to the default value.

Declaration
public override void ResetDefaults()
Overrides
MapperType.ResetDefaults()

ResetValue()

Resets the value back to the load value. Used for undo.

Declaration
public override void ResetValue()
Overrides
MapperType.ResetValue()

Serialize()

Serializes the current value.

Declaration
public override XData Serialize()
Returns
Type Description
XData
Overrides
MapperType.Serialize()

SerializeDefault()

Serializes the default value.

Declaration
public override XData SerializeDefault()
Returns
Type Description
XData
Overrides
MapperType.SerializeDefault()

SerializeLoadValue()

Serializes the load value.

Declaration
public override XData SerializeLoadValue()
Returns
Type Description
XData
Overrides
MapperType.SerializeLoadValue()

SerializeValue(T)

Override to specify how to serialize a T into an XData. Be careful: This is called from the MCustom constructor, which means it is called before the derived class' constructor is called! Use SerializationKey as the key for the XData object!

Declaration
public abstract XData SerializeValue(T value)
Parameters
Type Name Description
T value
Returns
Type Description
XData
Remarks

This is used to provide default implementations for the other Serialize* methods.

Events

Changed

Invoked whenever the underlying value of the mapper type is changed.

Declaration
public event Action<T> Changed
Event Type
Type Description
Action<T>
Back to top Generated by DocFX