1using Microsoft.Xna.Framework;
3using System.Collections;
4using System.Collections.Generic;
6using Terraria.DataStructures;
20 private static IDictionary<Type, TagSerializer>
serializers =
new Dictionary<Type, TagSerializer>();
21 private static IDictionary<string, Type>
typeNameCache =
new Dictionary<string, Type>();
27 internal static void Reload() {
46 var sType = typeof(TagSerializableSerializer<>).MakeGenericType(type);
62 type =
Type.GetType(name);
67 type = mod.Code?.GetType(name);
93 return ((IList<T>)value).Select(
Serialize).ToList();
97 return ((IList<S>)value).Select(
Deserialize).ToList();
103 public override short Serialize(ushort value) => (short)value;
109 public override int Serialize(uint value) => (int)value;
115 public override long Serialize(ulong value) => (long)value;
121 public override byte Serialize(
bool value) => (byte)(value ? 1 : 0);
143 public override Vector3
Deserialize(
TagCompound tag) =>
new Vector3(tag.GetFloat(
"x"), tag.GetFloat(
"y"), tag.GetFloat(
"z"));
149 return (
int)value.PackedValue;
153 return new Color(tag & 0xFF, tag >> 8 & 0xFF, tag >> 16 & 0xFF, tag >> 24 & 0xFF);
172 [
"width"] = value.Width,
173 [
"height"] = value.Height
176 public override Rectangle
Deserialize(
TagCompound tag) =>
new Rectangle(tag.GetInt(
"x"), tag.GetInt(
"y"), tag.GetInt(
"width"), tag.GetInt(
"height"));
override byte Serialize(bool value)
override bool Deserialize(byte tag)
override int Serialize(Color value)
override Color Deserialize(int tag)
override TagCompound Serialize(Point16 value)
override Point16 Deserialize(TagCompound tag)
override TagCompound Serialize(Rectangle value)
override Rectangle Deserialize(TagCompound tag)
abstract object Serialize(object value)
override IList DeserializeList(IList value)
override IList SerializeList(IList value)
override object Deserialize(object tag)
static IDictionary< Type, TagSerializer > serializers
static bool TryGetSerializer(Type type, out TagSerializer serializer)
abstract IList SerializeList(IList value)
static IDictionary< string, Type > typeNameCache
static void AddSerializer(TagSerializer serializer)
abstract T Deserialize(S tag)
static Type GetType(string name)
abstract object Deserialize(object tag)
abstract S Serialize(T value)
override object Serialize(object value)
abstract IList DeserializeList(IList value)
override int Serialize(uint value)
override uint Deserialize(int tag)
override ulong Deserialize(long tag)
override long Serialize(ulong value)
override ushort Deserialize(short tag)
override short Serialize(ushort value)
override Vector2 Deserialize(TagCompound tag)
override TagCompound Serialize(Vector2 value)
override TagCompound Serialize(Vector3 value)
override Vector3 Deserialize(TagCompound tag)
This serves as the central class which loads mods. It contains many static fields and methods related...