示例#1
0
        public virtual void SpreadPower(PowerNetwork pn)
        {
            this.grided = true;

            if (this.pn == null)
            {
                this.pn = pn;
            }

            if (Powered() && ProjectsPower())
            {
                HashSet <Hex> hexes = h.Neighbors().Aggregate(new HashSet <Hex>(),
                                                              (HashSet <Hex> acc, Hex hs) => {
                    acc.Add(h);
                    foreach (Hex n in hs.Neighbors())
                    {
                        acc.Add(n);
                    }
                    return(acc);
                });

                foreach (Hex hs in hexes)
                {
                    hs.pn = pn;
                }

                foreach (Hex hs in hexes)
                {
                    if (hs.building != null && !hs.building.grided)
                    {
                        if (VisuallyConnects() && hs.building.VisuallyConnects())
                        {
                            h.wm.bm.Add(h.loc, hs.loc);
                        }

                        hs.building.SpreadPower(pn);
                    }
                }
            }
        }
示例#2
0
文件: WarpGate.cs 项目: desyderata/4x
 public override void SpreadPower(PowerNetwork pn)
 {
     base.SpreadPower(pn);
     pn.warpgates++;
 }