Beispiel #1
0
    public SettlementSdo GetSettlementSdo()
    {
        SettlementSdo sdo;

        sdo             = new SettlementSdo();
        sdo.CellId      = _cell.Id;
        sdo.Population  = _population;
        sdo.FactionName = Faction?.Name;
        sdo.History     = _history;
        sdo.Name        = Name;
        sdo.CitizenIds  = new List <Guid>();
        sdo.Size        = Size;
        sdo.AreaIds     = new List <string>();

        foreach (var area in _areas.Keys)
        {
            sdo.AreaIds.Add(area.Id);
        }

        if (Citizens != null)
        {
            foreach (var citizen in Citizens)
            {
                sdo.CitizenIds.Add(citizen.Id);
            }
        }

        return(sdo);
    }
Beispiel #2
0
    public Settlement(SettlementSdo sdo)
    {
        if (sdo == null)
        {
            return;
        }

        if (!string.IsNullOrEmpty(sdo.FactionName))
        {
            Faction = WorldData.Instance.Factions[sdo.FactionName];
        }

        Size        = sdo.Size;
        Name        = sdo.Name;
        _cell       = WorldData.Instance.MapDictionary[sdo.CellId];
        _population = sdo.Population;
        _history    = sdo.History;

        Citizens = new List <Entity>();

        foreach (var id in sdo.CitizenIds)
        {
            Citizens.Add(WorldData.Instance.Entities[id]);
        }

        _areas = new Dictionary <Area, SettlementSection>();

        foreach (var id in sdo.AreaIds)
        {
            var splitId = id.Split(' ');

            var area = _cell.Areas[int.Parse(splitId[0]), int.Parse(splitId[1])];

            _areas.Add(new KeyValuePair <Area, SettlementSection>(area, area.SettlementSection));
        }
    }