Skip to content

Commit bfb11b0

Browse files
committed
Moved Dimensions to AreaManager
1 parent 907ab40 commit bfb11b0

File tree

6 files changed

+90
-90
lines changed

6 files changed

+90
-90
lines changed

Assets/MapEditor/Editor/API/Functions.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine;
33
using UnityEditor;
44
using RustMapEditor.Variables;
5+
using static AreaManager;
56
using static TerrainManager;
67

78
namespace RustMapEditor.UI
@@ -206,11 +207,11 @@ public static void NormaliseMap(ref float normaliseLow, ref float normaliseHigh,
206207
normaliseLow = Elements.ToolbarSlider(ToolTips.normaliseLow, normaliseLow, 0f, normaliseHigh);
207208
normaliseHigh = Elements.ToolbarSlider(ToolTips.normaliseHigh, normaliseHigh, normaliseLow, 1000f);
208209
if (EditorGUI.EndChangeCheck() && autoUpdate == true)
209-
NormaliseHeightMap(normaliseLow, normaliseHigh, dmns: Dimensions.HeightMapDimensions());
210+
NormaliseHeightMap(normaliseLow, normaliseHigh, dmns: Area.HeightMapDimensions());
210211

211212
Elements.BeginToolbarHorizontal();
212213
if (Elements.ToolbarButton(ToolTips.normaliseMap))
213-
NormaliseHeightMap(normaliseLow, normaliseHigh, dmns: Dimensions.HeightMapDimensions());
214+
NormaliseHeightMap(normaliseLow, normaliseHigh, dmns: Area.HeightMapDimensions());
214215
autoUpdate = Elements.ToolbarToggle(ToolTips.autoUpdateNormalise, autoUpdate);
215216
Elements.EndToolbarHorizontal();
216217
}
@@ -222,9 +223,9 @@ public static void SetHeight(ref float height)
222223
height = Elements.ToolbarSlider(ToolTips.heightToSet, height, 0f, 1000f);
223224
Elements.BeginToolbarHorizontal();
224225
if (Elements.ToolbarButton(ToolTips.setLandHeight))
225-
SetHeightMapHeight(height, dmns: Dimensions.HeightMapDimensions());
226+
SetHeightMapHeight(height, dmns: Area.HeightMapDimensions());
226227
if (Elements.ToolbarButton(ToolTips.setWaterHeight))
227-
SetHeightMapHeight(height, TerrainType.Water, Dimensions.HeightMapDimensions());
228+
SetHeightMapHeight(height, TerrainType.Water, Area.HeightMapDimensions());
228229
Elements.EndToolbarHorizontal();
229230
}
230231

@@ -235,9 +236,9 @@ public static void ClampHeight(ref float heightLow, ref float heightHigh)
235236
Elements.ToolbarMinMax(ToolTips.minHeight, ToolTips.maxHeight, ref heightLow, ref heightHigh, 0f, 1000f);
236237
Elements.BeginToolbarHorizontal();
237238
if (Elements.ToolbarButton(ToolTips.setMinHeight))
238-
ClampHeightMap(heightLow, 1000f, TerrainType.Land, Dimensions.HeightMapDimensions());
239+
ClampHeightMap(heightLow, 1000f, TerrainType.Land, Area.HeightMapDimensions());
239240
if (Elements.ToolbarButton(ToolTips.setMaxHeight))
240-
ClampHeightMap(0f, heightHigh, TerrainType.Land, Dimensions.HeightMapDimensions());
241+
ClampHeightMap(0f, heightHigh, TerrainType.Land, Area.HeightMapDimensions());
241242
Elements.EndToolbarHorizontal();
242243
}
243244

