// // // stairs // // /// <summary> /// Builds a new stair /// </summary> /// <param name="loc"></param> /// <param name="test">true to just check if it can be built.</param> /// <returns>true if it was/can be built.</returns> private bool createStair(Location loc, bool test) { ThinPlatform.RailRoadImpl rr = ThinPlatform.RailRoadImpl.get(loc); if (rr == null) { return(false); } ThinPlatform.RailRoadImpl nrr, prr; nrr = ThinPlatform.RailRoadImpl.get(loc + rr.direction); prr = ThinPlatform.RailRoadImpl.get(loc - rr.direction); if (nrr != null && nrr.outlook is ThinPlatform.PassagewayPlatform) { // TODO correctly compute the roof if (!test) { rr.outlook = new ThinPlatform.StairPlatform(true); } return(true); } if (prr != null && prr.outlook is ThinPlatform.PassagewayPlatform) { // TODO correctly compute the roof if (!test) { rr.outlook = new ThinPlatform.StairPlatform(false); } return(true); } return(false); }
private static bool canBuildPassageway(Location loc1, Location loc2) { if (loc1 == loc2) { return(false); } Direction dd = loc1.getDirectionTo(loc2); // direction Debug.Assert(dd.isSharp); while (true) { ThinPlatform.RailRoadImpl rr = ThinPlatform.RailRoadImpl.get(loc1); if (World.world[loc1] == null || // unused voxel == can be used in any way (rr != null && Direction.angle(rr.direction, dd) == 2)) // orthogonal platform. { if (loc1 == loc2) { return(true); // all voxels satisfy the constraint } loc1 = loc1.toward(loc2); continue; } return(false); // otherwise fail } }
// remove any passageway private static void removePassageway(Location loc1, Location loc2) { // on each voxel along the way for (Location loc = loc1; ; loc = loc.toward(loc2)) { TrafficVoxel tv = TrafficVoxel.get(loc); if (tv != null && tv.railRoad is ThinPlatform.RailRoadImpl) { ThinPlatform.RailRoadImpl rr = (ThinPlatform.RailRoadImpl)tv.railRoad; if (rr.outlook is ThinPlatform.PassagewayPlatform) { // retore the normal platform. rr.outlook = ThinPlatform.plainPlatform; } } else { // TODO: open-ended bridge } if (loc == loc2) { // TODO: correctly updated voxels World.world.onAllVoxelUpdated(); return; } } }
private void removeStair(Location loc) { ThinPlatform.RailRoadImpl rr = ThinPlatform.RailRoadImpl.get(loc); if (rr != null && rr.outlook is ThinPlatform.StairPlatform) { rr.outlook = ThinPlatform.plainPlatform; } }
private static void buildPassageway(Location loc1, Location loc2) { Direction dd = loc1.getDirectionTo(loc2); // direction Debug.Assert(dd.isSharp); // on each voxel along the way for (Location loc = loc1; ; loc = loc.toward(loc2)) { TrafficVoxel tv = TrafficVoxel.get(loc); if (tv != null) { if (tv.railRoad is ThinPlatform.RailRoadImpl) { ThinPlatform.RailRoadImpl rr = (ThinPlatform.RailRoadImpl)tv.railRoad; if (rr.outlook is ThinPlatform.PassagewayPlatform) { ThinPlatform.PassagewayPlatform ppp = (ThinPlatform.PassagewayPlatform)rr.outlook; if (ppp.hasBridge) { // if the passageway always has a bridge, keep it. } else { // if it has a partial passageway, make a bridge for it. rr.outlook = new ThinPlatform.PassagewayPlatform(true); } } else { // leave the end un-bridged. rr.outlook = new ThinPlatform.PassagewayPlatform( !((loc == loc1) && (dd.right90 == rr.direction) || (loc == loc2) && (dd.left90 == rr.direction))); } } else { // TODO: open-ended bridge } } else { // TODO: allow passageway to go over unused grounds } if (loc == loc2) { return; } } }