private float GetRandomFloat() { return(OriginCell.GetLocalRandomFloat(EstablishmentDate, _rngOffset++)); }
public TerrainCell ChooseNextDepthSeaCell(TerrainCell currentCell, int rngOffset, out Direction direction) { Direction newDirection = _traverseDirection; float newOffset = _currentDirectionOffset; float rngOutput = FirstCell.GetLocalRandomFloat(CreationDate, RngOffsets.ROUTE_CHOOSE_NEXT_DEPTH_SEA_CELL + rngOffset); //#if DEBUG // string debugLog = "ChooseNextDepthSeaCell: rng=" + rngOutput + // ", _traverseDirection=" + _traverseDirection + // ", _currentDirectionOffset=" + _currentDirectionOffset; //#endif float deviation = 2 * rngOutput - 1; deviation = (deviation * deviation + 1f) / 2f; deviation = newOffset - deviation; if (deviation >= 0.5f) { newDirection = (Direction)(((int)_traverseDirection + 1) % 8); } else if (deviation < -0.5f) { newDirection = (Direction)(((int)_traverseDirection + 6) % 8); } else if (deviation < 0) { newDirection = (Direction)(((int)_traverseDirection + 7) % 8); } TerrainCell nextCell = currentCell.GetNeighborCell(newDirection); direction = newDirection; //#if DEBUG // if ((Manager.RegisterDebugEvent != null) && (Manager.TracingData.Priority <= 0)) // { // if ((FirstCell.Longitude == Manager.TracingData.Longitude) && (FirstCell.Latitude == Manager.TracingData.Latitude)) // { // string cellPos = "Position: Long:" + FirstCell.Longitude + "|Lat:" + FirstCell.Latitude; // string nextCellDesc = "Null"; // if (nextCell != null) // { // nextCellDesc = "Position: Long:" + nextCell.Longitude + "|Lat:" + nextCell.Latitude; // } // SaveLoadTest.DebugMessage debugMessage = new SaveLoadTest.DebugMessage( // "ChooseNextDepthSeaCell - FirstCell:" + cellPos, // "CurrentDate: " + World.CurrentDate + // ", deviation: " + deviation + // ", nextCell: " + nextCellDesc + // ""); // Manager.RegisterDebugEvent("DebugMessage", debugMessage); // } // } //#endif if (nextCell == null) { //#if DEBUG // DebugLogs.Add(debugLog); //#endif return(null); } if (Cells.Contains(nextCell)) { //#if DEBUG // DebugLogs.Add(debugLog); //#endif return(null); } if (nextCell.IsPartOfCoastline) { _currentCoastPreference += CoastPreferenceIncrement; _currentEndRoutePreference += 0.1f; _isTraversingSea = false; } //#if DEBUG // debugLog += ", _currentCoastPreference=" + _currentCoastPreference + // ", _currentEndRoutePreference=" + _currentEndRoutePreference; // DebugLogs.Add(debugLog); //#endif return(nextCell); }