private bool VerifyScaffoldsForPartialSpace(SuiteProjection projection, SuiteEntity entity, LevelRoom room, out List <Scaffold_Node> projectionNodes) { throw new NotImplementedException(); }
private bool VerifyScaffoldsForFullSpace(SuiteProjection projection, SuiteEntity entity, LevelRoom room, Vector3 root, Direction normal, out List <Scaffold_Node> projectionNodes) { projectionNodes = new List <Scaffold_Node>(); var roomScaffold = Level.roomScaffolds[room.roomId]; var projectionSpace = projection.spaces; var projectionCells = CellCollection.cells.Select(s => s.Value).Where(x => projectionSpace.Contains(x.position)); //Floor + Ceiling, both are handled in the same move when not a partial var floor_main = roomScaffold.floor.main.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => floor_main.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(floor_main); var floor_connectors = roomScaffold.floor.connectors.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => floor_connectors.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(floor_connectors); var floor_columns = roomScaffold.floor.columns.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => floor_columns.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(floor_columns); var ceiling_main = roomScaffold.ceiling.main.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => ceiling_main.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(ceiling_main); var ceiling_connectors = roomScaffold.ceiling.connectors.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => ceiling_connectors.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(ceiling_connectors); var ceiling_columns = roomScaffold.ceiling.columns.Where(x => x.rootCells.All(a => projectionCells.Contains(a))); if (nextContainerInstance.claimedScaffolds.Any(a => ceiling_columns.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(ceiling_columns); //Walls var wall_main = new List <Node_WallMain>(); var wall_connector = new List <Node_WallConnector>(); var wallProjections = entity.BuildWallProjection(root, normal); foreach (var wall in wallProjections.spaces) { var direction = (Direction)wall.w; var result = roomScaffold.wall.main.FirstOrDefault(x => x.rootCells.All(a => a.position == (Vector3)wall) && x.direction == direction); if (result == null) { return(false); } wall_main.Add(result); if (nextContainerInstance.claimedScaffolds.Any(a => wall_main.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(wall_main); var result_C = roomScaffold.wall.connectors.FirstOrDefault(x => x.rootCells.All(a => a.position == (Vector3)wall) && x.direction == direction); if (result_C != null) { wall_connector.Add(result_C); } if (nextContainerInstance.claimedScaffolds.Any(a => wall_connector.Select(s => s.id).Contains(a.id))) { return(false); } projectionNodes.AddRange(wall_connector); } //If we got to this point, all scaffold points are available return(true); }
public void ClaimProjection(SuiteProjection projection, List <Scaffold_Node> projectionScaffold, Cell root, Direction direction, SuiteEntity entity) { nextContainerInstance.spaces.AddRange(projection.spaces); nextContainerInstance.claimedScaffolds.AddRange(projectionScaffold); nextContainerInstance.entities.Add(new Tuple <Vector3, Direction>(root.position, direction), entity); }
public bool VerifyProjectionScaffoldDoesntIntersect(SuiteProjection projection, SuiteEntity entity, LevelRoom room, Vector3 root, Direction normal, out List <Scaffold_Node> projectionNodes) { if (entity.partial) { return(VerifyScaffoldsForPartialSpace(projection, entity, room, out projectionNodes)); } return(VerifyScaffoldsForFullSpace(projection, entity, room, root, normal, out projectionNodes)); }
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); }