/// <summary> /// Terraform (raise, lower, etc) an area or whole parcel of land /// </summary> /// <param name="simulator">Simulator land area is in.</param> /// <param name="localID">LocalID of parcel, or -1 if using bounding box</param> /// <param name="west">west border of area to modify</param> /// <param name="south">south border of area to modify</param> /// <param name="east">east border of area to modify</param> /// <param name="north">north border of area to modify</param> /// <param name="action">From Enum, Raise, Lower, Level, Smooth, Etc.</param> /// <param name="brushSize">Size of area to modify</param> /// <param name="seconds">How many meters + or - to lower, 1 = 1 meter</param> /// <returns>true on successful request sent.</returns> /// <remarks>Settings.STORE_LAND_PATCHES must be true, /// Parcel information must be downloaded using <code>RequestAllSimParcels()</code></remarks> public bool Terraform(Simulator simulator, int localID, float west, float south, float east, float north, TerraformAction action, TerraformBrushSize brushSize, int seconds) { float height = 0f; int x, y; if (localID == -1) { x = (int)east - (int)west / 2; y = (int)north - (int)south / 2; } else { Parcel p; if (!simulator.Parcels.TryGetValue(localID, out p)) { Logger.Log(String.Format("Can't find parcel {0} in simulator {1}", localID, simulator), Helpers.LogLevel.Warning, Client); return false; } x = (int)p.AABBMax.X - (int)p.AABBMin.X / 2; y = (int)p.AABBMax.Y - (int)p.AABBMin.Y / 2; } if (!simulator.TerrainHeightAtPoint(x, y, out height)) { Logger.Log("Land Patch not stored for location", Helpers.LogLevel.Warning, Client); return false; } Terraform(simulator, localID, west, south, east, north, action, brushSize, seconds, height); return true; }
private static void SaveTerrainStream(Stream s, Simulator sim) { BinaryWriter bs = new BinaryWriter(s); int y; for (y = 0; y < 256; y++) { int x; for (x = 0; x < 256; x++) { float height; sim.TerrainHeightAtPoint(x, y, out height); bs.Write(height); } } bs.Close(); }