using GlitchyEngine.Editor; using System; using System.Collections.Generic; using System.Reflection; using GlitchyEngine.Core; using GlitchyEngine.Extensions; namespace GlitchyEngine.Serialization; internal enum SerializationType : int { None, Bool, Char, String, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float, Double, Decimal, Enum, EntityReference, ComponentReference, ObjectReference } internal static class EntitySerializer { internal static void Serialize(Entity entity, IntPtr internalContext) { SerializedObject obj = new SerializedObject(internalContext, UUID.Zero, new Dictionary()); obj.Serialize(entity); } internal static void Deserialize(Entity entity, IntPtr internalContext) { DeserializationObject obj = new DeserializationObject(internalContext, UUID.Zero, new Dictionary()); obj.Deserialize(entity); } /// /// Returns whether or not the field described by the given should be serialized or not. /// internal static bool SerializeField(FieldInfo fieldInfo) { // TODO: We want to be able to serialize static fields in the future! if (fieldInfo.IsStatic) return false; var serializeField = fieldInfo.HasCustomAttribute(); var dontSerializeField = fieldInfo.HasCustomAttribute(); //var hideField = fieldInfo.HasCustomAttribute(); var showField = fieldInfo.HasCustomAttribute(); if (fieldInfo.IsPublic) { if (dontSerializeField) return false; return true; } if (serializeField) return true; if (showField && !dontSerializeField) return true; return false; } }