Esempio n. 1
0
    public static SaveGameData.SaveData.SerializableEntitiesDictionary ConvertToEntitySdos(List <Entity> entities)
    {
        var sdos = new SaveGameData.SaveData.SerializableEntitiesDictionary();

        foreach (var entity in entities)
        {
            if (entity.CurrentCell == null)
            {
                continue;
            }

            var sdo = ConvertToEntitySdo(entity);
            sdos.Add(sdo.Id, sdo);
        }

        return(sdos);
    }
Esempio n. 2
0
    public static Dictionary <Guid, Entity> ConvertToEntities(
        SaveGameData.SaveData.SerializableEntitiesDictionary entitySdos)
    {
        var entities = new Dictionary <Guid, Entity>();

        foreach (var entitySdo in entitySdos)
        {
            var entity = ConvertToEntity(entitySdo.Value);

            entities.Add(entity.Id, entity);
        }

        foreach (var entitySdo in entitySdos)
        {
            var entity = entities[entitySdo.Key];

            if (entities.ContainsKey(entitySdo.Value.BirthMotherId))
            {
                entity.BirthMother = entities[entitySdo.Value.BirthMotherId];
            }

            if (entities.ContainsKey(entitySdo.Value.BirthFatherId))
            {
                entity.BirthFather = entities[entitySdo.Value.BirthFatherId];
            }

            foreach (var childId in entitySdo.Value.ChildrenIds)
            {
                if (entities.ContainsKey(childId))
                {
                    entity.Children.Add(entities[childId]);
                }
            }
        }
        return(entities);
    }