예제 #1
0
        public void ResetRenderContainer(LevelRoom room)
        {
            renderContainer = new SuiteRenderingContainer();

            var roomCells = CellCollection.GetByRoom(room.roomId);
            var doorways  = Level.doors.Where(x => roomCells.Any(c => x.rootCells.Contains(c)));
            var openCells = roomCells.Where(x => doorways.Any(a => a.rootCells.Contains(x)));

            renderContainer.spaces.AddRange(openCells.Select(s => (Vector4)s.position));

            nextContainerInstance = renderContainer.Copy();
        }
예제 #2
0
        public bool RenderEntity(LevelRoom room, SuiteEntity entity)
        {
            if (renderContainer == null)
            {
                ResetRenderContainer(room);
            }

            var projectionScaffolds = new List <Scaffold_Node>();

            var success = false;

            //Shortcut to prevent expensive calculations if something obvious can prevent more computation
            if (!ValidateRoom(room))
            {
                return(false);
            }

            foreach (var cell in CellCollection.GetByRoom(room.roomId).ToList().Shuffle())
            {
                foreach (var direction in Directionf.Directions())
                {
                    var projection = entity.BuildProjection(cell.position, direction);
                    //Projection cannot clip room cell space
                    if (projection.spaces.Any(x => !CellCollection.HasCellAt(x) || CellCollection.cells[x].roomId != room.roomId))
                    {
                        continue;
                    }

                    //Projection cannot intersect existing projections
                    if (nextContainerInstance.cellPositionsTaken.Any(a => projection.spaces.Contains(a)))
                    {
                        continue;
                    }

                    //Project cannot intersect with existing scaffold claims
                    if (!VerifyProjectionScaffoldDoesntIntersect(projection, entity, room, cell.position, direction, out projectionScaffolds))
                    {
                        continue;
                    }

                    //Projection cannot block navigation through room
                    if (!VerifyProjectionDoesNotBlockRoomPathways(projection))
                    {
                        continue;
                    }

                    //If we made it this far, this projection is valid, we will claim it
                    ClaimProjection(projection, projectionScaffolds, cell, direction, entity);
                    success = true;
                    break;
                }

                if (success)
                {
                    renderContainer = nextContainerInstance;
                    renderContainer.claimedScaffolds.ForEach(x => Level.roomScaffolds[room.roomId].SetNodeClaimed(x.id));
                    RollbackRenderContainer();
                    break; //A claim was found
                }
            }

            return(success);
        }
예제 #3
0
 public void RollbackRenderContainer()
 {
     nextContainerInstance = renderContainer.Copy();
 }