Пример #1
0
        private static IList <IEntity> GetEntitiesUnderPosition(IClientEntityManager entityMan,
                                                                GridLocalCoordinates coordinates)
        {
            // Find all the entities intersecting our click
            var entities = entityMan.GetEntitiesIntersecting(coordinates.MapID, coordinates.Position);

            // Check the entities against whether or not we can click them
            var foundEntities = new List <(IEntity clicked, int drawDepth)>();

            foreach (var entity in entities)
            {
                if (entity.TryGetComponent <IClientClickableComponent>(out var component) &&
                    entity.Transform.IsMapTransform &&
                    component.CheckClick(coordinates, out var drawDepthClicked))
                {
                    foundEntities.Add((entity, drawDepthClicked));
                }
            }

            if (foundEntities.Count == 0)
            {
                return(new List <IEntity>());
            }

            foundEntities.Sort(new ClickableEntityComparer());
            // 0 is the top element.
            foundEntities.Reverse();
            return(foundEntities.Select(a => a.clicked).ToList());
        }
Пример #2
0
        public void Setup()
        {
            EntityManager = IoCManager.Resolve <IClientEntityManager>();
            MapManager    = IoCManager.Resolve <IMapManager>();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            MapA  = MapManager.CreateMap();
            GridA = MapManager.CreateGrid(MapA);

            MapB  = MapManager.CreateMap();
            GridB = MapManager.CreateGrid(MapB);

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the tests
        }
Пример #3
0
        public void Setup()
        {
            var factory = IoCManager.Resolve <IComponentFactory>();

            factory.Register <TransformComponent>();
            factory.RegisterReference <TransformComponent, ITransformComponent>();

            EntityManager = IoCManager.Resolve <IClientEntityManager>();
            MapManager    = IoCManager.Resolve <IMapManager>();

            var manager = IoCManager.Resolve <IPrototypeManager>();

            manager.LoadFromStream(new StringReader(PROTOTYPES));
            manager.Resync();

            // build the net dream
            MapA  = MapManager.CreateMap();
            GridA = MapA.CreateGrid();

            MapB  = MapManager.CreateMap();
            GridB = MapB.CreateGrid();

            //NOTE: The grids have not moved, so we can assert worldpos == localpos for the tests
        }