@@ -249,9 +250,9 @@ public static void OffsetMap(ref float offset, ref bool clampOffset)
249250
Elements.BeginToolbarHorizontal();
250251
clampOffset = Elements.ToolbarToggle(ToolTips.clampOffset, clampOffset);
251252
if (Elements.ToolbarButton(ToolTips.offsetLand))
252-
OffsetHeightMap(offset, clampOffset, TerrainType.Land, Dimensions.HeightMapDimensions());
253+
OffsetHeightMap(offset, clampOffset, TerrainType.Land, Area.HeightMapDimensions());
253254
if (Elements.ToolbarButton(ToolTips.offsetWater))
254-
OffsetHeightMap(offset, clampOffset, TerrainType.Water, Dimensions.HeightMapDimensions());
255+
OffsetHeightMap(offset, clampOffset, TerrainType.Water, Area.HeightMapDimensions());
255256
Elements.EndToolbarHorizontal();
256257
}
257258

@@ -261,9 +262,9 @@ public static void InvertMap()
261262

262263
Elements.BeginToolbarHorizontal();
263264
if (Elements.ToolbarButton(ToolTips.invertLand))
264-
InvertHeightMap(dmns: Dimensions.HeightMapDimensions());
265+
InvertHeightMap(dmns: Area.HeightMapDimensions());
265266
if (Elements.ToolbarButton(ToolTips.invertWater))
266-
InvertHeightMap(TerrainType.Water, Dimensions.HeightMapDimensions());
267+
InvertHeightMap(TerrainType.Water, Area.HeightMapDimensions());
267268
Elements.EndToolbarHorizontal();
268269
}
269270
#endregion
@@ -546,8 +547,8 @@ public static void AreaSelect()
546547
{
547548
Elements.MiniBoldLabel(ToolTips.areaSelectLabel);
548549

549-
Elements.ToolbarMinMaxInt(ToolTips.fromZ, ToolTips.toZ, ref AreaManager.Area.z0, ref AreaManager.Area.z1, 0, SplatMapRes);
550-
Elements.ToolbarMinMaxInt(ToolTips.fromX, ToolTips.toX, ref AreaManager.Area.x0, ref AreaManager.Area.x1, 0, SplatMapRes);
550+
Elements.ToolbarMinMaxInt(ToolTips.fromZ, ToolTips.toZ, ref AreaManager.ActiveArea.z0, ref AreaManager.ActiveArea.z1, 0, SplatMapRes);
551+
Elements.ToolbarMinMaxInt(ToolTips.fromX, ToolTips.toX, ref AreaManager.ActiveArea.x0, ref AreaManager.ActiveArea.x1, 0, SplatMapRes);
551552

552553
if (Elements.ToolbarButton(ToolTips.resetArea))
553554
AreaManager.Reset();
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
using RustMapEditor.Variables;
2-
3-
public static class AreaManager
1+
public static class AreaManager
42
{
5-
public static Dimensions Area = new Dimensions(0, 512, 0, 512);
6-
7-
public static bool AreaActive { get; private set; }
3+
/// <summary>The currently active area that paint operations affect.</summary>
4+
public static Area ActiveArea = new Area(0, 512, 0, 512);
85

96
public static void Reset()
107
{
11-
Area = new Dimensions(0, TerrainManager.SplatMapRes, 0, TerrainManager.SplatMapRes);
8+
ActiveArea = new Area(0, TerrainManager.SplatMapRes, 0, TerrainManager.SplatMapRes);
9+
}
10+
11+
public class Area
12+
{
13+
public int x0;
14+
public int x1;
15+
public int z0;
16+
public int z1;
17+
18+
public Area(int x0, int x1, int z0, int z1)
19+
{
20+
this.x0 = x0;
21+
this.x1 = x1;
22+
this.z0 = z0;
23+
this.z1 = z1;
24+
}
25+
26+
public static Area HeightMapDimensions()
27+
{
28+
return new Area(0, TerrainManager.HeightMapRes, 0, TerrainManager.HeightMapRes);
29+
}
1230
}
1331
}

Assets/MapEditor/Managers/TerrainManager.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
using Unity.EditorCoroutines.Editor;
66
using System.Collections;
77
using System.Threading.Tasks;
8-
using RustMapEditor.Variables;
98
using RustMapEditor.Maths;
109
using static WorldConverter;
10+
using static AreaManager;
1111

1212
public static class TerrainManager
1313
{
@@ -359,7 +359,7 @@ public static bool IsValidIndex(int x, int y)
359359

360360
/// <summary>Rotates the HeightMap 90° Clockwise or Counter Clockwise.</summary>
361361
/// <param name="CW">True = 90°, False = 270°</param>
362-
public static void RotateHeightMap(bool CW, TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
362+
public static void RotateHeightMap(bool CW, TerrainType terrain = TerrainType.Land, Area dmns = null)
363363
{
364364
RegisterHeightMapUndo(terrain, "Rotate HeightMap");
365365
if (terrain == TerrainType.Land)
@@ -370,7 +370,7 @@ public static void RotateHeightMap(bool CW, TerrainType terrain = TerrainType.La
370370

371371
/// <summary>Sets the HeightMap to the height input.</summary>
372372
/// <param name="height">The height to set.</param>
373-
public static void SetHeightMapHeight(float height, TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
373+
public static void SetHeightMapHeight(float height, TerrainType terrain = TerrainType.Land, Area dmns = null)
374374
{
375375
height /= 1000f; // Normalises user input to a value between 0 - 1f.
376376
RegisterHeightMapUndo(terrain, "Set HeightMap Height");
@@ -382,7 +382,7 @@ public static void SetHeightMapHeight(float height, TerrainType terrain = Terrai
382382
}
383383

384384
/// <summary>Inverts the HeightMap heights.</summary>
385-
public static void InvertHeightMap(TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
385+
public static void InvertHeightMap(TerrainType terrain = TerrainType.Land, Area dmns = null)
386386
{
387387
RegisterHeightMapUndo(terrain, "Invert HeightMap");
388388
if (terrain == TerrainType.Land)
@@ -394,7 +394,7 @@ public static void InvertHeightMap(TerrainType terrain = TerrainType.Land, Dimen
394394
/// <summary> Normalises the HeightMap between two heights.</summary>
395395
/// <param name="normaliseLow">The lowest height the HeightMap should be.</param>
396396
/// <param name="normaliseHigh">The highest height the HeightMap should be.</param>
397-
public static void NormaliseHeightMap(float normaliseLow, float normaliseHigh, TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
397+
public static void NormaliseHeightMap(float normaliseLow, float normaliseHigh, TerrainType terrain = TerrainType.Land, Area dmns = null)
398398
{
399399
normaliseLow /= 1000f; normaliseHigh /= 1000f; // Normalises user input to a value between 0 - 1f.
400400
RegisterHeightMapUndo(terrain, "Normalise HeightMap");
@@ -408,7 +408,7 @@ public static void NormaliseHeightMap(float normaliseLow, float normaliseHigh, T
408408
/// <summary>Increases or decreases the HeightMap by the offset.</summary>
409409
/// <param name="offset">The amount to offset by. Negative values offset down.</param>
410410
/// <param name="clampOffset">Check if offsetting the HeightMap would exceed the min-max values.</param>
411-
public static void OffsetHeightMap(float offset, bool clampOffset, TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
411+
public static void OffsetHeightMap(float offset, bool clampOffset, TerrainType terrain = TerrainType.Land, Area dmns = null)
412412
{
413413
offset /= 1000f; // Normalises user input to a value between 0 - 1f.
414414
RegisterHeightMapUndo(terrain, "Offset HeightMap");
@@ -422,7 +422,7 @@ public static void OffsetHeightMap(float offset, bool clampOffset, TerrainType t
422422
/// <summary>Sets the HeightMap level to the minimum if it's below.</summary>
423423
/// <param name="minimumHeight">The minimum height to set.</param>
424424
/// <param name="maximumHeight">The maximum height to set.</param>
425-
public static void ClampHeightMap(float minimumHeight, float maximumHeight, TerrainType terrain = TerrainType.Land, Dimensions dmns = null)
425+
public static void ClampHeightMap(float minimumHeight, float maximumHeight, TerrainType terrain = TerrainType.Land, Area dmns = null)
426426
{
427427
minimumHeight /= 1000f; maximumHeight /= 1000f; // Normalises user input to a value between 0 - 1f.
428428
RegisterHeightMapUndo(terrain, "Clamp HeightMap");

0 commit comments

Comments
 (0)