public void FreezeThawAndDepositSnow(TerrainChunk chunk) { Terrain terrain = SubsystemTerrain.Terrain; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { if (m_random.Int() % 2 == 0) { continue; } int topHeightFast = chunk.GetTopHeightFast(i, j); int cellValueFast = chunk.GetCellValueFast(i, topHeightFast, j); int num = Terrain.ExtractContents(cellValueFast); int num2 = chunk.Origin.X + i; int num3 = topHeightFast; int num4 = chunk.Origin.Y + j; PrecipitationShaftInfo precipitationShaftInfo = GetPrecipitationShaftInfo(num2, num4); if (precipitationShaftInfo.Type == PrecipitationType.Snow) { if (num == 18) { int cellContents = terrain.GetCellContents(num2 + 1, num3, num4); int cellContents2 = terrain.GetCellContents(num2 - 1, num3, num4); int cellContents3 = terrain.GetCellContents(num2, num3, num4 - 1); int cellContents4 = terrain.GetCellContents(num2, num3, num4 + 1); bool num5 = cellContents != 18 && cellContents != 0; bool flag = cellContents2 != 18 && cellContents2 != 0; bool flag2 = cellContents3 != 18 && cellContents3 != 0; bool flag3 = cellContents4 != 18 && cellContents4 != 0; if (num5 | flag | flag2 | flag3) { SubsystemTerrain.ChangeCell(num2, num3, num4, Terrain.MakeBlockValue(62)); } } else if (precipitationShaftInfo.Intensity > 0.5f && SubsystemSnowBlockBehavior.CanSupportSnow(cellValueFast) && (num != 62 || ShaftHasSnowOnIce(num2, num4)) && num3 + 1 < 255) { SubsystemTerrain.ChangeCell(num2, num3 + 1, num4, Terrain.MakeBlockValue(61)); } } else { switch (num) { case 61: SubsystemTerrain.DestroyCell(0, num2, num3, num4, 0, noDrop: true, noParticleSystem: true); break; case 62: SubsystemTerrain.DestroyCell(0, num2, num3, num4, 0, noDrop: false, noParticleSystem: true); break; } } } } }
public void PaintFastAvoidWater(TerrainChunk chunk, int x, int y, int z) { Terrain terrain = chunk.Terrain; x -= chunk.Origin.X; z -= chunk.Origin.Y; Cell[] cells = Cells; for (int i = 0; i < cells.Length; i++) { Cell cell = cells[i]; int num = cell.X + x; int num2 = cell.Y + y; int num3 = cell.Z + z; if (num >= 0 && num < 16 && num2 >= 0 && num2 < 255 && num3 >= 0 && num3 < 16) { int num4 = num + chunk.Origin.X; int y2 = num2; int num5 = num3 + chunk.Origin.Y; if (chunk.GetCellContentsFast(num, num2, num3) != 18 && terrain.GetCellContents(num4 - 1, y2, num5) != 18 && terrain.GetCellContents(num4 + 1, y2, num5) != 18 && terrain.GetCellContents(num4, y2, num5 - 1) != 18 && terrain.GetCellContents(num4, y2, num5 + 1) != 18 && chunk.GetCellContentsFast(num, num2 + 1, num3) != 18) { chunk.SetCellValueFast(num, num2, num3, cell.Value); } } } }
public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) { base.OnNeighborBlockChanged(x, y, z, neighborX, neighborY, neighborZ); WorldSettings worldSettings = m_subsystemGameInfo.WorldSettings; if (worldSettings.EnvironmentBehaviorMode == EnvironmentBehaviorMode.Living && y > 0 && y > worldSettings.TerrainLevel + worldSettings.SeaLevelOffset && (neighborX != x || neighborY != y || neighborZ != z)) { Terrain terrain = SubsystemTerrain.Terrain; if (BlocksManager.Blocks[terrain.GetCellContents(x, y - 1, z)].IsFluidBlocker || BlocksManager.Blocks[terrain.GetCellContents(x, y - 1, z)].IsFluidBlocker) { return; } int i = y; while (i < 128 && Terrain.ExtractContents(terrain.GetCellValue(x, i, z)) == 18) { i++; } SubsystemTerrain.DestroyCell(0, x, i - 1, z, 0, false, false); } }
public void ProcessModifiedCells() { m_modifiedList.Clear(); foreach (Point3 key in m_modifiedCells.Keys) { m_modifiedList.Add(key); } m_modifiedCells.Clear(); for (int i = 0; i < m_modifiedList.Count; i++) { Point3 point = m_modifiedList.Array[i]; for (int j = 0; j < m_neighborOffsets.Length; j++) { Point3 point2 = m_neighborOffsets[j]; int cellContents = Terrain.GetCellContents(point.X + point2.X, point.Y + point2.Y, point.Z + point2.Z); SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(cellContents); for (int k = 0; k < blockBehaviors.Length; k++) { blockBehaviors[k].OnNeighborBlockChanged(point.X + point2.X, point.Y + point2.Y, point.Z + point2.Z, point.X, point.Y, point.Z); } } } }
public void PaintFastAvoidWater(Terrain terrain, int x, int y, int z, int minX, int maxX, int minY, int maxY, int minZ, int maxZ) { Cell[] cells = Cells; for (int i = 0; i < cells.Length; i++) { Cell cell = cells[i]; int num = cell.X + x; int num2 = cell.Y + y; int num3 = cell.Z + z; if (num >= minX && num < maxX && num2 >= minY && num2 < maxY && num3 >= minZ && num3 < maxZ && terrain.GetCellContentsFast(num, num2, num3) != 18 && terrain.GetCellContents(num - 1, num2, num3) != 18 && terrain.GetCellContents(num + 1, num2, num3) != 18 && terrain.GetCellContents(num, num2, num3 - 1) != 18 && terrain.GetCellContents(num, num2, num3 + 1) != 18 && terrain.GetCellContentsFast(num, num2 + 1, num3) != 18) { terrain.SetCellValueFast(num, num2, num3, cell.Value); } } }
public static bool IsBottomPart(Terrain terrain, int x, int y, int z) { return(BlocksManager.Blocks[terrain.GetCellContents(x, y + 1, z)] is DoorBlock); }