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); }