Exemple #1
0
        private bool HaveNoBuilding(Requirement req, IEnumerable <IStructure> objects, uint x, uint y, byte size)
        {
            foreach (var obj in objects)
            {
                if (req.Type != obj.Type || obj.Lvl > req.MaxLvl || obj.Lvl < req.MinLvl)
                {
                    continue;
                }

                int dist = tileLocator.RadiusDistance(obj.PrimaryPosition, obj.Size, new Position(x, y), size);

                if (dist > req.MaxDist || dist < req.MinDist)
                {
                    continue;
                }

                return(false);
            }
            return(true);
        }
Exemple #2
0
        public override bool Validate(IStructure builder, ushort type, uint x, uint y, byte size)
        {
            var effects = builder.Technologies.GetAllEffects(EffectInheritance.Upward).ToArray();

            foreach (var req in Requirements)
            {
                int radius = formula.GetAwayFromRadius(effects, req.MinDist, type);

                // Copy for local closure
                Requirement req1 = req;
                if (builder.City.Any(structure =>
                                     structure.Type == req1.Type &&
                                     structure.Lvl >= req1.MinLvl &&
                                     structure.Lvl <= req1.MaxLvl &&
                                     tileLocator.RadiusDistance(structure.PrimaryPosition, structure.Size, new Position(x, y), size) < radius + 1))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #3
0
 public void Add(Requirement req)
 {
     Requirements.Add(req);
 }