//Requested by path builder. Returns the pathed area of the passed BPP. //Used to check changes in areas. //[TODO] Should this also check if it's an exit piece? How to handle that? public PathedArea GetAreaForBuiltPathPiece(BuiltPathPiece bppRef) { for (int i = 0; i < allPathedAreas.Count; i++) { if (allPathedAreas[i].thisPathedArea.thisAreaFormat == AreaFormat.Procedural) { for (int j = 0; j < allPathedAreas[i].allPoolPieces.Count; j++) { if (allPathedAreas[i].allPoolPieces[j] == bppRef) { return(allPathedAreas[i].thisPathedArea); } } } else if (allPathedAreas[i].thisPathedArea.thisAreaFormat == AreaFormat.Fixed) { if (bppRef.transform.parent.gameObject == allPathedAreas[i].thisPathedArea.fixedAreaObject) { return(allPathedAreas[i].thisPathedArea); } } } Debug.LogWarning("Could not find area for requested built path piece"); return(null); }
void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player") { if (isTownTurnArea) { for (int i = 0; i < townConnectedPieces.Count; i++) { townConnectedPieces[i].PrepareArea(transform.position, pRunner.currentMoveDirection); Debug.Log(townConnectedPieces[i].pieceFacingDirection); switch (townConnectedPieces[i].pieceFacingDirection) { case MoveDirection.North: northPiece = townConnectedPieces[i]; break; case MoveDirection.East: eastPiece = townConnectedPieces[i]; break; case MoveDirection.South: southPiece = townConnectedPieces[i]; break; case MoveDirection.West: westPiece = townConnectedPieces[i]; break; } } } else { for (int i = 0; i < proceduralConnectedPieces.Count; i++) { proceduralConnectedPieces[i].PrepareArea(transform.position, pRunner.currentMoveDirection); switch (proceduralConnectedPieces[i].pieceFacingDirection) { case MoveDirection.North: northPiece = proceduralConnectedPieces[i]; break; case MoveDirection.East: eastPiece = proceduralConnectedPieces[i]; break; case MoveDirection.South: southPiece = proceduralConnectedPieces[i]; break; case MoveDirection.West: westPiece = proceduralConnectedPieces[i]; break; } } } pRunner.PrepareTurn(this); } }
IEnumerator DeactivatePieceOnDelay(BuiltPathPiece deactivateBPP, PathedArea pArea) { yield return(new WaitForSeconds(0.5f)); if (pArea.thisAreaFormat == AreaFormat.Procedural) { deactivateBPP.DeactivateToPool(); } else { //Deactivate fixed area pArea.fixedAreaObject.SetActive(false); //Also deactivate any connected areas for (int i = 0; i < pArea.connectionPieces.Count; i++) { PathPoolGroup ppGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == pArea.connectionPieces[i].areaTo); if (ppGroup != null && ppGroup != currentPathPoolGroup) { ppGroup.pathFirstLeftPiece.DeactivateToPool(); ppGroup.pathFirstRightPiece.DeactivateToPool(); } } } }
public void SetupRunner(BuiltPathPiece startingBPP, Transform startingLocation) { currentLane = RunningLane.Mid; currentMoveDirection = MoveDirection.North; transform.position = startingLocation.position; transform.rotation = startingLocation.rotation; currentBPP = startingBPP; }
public BuiltPathPiece GetValidBPPForPathedArea(PathedArea pArea) { //Find the related group PathPoolGroup ppGroup = allPathedAreas.Find(x => x.thisPathedArea == pArea); //Get a random available piece from that group BuiltPathPiece availablePiece = GetProceduralBPPForGroup(ppGroup); //Return the piece return(availablePiece); }
public void PlayerEntersNewPiece(BuiltPathPiece newPieceRef) { Debug.Log("Player enters " + newPieceRef); //Area check //PathedArea pa = ppMan.GetAreaForBuiltPathPiece(newPieceRef); bool enteredNewArea = false; //[TODO] temporary? Will town pieces be BPP? if (currentBPP != null && ((currentPathArea.thisAreaFormat != AreaFormat.Fixed) || (currentPathArea.thisAreaFormat == AreaFormat.Fixed && currentPathProgress == 0))) { ppMan.DeactivatePieces(currentBPP, newPieceRef); } //Current piece is new piece currentBPP = newPieceRef; currentBPP.PlayerOnThisPiece(); currentPathProgress++; //If the player has travelled to a new area for (int i = 0; i < currentPathArea.connectionPieces.Count; i++) { //If it's a connection piece that the player entered, they are moving to a new area if (currentPathArea.connectionPieces[i].thisConnectionPiece == newPieceRef) { #region Area Change enteredNewArea = true; PathedArea newPA = ppMan.GetAreaOfType(currentPathArea.connectionPieces[i].areaTo); PlayerEntersNewArea(newPA); if (currentPathArea.thisAreaFormat == AreaFormat.Fixed) { //Spawn extensions if it's a fixed area BuildExtensionsToFixedArea(); } else if (currentPathArea.thisAreaFormat == AreaFormat.Procedural) { //Otherwise do normal spawning of extensions for procedural area StartOnProceduralPath(); } #endregion } } //If the area remains the same - continue building forward if (enteredNewArea == false) { ContinueProceduralArea(); } }
public void ActivatePathPiece_InConnectedArea(PathedArea pArea, BuiltPathPiece bppRef, bool isLeft, bool isRight) { PathPoolGroup thisGroup = allPathedAreas.Find(x => x.thisPathedArea == pArea); if (isLeft) { thisGroup.pathFirstLeftPiece = bppRef; } else if (isRight) { thisGroup.pathFirstRightPiece = bppRef; } bppRef.ActivateFromPool(); }
public void SetStartingArea(AreaTypes areaType) { currentPathPoolGroup = allPathedAreas.Find(x => x.thisPathedArea.thisAreaType == areaType); if (currentPathPoolGroup == null) { Debug.LogError("Invalid area type set as starting area."); } else { pathBuilder.BuildFixedArea(currentPathPoolGroup); pathBuilder.BuildExtensionsToFixedArea(); currentPathPoolGroup.Fixed_SetupLocalReferences(); currentBuiltPathPiece = currentPathPoolGroup.thisPathedArea.startBPP; } }
Vector3 GetNextPlacementPosition(MoveDirection mDir, Vector3 displacePoint, BuiltPathPiece nextPathPiece) { Vector3 nextPos = Vector3.zero; //[TODO] prob clean up the below based on changes to BPP Vector3 objectScale = nextPathPiece.exitLocations[nextPathPiece.exitLocations.Count - 1].pathTurnLocation.position; northAdd = new Vector3(0f, objectScale.y / 2f, objectScale.x / 2f + objectScale.z / 2f); southAdd = new Vector3(0f, objectScale.y / 2f, -(objectScale.x / 2f + objectScale.z / 2f)); eastAdd = new Vector3(objectScale.x / 2f + objectScale.z / 2f, objectScale.y / 2f, 0f); westAdd = new Vector3(-(objectScale.x / 2f + objectScale.z / 2f), objectScale.y / 2f, 0f); switch (mDir) { case MoveDirection.North: nextPos = displacePoint + northAdd; break; case MoveDirection.East: nextPos = displacePoint + eastAdd; break; case MoveDirection.South: nextPos = displacePoint + southAdd; break; case MoveDirection.West: nextPos = displacePoint + westAdd; break; default: Debug.Log("???"); break; } return(nextPos); }
public void RebuildPath() { thisBPP = gameObject.GetComponent <BuiltPathPiece>(); //pathGeometryParent = transform; for (int i = 0; i < spawnedPathObjects.Count; i++) { //Debug.Log("i"); if (spawnedPathObjects[i] != null) { DestroyImmediate(spawnedPathObjects[i]); } } spawnedPathObjects.Clear(); for (int i = 0; i < spawnedSurfaceObjects.Count; i++) { //Debug.Log("i2"); if (spawnedSurfaceObjects[i] != null) { DestroyImmediate(spawnedSurfaceObjects[i]); } } spawnedSurfaceObjects.Clear(); for (int i = 0; i < spawnedEnvironmentObjects.Count; i++) { //Debug.Log("i2"); if (spawnedEnvironmentObjects[i] != null) { DestroyImmediate(spawnedEnvironmentObjects[i]); } } spawnedEnvironmentObjects.Clear(); placementPosition = Vector3.zero; for (int i = 0; i < chunkPathObjects.Count; i++) { //Debug.Log("Build i"); if (chunkPathObjects[i].thisPathChunkPiece != null) { GameObject g = Instantiate(chunkPathObjects[i].thisPathChunkPiece.gameObject, pathGeometryParent) as GameObject; g.transform.position = placementPosition; spawnedPathObjects.Add(g); } if (surfaceChunkObjects.Count > i) { GameObject surf = null; if (surfaceChunkObjects[i].thisSurfaceChunkPiece != null) { surf = Instantiate(surfaceChunkObjects[i].thisSurfaceChunkPiece.gameObject, surfaceChunkParent) as GameObject; surf.transform.position = placementPosition; surf.GetComponent <SurfaceChunk>().SpawnAllResourceNodes(); } spawnedSurfaceObjects.Add(surf); } if (enviroChunkObjects.Count > i) { GameObject enviro = null; if (enviroChunkObjects[i].thisEnviroChunk != null) { enviro = Instantiate(enviroChunkObjects[i].thisEnviroChunk.gameObject, environmentChunkParent) as GameObject; enviro.transform.position = placementPosition; enviro.GetComponent <EnvironmentChunk>().SpawnEnvironmentPieces(); } spawnedEnvironmentObjects.Add(enviro); } //move position forward placementPosition += chunkPathObjects[i].thisPathChunkPiece.endRelativeToStart; //Equal to end point } //turnPiece.transform.position = placementPosition; if (pathEndChunk != null) { GameObject e = Instantiate(pathEndChunk.gameObject, environmentChunkParent) as GameObject; e.transform.position = placementPosition; //Cap to end of turn piece e.GetComponent <EnvironmentChunk>().SpawnEnvironmentPieces(); spawnedEnvironmentObjects.Add(e); } //Set up BPP as required thisBPP.exitLocations.Clear(); for (int i = 0; i < spawnedPathObjects.Count; i++) { PathChunkPiece pcp = spawnedPathObjects[i].GetComponent <PathChunkPiece>(); if (pcp != null) { if (pcp.isTurnArea == true) { if (thisBPP.exitLocations.Exists(x => x.pathTurnLocation == spawnedPathObjects[i].transform) == false) { PathTurnConditions ptc = new PathTurnConditions(); ptc.connectedTurnTriggerArea = spawnedPathObjects[i].GetComponentInChildren <TurnTriggerArea>(); ptc.pathTurnLocation = spawnedPathObjects[i].transform; thisBPP.exitLocations.Add(ptc); } } } } }
public void BuildExtensionsForBPP(BuiltPathPiece bpp) { //For each exit location for (int i = 0; i < bpp.exitLocations.Count; i++) { //Spawn a left if (bpp.exitLocations[i].canDoLeft) { //Spawn a right piece for this pathed area BuiltPathPiece leftPiece = ppMan.GetValidBPPForPathedArea(currentPathArea); //Position and rotate accordingly leftPiece.intendedMoveDirection = GetLeftMoveDirection(bpp.intendedMoveDirection); leftPiece.transform.position = GetNextPlacementPosition(leftPiece.intendedMoveDirection, bpp.exitLocations[i].pathTurnLocation.position, leftPiece); leftPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(leftPiece.intendedMoveDirection); bpp.exitLocations[i].nextLeftPathPiece = leftPiece; switch (leftPiece.intendedMoveDirection) { case MoveDirection.North: bpp.exitLocations[i].connectedTurnTriggerArea.northPiece = leftPiece; break; case MoveDirection.East: bpp.exitLocations[i].connectedTurnTriggerArea.eastPiece = leftPiece; break; case MoveDirection.South: bpp.exitLocations[i].connectedTurnTriggerArea.southPiece = leftPiece; break; case MoveDirection.West: bpp.exitLocations[i].connectedTurnTriggerArea.westPiece = leftPiece; break; } //Activate piece //[TODO] next version ppMan.ActivatePathPiece_InCurrentArea(leftPiece); } //Spawn a right if (bpp.exitLocations[i].canDoRight) { //Spawn a right piece for this pathed area BuiltPathPiece rightPiece = ppMan.GetValidBPPForPathedArea(currentPathArea); //Position and rotate accordingly rightPiece.intendedMoveDirection = GetRightMoveDirection(bpp.intendedMoveDirection); rightPiece.transform.position = GetNextPlacementPosition(rightPiece.intendedMoveDirection, bpp.exitLocations[i].pathTurnLocation.position, rightPiece); rightPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(rightPiece.intendedMoveDirection); bpp.exitLocations[i].nextRightPathPiece = rightPiece; switch (rightPiece.intendedMoveDirection) { case MoveDirection.North: bpp.exitLocations[i].connectedTurnTriggerArea.northPiece = rightPiece; break; case MoveDirection.East: bpp.exitLocations[i].connectedTurnTriggerArea.eastPiece = rightPiece; break; case MoveDirection.South: bpp.exitLocations[i].connectedTurnTriggerArea.southPiece = rightPiece; break; case MoveDirection.West: bpp.exitLocations[i].connectedTurnTriggerArea.westPiece = rightPiece; break; } //Activate piece //[TODO] next version ppMan.ActivatePathPiece_InCurrentArea(rightPiece); } } }
void PositionFixedArea(BuiltPathPiece exitPiece, PathedArea fixedArea) { //Get entrance area to align FixedAreaEntrances entranceArea = fixedArea.GetFixedAreaEntranceForAreaType(currentPathArea.thisAreaType); //"Place" entrance piece going left //entranceArea.connectedEntrancePathPiece.intendedMoveDirection = GetLeftMoveDirection(exitPiece.intendedMoveDirection); //Piece should go straight ahead entranceArea.connectedEntrancePathPiece.intendedMoveDirection = exitPiece.intendedMoveDirection; Vector3 exitPosition = GetNextPlacementPosition(entranceArea.connectedEntrancePathPiece.intendedMoveDirection, exitPiece.exitLocations[0].pathTurnLocation.position, entranceArea.connectedEntrancePathPiece); //Get rotation where "intended direction" compares to "entrance direction" int directionDiff = (int)entranceArea.connectedEntrancePathPiece.intendedMoveDirection - (int)entranceArea.entranceDirection; directionDiff++; //Because north is 1 if (directionDiff < 1) { directionDiff += 4; } else if (directionDiff > 4) { directionDiff -= 4; } MoveDirection directionDiffDir = (MoveDirection)directionDiff; Vector3 fixedEul = Vector3.zero; Vector3 newFixedAreaPos = Vector3.zero; switch (directionDiffDir) { case MoveDirection.West: fixedEul.y = 270f; break; case MoveDirection.South: fixedEul.y = 180f; break; case MoveDirection.East: fixedEul.y = 90f; break; //exit and move are same case MoveDirection.North: fixedEul.y = 0f; break; } //Update fixed area connection piece directions to work with new rotation for (int i = 0; i < fixedArea.connectionPieces.Count; i++) { int moveDirChange = (int)fixedArea.connectionPieces[i].originalPieceDirection + directionDiff; moveDirChange--; //Because north is 1 if (moveDirChange > 4) { moveDirChange -= 4; } fixedArea.connectionPieces[i].connectionPieceDirection = (MoveDirection)moveDirChange; } Debug.Log(exitPiece.intendedMoveDirection + " " + entranceArea.connectedEntrancePathPiece.intendedMoveDirection + " " + entranceArea.entranceDirection + " " + directionDiffDir); //Adjust town based on entrance fixedArea.fixedAreaObject.transform.eulerAngles = fixedEul; //Get original settings of entrancePiece to fixedArea Vector3 pieceOffset = entranceArea.connectedEntrancePathPiece.transform.position - fixedArea.fixedAreaObject.transform.position; //entranceArea.connectedEntrancePathPiece.transform.position = exitPosition; newFixedAreaPos = exitPosition - pieceOffset; Debug.Log(exitPosition + " " + pieceOffset + " " + newFixedAreaPos); fixedArea.fixedAreaObject.transform.position = newFixedAreaPos; fixedArea.fixedAreaObject.SetActive(true); exitPiece.exitLocations[0].connectedFixedArea = fixedArea; }
//[TODO] Extension code could probably / definitely be cleaned up (duplicates) //Procedural version of the above void BuildConnectionsToConnectedArea(PathConnectionPiece connectionPiece) { PathedArea connectedPathArea = ppMan.GetAreaOfType(connectionPiece.areaTo); //Move fixed areas accordingly if (connectedPathArea.thisAreaFormat == AreaFormat.Fixed) { //[TODO] properly reposition PositionFixedArea(connectionPiece.thisConnectionPiece, connectedPathArea); } //OR spawn extensions of next procedural area else { //Get Exit Location ref BuiltPathPiece extensionBPP = connectionPiece.thisConnectionPiece; //Get position for pieces to be placed Vector3 exitPosition = extensionBPP.exitLocations[0].pathTurnLocation.position; if (extensionBPP.exitLocations[0].canDoLeft) { //Spawn a left piece for this pathed area BuiltPathPiece leftPiece = ppMan.GetValidBPPForAreaType(connectionPiece.areaTo); //Position and rotate accordingly leftPiece.intendedMoveDirection = GetLeftMoveDirection(connectionPiece.connectionPieceDirection); leftPiece.transform.position = GetNextPlacementPosition(leftPiece.intendedMoveDirection, exitPosition, leftPiece); leftPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(leftPiece.intendedMoveDirection); extensionBPP.exitLocations[0].nextLeftPathPiece = leftPiece; switch (leftPiece.intendedMoveDirection) { case MoveDirection.North: extensionBPP.exitLocations[0].connectedTurnTriggerArea.northPiece = leftPiece; break; case MoveDirection.East: extensionBPP.exitLocations[0].connectedTurnTriggerArea.eastPiece = leftPiece; break; case MoveDirection.South: extensionBPP.exitLocations[0].connectedTurnTriggerArea.southPiece = leftPiece; break; case MoveDirection.West: extensionBPP.exitLocations[0].connectedTurnTriggerArea.westPiece = leftPiece; break; } //Activate piece ppMan.ActivatePathPiece_InConnectedArea(connectedPathArea, leftPiece, true, false); } if (extensionBPP.exitLocations[0].canDoRight) { //Spawn a right piece for this pathed area BuiltPathPiece rightPiece = ppMan.GetValidBPPForAreaType(connectionPiece.areaTo); //Position and rotate accordingly rightPiece.intendedMoveDirection = GetRightMoveDirection(connectionPiece.connectionPieceDirection); rightPiece.transform.position = GetNextPlacementPosition(rightPiece.intendedMoveDirection, exitPosition, rightPiece); rightPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(rightPiece.intendedMoveDirection); extensionBPP.exitLocations[0].nextRightPathPiece = rightPiece; switch (rightPiece.intendedMoveDirection) { case MoveDirection.North: extensionBPP.exitLocations[0].connectedTurnTriggerArea.northPiece = rightPiece; break; case MoveDirection.East: extensionBPP.exitLocations[0].connectedTurnTriggerArea.eastPiece = rightPiece; break; case MoveDirection.South: extensionBPP.exitLocations[0].connectedTurnTriggerArea.southPiece = rightPiece; break; case MoveDirection.West: extensionBPP.exitLocations[0].connectedTurnTriggerArea.westPiece = rightPiece; break; } //Activate piece ppMan.ActivatePathPiece_InConnectedArea(connectedPathArea, rightPiece, false, true); } } }
public void ActivatePathPiece_InCurrentArea(BuiltPathPiece bppRef) { bppRef.ActivateFromPool(); }
//Must be current area public void BuildExtensionsToFixedArea() { Debug.Log("Build fixed area extensions"); for (int i = 0; i < currentPathArea.connectionPieces.Count; i++) { PathedArea connectedPathArea = ppMan.GetAreaOfType(currentPathArea.connectionPieces[i].areaTo); Debug.Log("Build extensions for " + connectedPathArea.thisAreaType); //For each connection exit piece //Get Exit Location ref BuiltPathPiece extensionBPP = currentPathArea.connectionPieces[i].thisConnectionPiece; //Get position for pieces to be placed Vector3 exitPosition = extensionBPP.exitLocations[0].pathTurnLocation.position; if (extensionBPP.exitLocations[0].canDoLeft) { //Spawn a left piece for this pathed area BuiltPathPiece leftPiece = ppMan.GetValidBPPForAreaType(currentPathArea.connectionPieces[i].areaTo); //Position and rotate accordingly leftPiece.intendedMoveDirection = GetLeftMoveDirection(currentPathArea.connectionPieces[i].connectionPieceDirection); leftPiece.transform.position = GetNextPlacementPosition(leftPiece.intendedMoveDirection, exitPosition, leftPiece); leftPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(leftPiece.intendedMoveDirection); extensionBPP.exitLocations[0].nextLeftPathPiece = leftPiece; switch (leftPiece.intendedMoveDirection) { case MoveDirection.North: extensionBPP.exitLocations[0].connectedTurnTriggerArea.northPiece = leftPiece; break; case MoveDirection.East: extensionBPP.exitLocations[0].connectedTurnTriggerArea.eastPiece = leftPiece; break; case MoveDirection.South: extensionBPP.exitLocations[0].connectedTurnTriggerArea.southPiece = leftPiece; break; case MoveDirection.West: extensionBPP.exitLocations[0].connectedTurnTriggerArea.westPiece = leftPiece; break; } //Activate piece ppMan.ActivatePathPiece_InConnectedArea(connectedPathArea, leftPiece, true, false); } if (extensionBPP.exitLocations[0].canDoRight) { //Spawn a right piece for this pathed area BuiltPathPiece rightPiece = ppMan.GetValidBPPForAreaType(currentPathArea.connectionPieces[i].areaTo); //Position and rotate accordingly rightPiece.intendedMoveDirection = GetRightMoveDirection(currentPathArea.connectionPieces[i].connectionPieceDirection); rightPiece.transform.position = GetNextPlacementPosition(rightPiece.intendedMoveDirection, exitPosition, rightPiece); rightPiece.transform.eulerAngles = GetEulerAnglesForMoveDirection(rightPiece.intendedMoveDirection); extensionBPP.exitLocations[0].nextRightPathPiece = rightPiece; switch (rightPiece.intendedMoveDirection) { case MoveDirection.North: extensionBPP.exitLocations[0].connectedTurnTriggerArea.northPiece = rightPiece; break; case MoveDirection.East: extensionBPP.exitLocations[0].connectedTurnTriggerArea.eastPiece = rightPiece; break; case MoveDirection.South: extensionBPP.exitLocations[0].connectedTurnTriggerArea.southPiece = rightPiece; break; case MoveDirection.West: extensionBPP.exitLocations[0].connectedTurnTriggerArea.westPiece = rightPiece; break; } //Activate piece ppMan.ActivatePathPiece_InConnectedArea(connectedPathArea, rightPiece, false, true); } } }
public PathConnectionPiece GetConnectionPieceOfBPP(BuiltPathPiece bppRef) { return(connectionPieces.Find(x => x.thisConnectionPiece == bppRef)); }
//[TODO] deactivate from pool for recycling public void DeactivatePieces(BuiltPathPiece lastPiece, BuiltPathPiece currentPiece) { Debug.Log("Deactivate pieces"); //Deactivate last piece on delay PathedArea lastPA = GetAreaForBuiltPathPiece(lastPiece); StartCoroutine(DeactivatePieceOnDelay(lastPiece, lastPA)); //Deactivate alternate piece on delay //Deactivate non alternate exits, and children, instantly for (int i = 0; i < lastPiece.exitLocations.Count; i++) { //If player did not turn left here, disable it if (lastPiece.exitLocations[i].nextLeftPathPiece != currentPiece && lastPiece.exitLocations[i].nextLeftPathPiece != null) { PathedArea altPA = GetAreaForBuiltPathPiece(lastPiece.exitLocations[i].nextLeftPathPiece); if (altPA.thisAreaFormat == AreaFormat.Procedural) { lastPiece.exitLocations[i].nextLeftPathPiece.DeactivateToPool(); for (int j = 0; j < lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations.Count; j++) { if (lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].nextLeftPathPiece != null) { lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].nextLeftPathPiece.DeactivateToPool(); } if (lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].nextRightPathPiece != null) { lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].nextRightPathPiece.DeactivateToPool(); } if (lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].connectedFixedArea.fixedAreaObject != null) { lastPiece.exitLocations[i].nextLeftPathPiece.exitLocations[j].connectedFixedArea.fixedAreaObject.SetActive(false); } } } else { altPA.fixedAreaObject.SetActive(false); } } //If player did not turn right here, disable it if (lastPiece.exitLocations[i].nextRightPathPiece != currentPiece && lastPiece.exitLocations[i].nextRightPathPiece != null) { PathedArea altPA = GetAreaForBuiltPathPiece(lastPiece.exitLocations[i].nextRightPathPiece); if (altPA.thisAreaFormat == AreaFormat.Procedural) { lastPiece.exitLocations[i].nextRightPathPiece.DeactivateToPool(); for (int j = 0; j < lastPiece.exitLocations[i].nextRightPathPiece.exitLocations.Count; j++) { if (lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].nextLeftPathPiece != null) { lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].nextLeftPathPiece.DeactivateToPool(); } if (lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].nextRightPathPiece != null) { lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].nextRightPathPiece.DeactivateToPool(); } if (lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].connectedFixedArea.fixedAreaObject != null) { lastPiece.exitLocations[i].nextRightPathPiece.exitLocations[j].connectedFixedArea.fixedAreaObject.SetActive(false); } } } else { altPA.fixedAreaObject.SetActive(false); } } } }