private void SaveComponentData <T>(Entity e, string typeName, string entityName) where T : struct, IComponentData { string filePath = GetFolderPath(typeName, entityName) + typeof(T).Name.ToString() + ".txt"; //Debug.LogError("Saving [" + entityName + "] [" + typeof(T).Name.ToString() + "] to File at: " + filePath); string json; /*if (typeof(BlitzSerializeable<T>) == typeof(T)) * { * BlitzSerializeable<T> component = EntityManager.GetComponentData<BlitzSerializeable<T>>(e); * json = component.GetJson(); * }*/ if (typeof(T) == typeof(Inventory)) { if (EntityManager.HasComponent <Inventory>(e) == false) { Debug.LogError("Character has no inventory.."); json = ""; } else { Inventory component = EntityManager.GetComponentData <Inventory>(e); json = component.GetJson(); } } else if (typeof(T) == typeof(Stats)) { if (World.EntityManager.HasComponent <Stats>(e)) { Stats component = EntityManager.GetComponentData <Stats>(e); json = component.GetJson(); } else { json = ""; } } else if (typeof(T) == typeof(Skills)) { if (World.EntityManager.HasComponent <Skills>(e)) { Skills component = EntityManager.GetComponentData <Skills>(e); json = component.GetJson(); } else { json = ""; } } else if (typeof(T) == typeof(Equipment)) { if (World.EntityManager.HasComponent <Equipment>(e)) { Equipment component = EntityManager.GetComponentData <Equipment>(e); json = component.GetJson(); } else { json = ""; } } else if (typeof(T) == typeof(QuestLog)) { if (World.EntityManager.HasComponent <QuestLog>(e)) { QuestLog component = EntityManager.GetComponentData <QuestLog>(e); json = component.GetJson(); } else { json = ""; } } else { T component = EntityManager.GetComponentData <T>(e); json = ToJson(component); } //Debug.Log("Saving Json to: " + filePath + " of type " + typeof(T).ToString() + "\n" + json); System.IO.File.WriteAllText(filePath, json); }