Exemplo n.º 1
0
        public static IEnumerable <(Direction dir, EntityUid entity)> GetCardinalNeighborCells(
            IMapGrid grid,
            Vector2i coords,
            bool includeSameTile = true)
        {
            if (includeSameTile)
            {
                foreach (var uid in grid.GetAnchoredEntities(coords))
                {
                    yield return(Direction.Invalid, uid);
                }
            }

            foreach (var uid in grid.GetAnchoredEntities(coords + (0, 1)))
            {
                yield return(Direction.North, uid);
            }

            foreach (var uid in grid.GetAnchoredEntities(coords + (0, -1)))
            {
                yield return(Direction.South, uid);
            }

            foreach (var uid in grid.GetAnchoredEntities(coords + (1, 0)))
            {
                yield return(Direction.East, uid);
            }

            foreach (var uid in grid.GetAnchoredEntities(coords + (-1, 0)))
            {
                yield return(Direction.West, uid);
            }
        }
Exemplo n.º 2
0
    private static PuddleComponent?GetPuddle(IEntityManager entityManager, IMapGrid mapGrid, Vector2i pos)
    {
        foreach (var uid in mapGrid.GetAnchoredEntities(pos))
        {
            if (entityManager.TryGetComponent(uid, out PuddleComponent puddleComponent))
            {
                return(puddleComponent);
            }
        }

        return(null);
    }
Exemplo n.º 3
0
        public static IEnumerable <Node> GetNodesInTile(IComponentManager compMgr, IMapGrid grid, Vector2i coords)
        {
            foreach (var entityUid in grid.GetAnchoredEntities(coords))
            {
                if (!compMgr.TryGetComponent(entityUid, out NodeContainerComponent? container))
                {
                    continue;
                }

                foreach (var node in container.Nodes.Values)
                {
                    yield return(node);
                }
            }
        }
        private void UpdateTile(IMapGrid grid, Vector2i position)
        {
            var covered = HasFloorCover(grid, position);

            foreach (var uid in grid.GetAnchoredEntities(position))
            {
                if (!TryComp(uid, out SubFloorHideComponent? hideComp))
                {
                    continue;
                }

                if (hideComp.IsUnderCover == covered)
                {
                    continue;
                }

                hideComp.IsUnderCover = covered;
                UpdateAppearance(uid, hideComp);
            }
        }