예제 #1
0
        private void UpdateEntityKnowledge(
            GameEntity entity,
            EntityMatcher <GameEntity> matcher,
            GameManager manager,
            Point?additionalCellToTest = null,
            LevelComponent level       = null)
        {
            var position = entity.Position;

            if (position != null)
            {
                level = level ?? position.LevelEntity.Level;
            }

            SenseType sensedType;

            if (position != null &&
                ((sensedType = manager.SensorySystem.SensedByPlayer(entity, position.LevelCell))
                 != SenseType.None ||
                 (additionalCellToTest != null &&
                  (sensedType = manager.SensorySystem.SensedByPlayer(entity, additionalCellToTest.Value))
                  != SenseType.None)))
            {
                foreach (var conflictingKnowledge in
                         manager.LevelKnowledgeToLevelCellIndex[(position.LevelId, position.LevelX, position.LevelY)])
예제 #2
0
        public void ShouldMatchEntityReceivedFromFilter()
        {
            testEntity.AddComponent(new FirstTestComponent());
            testFilter.AnyOf(typeof(FirstTestComponent));

            Assert.IsTrue(EntityMatcher.GetMatchedEntities(testFilter).Contains(testEntity));
        }
예제 #3
0
        public List <Category> GetListOfCategories(EntityMatcher matcher)
        {
            var command = $"SELECT * FROM {matcher.TableName}";
            var result  = _commandContext
                          .ExecuteTypeSqlCommand <Category>(command)
                          .ToList();

            return(result);
        }
예제 #4
0
 private void UpdateAllEntitiesKnowledge(
     EntityRelationship <GameEntity> levelEntitiesToLevelRelationship,
     EntityMatcher <GameEntity> matcher,
     LevelComponent level,
     GameManager manager)
 {
     // TODO: Perf: use interval tree to only get the entities and knowledge within sense range
     foreach (var levelEntity in levelEntitiesToLevelRelationship[level.EntityId])
     {
         UpdateEntityKnowledge(levelEntity, matcher, manager, level: level);
     }
 }
예제 #5
0
        private IEnumerable <EntityMatcher> InitializeEntitymatchers()
        {
            var productMatcher = new EntityMatcher(typeof(Product))
            {
                TableName = "Products"
            };

            productMatcher.MatchedTags.UnionWith(new[]
            {
                "товар",
                "продукт",
                "покупка"
            });
            productMatcher.MatchedBulkTags.UnionWith(new[]
            {
                "товары",
                "продукты",
                "покупки"
            });


            var categoryMatcher = new EntityMatcher(typeof(Category))
            {
                TableName = "Categories"
            };

            categoryMatcher.MatchedTags.UnionWith(new[]
            {
                "категория",
                "вид",
                "ассортимент",
                "разновидность"
            });
            categoryMatcher.MatchedBulkTags.UnionWith(new[]
            {
                "категории",
                "виды",
                "разновидности"
            });

            return(new[] { productMatcher, categoryMatcher });
        }
예제 #6
0
 public void ThrowExceptionWhenPassNullFilter()
 {
     EntityMatcher.GetMatchedEntities(null);
 }
예제 #7
0
 public void ShouldNotDuplicateIds()
 {
     EntityMatcher.Subscribe(testEntity);
     EntityMatcher.Subscribe(testEntity);
     Assert.AreEqual(1, EntityMatcher.subscribedEntities.Count);
 }
예제 #8
0
 public void ShouldSubscibeBlankId()
 {
     EntityMatcher.Subscribe(testEntity);
     Assert.AreNotEqual(0, EntityMatcher.subscribedEntities.Count);
 }
예제 #9
0
 public void ShouldUnsubscribeEntity()
 {
     EntityMatcher.Unsubscribe(testEntity);
     Assert.AreEqual(0, EntityMatcher.subscribedEntities.Count);
 }
예제 #10
0
 public void ShouldThrowExceptionWhenRemoveNullEntity()
 {
     EntityMatcher.Unsubscribe(null);
 }
예제 #11
0
 public void ShouldThrowExceptionWhenAddNullEntity()
 {
     EntityMatcher.Subscribe(null);
 }