Exemplo n.º 1
0
 public BCMHubCell(BCMHubCell hubCell)
 {
     GridPos        = hubCell.GridPos;
     Township       = hubCell.Township;
     CellRule       = hubCell.CellRule;
     HubRule        = hubCell.HubRule;
     WildernessRule = hubCell.WildernessRule;
     Lots           = new List <BCMLot>();
 }
Exemplo n.º 2
0
        public override void Process()
        {
            if (Options.ContainsKey("reset"))
            {
                _hubCellData.Clear();
                _loaded.Clear();
            }

            GetHubCellData();
            var filteredHCD = new List <BCMHubCell>();

            if (Params.Count == 1)
            {
                GetMinMax(out int minX, out int minY, out int maxX, out int maxY);

                foreach (var hubCell in _hubCellData)
                {
                    if (!(minX <= hubCell.GridPos.x && hubCell.GridPos.x <= maxX &&
                          minY <= hubCell.GridPos.y && hubCell.GridPos.y <= maxY))
                    {
                        continue;
                    }

                    var newHubCell = new BCMHubCell(hubCell);
                    foreach (var lot in hubCell.Lots)
                    {
                        if (!lot.Prefab.Contains(Params[0]))
                        {
                            continue;
                        }

                        newHubCell.Lots.Add(new BCMLot(lot));
                        filteredHCD.Add(newHubCell);
                    }
                }
            }
            else
            {
                filteredHCD = _hubCellData;
            }

            if (Options.ContainsKey("full"))
            {
                SendJson(filteredHCD);
            }
            else if (Options.ContainsKey("min"))
            {
                var keyless = new List <object>();
                foreach (var d in filteredHCD)
                {
                    var obj = d.Lots.Select(l => $"{l.Prefab}:{l.Position}").Cast <object>().ToList();
                    if (obj.Count <= 0)
                    {
                        continue;
                    }

                    keyless.AddRange(obj);
                }

                SendJson(keyless);
            }
            else
            {
                SendJson(filteredHCD.SelectMany(hubCell => hubCell.Lots, (hubCell, lot) => new BCMBasicLot(lot)).ToList());
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }