public void All_constraint_params_sets_OrConstraint_to_empty_list()
        {
            var constraint = Constraint.All(BasicConstraint, BasicConstraint, BasicConstraint);

            Assert.AreEqual(constraint.AsQueryConstraint().AndConstraint.Count, 3);
            Assert.AreEqual(0, constraint.AsQueryConstraint().OrConstraint.Count);
        }
        public void All_constraint_enumerable_sets_OrConstraint_to_empty_list()
        {
            var constraint = Constraint.All(new List <Constraint> {
                BasicConstraint
            });

            Assert.AreEqual(constraint.AsQueryConstraint().AndConstraint.Count, 1);
            Assert.AreEqual(0, constraint.AsQueryConstraint().OrConstraint.Count);
        }
Beispiel #3
0
        static void AddSymbolicTowerQuery <T>(InterestTemplate interest) where T : ISpatialComponentData
        {
            var towerQuery = InterestQuery.Query(
                Constraint.All(
                    Constraint.Component(SymbolicTower.ComponentId),
                    Constraint.RelativeSphere(FixedParams.WorldInterestLimit)))
                             .FilterResults(Position.ComponentId,
                                            SymbolicTower.ComponentId,
                                            Metadata.ComponentId)
                             .WithMaxFrequencyHz(FixedParams.WorldInterestFrequency);

            interest.AddQueries <T>(towerQuery);
        }
Beispiel #4
0
        static void AddMinimapQuery <T>(InterestTemplate interest) where T : ISpatialComponentData
        {
            var minimapQuery = InterestQuery.Query(
                Constraint.All(
                    Constraint.Any(Constraint.Component(CommanderStatus.ComponentId),
                                   Constraint.Component(StrongholdStatus.ComponentId),
                                   Constraint.Component(HeadQuarters.ComponentId)),
                    Constraint.RelativeSphere(FixedParams.WorldInterestLimit)))
                               .FilterResults(Position.ComponentId,
                                              BaseUnitStatus.ComponentId,
                                              TransformInternal.ComponentId)
                               .WithMaxFrequencyHz(FixedParams.WorldInterestFrequency);

            interest.AddQueries <T>(minimapQuery);
        }
        void Test()
        {
            var playerQuery = InterestQuery.Query(
                Constraint.All(
                    Constraint.Component <PlayerInfo.Component>(),
                    Constraint.RelativeSphere(20))
                ).FilterResults(Position.ComponentId, PlayerInfo.ComponentId);

            var minimapQuery = InterestQuery.Query(
                Constraint.All(
                    Constraint.Component <MinimapRepresentaion.Component>(),
                    Constraint.RelativeBox(50, double.PositiveInfinity, 50))
                ).FilterResults(Position.ComponentId, MinimapRepresentaion.ComponentId);

            var interestTemplate = InterestTemplate.Create()
                                   .AddQueries <PlayerControls.Component>(playerQuery, minimapQuery);

            var playerTemplate = new EntityTemplate();

            playerTemplate.AddComponent(interestTemplate.ToSnapshot(), WorkerUtils.UnityGameLogic);
        }
 public void All_constraint_throws_if_enumerable_empty()
 {
     Assert.Throws <ArgumentException>(() => Constraint.All(new List <Constraint>()));
 }