public clsViewInfo(clsMap Map, ctrlMapView MapView) { this.Map = Map; this.MapView = MapView; this.ViewPos = new modMath.sXYZ_int(0, 0xc00, 0); this.FOV_Multiplier_Set(modSettings.Settings.FOVDefault); this.ViewAngleSetToDefault(); modMath.sXY_int horizontal = new modMath.sXY_int((int) Math.Round((double) (((double) (Map.Terrain.TileSize.X * 0x80)) / 2.0)), (int) Math.Round((double) (((double) (Map.Terrain.TileSize.Y * 0x80)) / 2.0))); this.LookAtPos(horizontal); }
public void MouseDown(MouseEventArgs e) { modMath.sXY_int _int; this.Map.SuppressMinimap = true; _int.X = e.X; _int.Y = e.Y; if (e.Button == MouseButtons.Left) { this.MouseLeftDown = new clsMouseDown(); if (this.IsViewPosOverMinimap(_int)) { this.MouseLeftDown.OverMinimap = new clsMouseDown.clsOverMinimap(); this.MouseLeftDown.OverMinimap.DownPos = _int; modMath.sXY_int tileNum = new modMath.sXY_int((int) Math.Round(Conversion.Int((double) (_int.X * this.Tiles_Per_Minimap_Pixel))), (int) Math.Round(Conversion.Int((double) (_int.Y * this.Tiles_Per_Minimap_Pixel)))); this.Map.TileNumClampToMap(tileNum); this.LookAtTile(tileNum); } else { clsMouseOver.clsOverTerrain mouseOverTerrain = this.GetMouseOverTerrain(); if (mouseOverTerrain != null) { this.MouseLeftDown.OverTerrain = new clsMouseDown.clsOverTerrain(); this.MouseLeftDown.OverTerrain.DownPos = mouseOverTerrain.Pos; if (modTools.Tool == modTools.Tools.ObjectSelect) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { if (mouseOverTerrain.Units.Count > 0) { if (mouseOverTerrain.Units.Count == 1) { modMain.frmMainInstance.ObjectPicker(mouseOverTerrain.Units[0].Type); } else { this.MapView.ListSelectBegin(true); } } } else if (modControls.KeyboardProfile.Active(modControls.Control_ScriptPosition)) { clsMap.clsScriptPosition position = clsMap.clsScriptPosition.Create(this.Map); if (position != null) { position.PosX = this.MouseLeftDown.OverTerrain.DownPos.Horizontal.X; position.PosY = this.MouseLeftDown.OverTerrain.DownPos.Horizontal.Y; modMain.frmMainInstance.ScriptMarkerLists_Update(); } } else { if (!modControls.KeyboardProfile.Active(modControls.Control_Unit_Multiselect)) { this.Map.SelectedUnits.Clear(); } modMain.frmMainInstance.SelectedObject_Changed(); this.Map.Unit_Selected_Area_VertexA = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal); this.MapView.DrawViewLater(); } } else if (modTools.Tool == modTools.Tools.TerrainBrush) { if (this.Map.Tileset != null) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { modMain.frmMainInstance.TerrainPicker(); } else { this.Apply_Terrain(); if (modMain.frmMainInstance.cbxAutoTexSetHeight.Checked) { this.Apply_Height_Set(modProgram.TerrainBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]); } } } } else if (modTools.Tool == modTools.Tools.HeightSetBrush) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { modMain.frmMainInstance.HeightPickerL(); } else { this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]); } } else if (modTools.Tool == modTools.Tools.TextureBrush) { if (this.Map.Tileset != null) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { modMain.frmMainInstance.TexturePicker(); } else { this.Apply_Texture(); } } } else if (modTools.Tool == modTools.Tools.CliffTriangle) { this.Apply_CliffTriangle(false); } else if (modTools.Tool == modTools.Tools.CliffBrush) { this.Apply_Cliff(); } else if (modTools.Tool == modTools.Tools.CliffRemove) { this.Apply_Cliff_Remove(); } else if (modTools.Tool == modTools.Tools.TerrainFill) { if (this.Map.Tileset != null) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { modMain.frmMainInstance.TerrainPicker(); } else { this.Apply_Terrain_Fill(modMain.frmMainInstance.FillCliffAction, modMain.frmMainInstance.cbxFillInside.Checked); this.MapView.DrawViewLater(); } } } else if (modTools.Tool == modTools.Tools.RoadPlace) { if (this.Map.Tileset != null) { this.Apply_Road(); } } else if (modTools.Tool == modTools.Tools.RoadLines) { if (this.Map.Tileset != null) { this.Apply_Road_Line_Selection(); } } else if (modTools.Tool == modTools.Tools.RoadRemove) { this.Apply_Road_Remove(); } else if (modTools.Tool == modTools.Tools.ObjectPlace) { if ((modMain.frmMainInstance.SingleSelectedObjectType != null) & (this.Map.SelectedUnitGroup != null)) { clsMap.clsUnitCreate objectCreator = new clsMap.clsUnitCreate(); this.Map.SetObjectCreatorDefaults(objectCreator); objectCreator.Horizontal = mouseOverTerrain.Pos.Horizontal; objectCreator.Perform(); this.Map.UndoStepCreate("Place Object"); this.Map.Update(); this.Map.MinimapMakeLater(); this.MapView.DrawViewLater(); } } else if (modTools.Tool == modTools.Tools.ObjectLines) { this.ApplyObjectLine(); } else if (modTools.Tool == modTools.Tools.TerrainSelect) { if (this.Map.Selected_Area_VertexA == null) { this.Map.Selected_Area_VertexA = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal); this.MapView.DrawViewLater(); } else if (this.Map.Selected_Area_VertexB == null) { this.Map.Selected_Area_VertexB = new modMath.clsXY_int(mouseOverTerrain.Vertex.Normal); this.MapView.DrawViewLater(); } else { this.Map.Selected_Area_VertexA = null; this.Map.Selected_Area_VertexB = null; this.MapView.DrawViewLater(); } } else if (modTools.Tool == modTools.Tools.Gateways) { this.Apply_Gateway(); } } else if (modTools.Tool == modTools.Tools.ObjectSelect) { this.Map.SelectedUnits.Clear(); modMain.frmMainInstance.SelectedObject_Changed(); } } } else if (e.Button == MouseButtons.Right) { this.MouseRightDown = new clsMouseDown(); if (this.IsViewPosOverMinimap(_int)) { this.MouseRightDown.OverMinimap = new clsMouseDown.clsOverMinimap(); this.MouseRightDown.OverMinimap.DownPos = _int; } else { clsMouseOver.clsOverTerrain terrain2 = this.GetMouseOverTerrain(); if (terrain2 != null) { this.MouseRightDown.OverTerrain = new clsMouseDown.clsOverTerrain(); this.MouseRightDown.OverTerrain.DownPos = terrain2.Pos; } } if ((modTools.Tool == modTools.Tools.RoadLines) | (modTools.Tool == modTools.Tools.ObjectLines)) { this.Map.Selected_Tile_A = null; this.MapView.DrawViewLater(); } else if (modTools.Tool == modTools.Tools.TerrainSelect) { this.Map.Selected_Area_VertexA = null; this.Map.Selected_Area_VertexB = null; this.MapView.DrawViewLater(); } else if (modTools.Tool == modTools.Tools.CliffTriangle) { this.Apply_CliffTriangle(true); } else if (modTools.Tool == modTools.Tools.Gateways) { this.Map.Selected_Tile_A = null; this.Map.Selected_Tile_B = null; this.MapView.DrawViewLater(); } else if (modTools.Tool == modTools.Tools.HeightSetBrush) { if (modControls.KeyboardProfile.Active(modControls.Control_Picker)) { modMain.frmMainInstance.HeightPickerR(); } else { this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetR.SelectedIndex]); } } } }
public void Apply_Terrain_Fill(modProgram.enumFillCliffAction CliffAction, bool Inside) { clsMouseOver.clsOverTerrain mouseOverTerrain = this.GetMouseOverTerrain(); if (mouseOverTerrain != null) { modMath.sXY_int normal = mouseOverTerrain.Vertex.Normal; clsPainter.clsTerrain selectedTerrain = modProgram.SelectedTerrain; clsPainter.clsTerrain terrain = this.Map.Terrain.Vertices[normal.X, normal.Y].Terrain; if (selectedTerrain != terrain) { modMath.sXY_int[] _intArray = new modMath.sXY_int[0x80001]; _intArray[0] = normal; int index = 1; int num6 = 0; while (num6 < index) { bool flag; modMath.sXY_int vertexNum = _intArray[num6]; if (CliffAction == modProgram.enumFillCliffAction.StopBefore) { flag = this.Map.VertexIsCliffEdge(vertexNum); } else { flag = false; } bool flag2 = false; if (Inside) { if (vertexNum.X > 0) { if ((vertexNum.Y > 0) && ((this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y - 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y - 1].Terrain != selectedTerrain))) { flag2 = true; } if ((this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y].Terrain != selectedTerrain)) { flag2 = true; } if ((vertexNum.Y < this.Map.Terrain.TileSize.Y) && ((this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y + 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X - 1, vertexNum.Y + 1].Terrain != selectedTerrain))) { flag2 = true; } } if ((vertexNum.Y > 0) && ((this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y - 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y - 1].Terrain != selectedTerrain))) { flag2 = true; } if (vertexNum.X < this.Map.Terrain.TileSize.X) { if ((vertexNum.Y > 0) && ((this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y - 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y - 1].Terrain != selectedTerrain))) { flag2 = true; } if ((this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y].Terrain != selectedTerrain)) { flag2 = true; } if ((vertexNum.Y < this.Map.Terrain.TileSize.Y) && ((this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y + 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X + 1, vertexNum.Y + 1].Terrain != selectedTerrain))) { flag2 = true; } } if ((vertexNum.Y < this.Map.Terrain.TileSize.Y) && ((this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y + 1].Terrain != terrain) & (this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y + 1].Terrain != selectedTerrain))) { flag2 = true; } } if (!(flag | flag2) && (this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y].Terrain == terrain)) { modMath.sXY_int _int2; modMath.sXY_int _int4; this.Map.Terrain.Vertices[vertexNum.X, vertexNum.Y].Terrain = selectedTerrain; this.Map.SectorGraphicsChanges.VertexChanged(vertexNum); this.Map.SectorTerrainUndoChanges.VertexChanged(vertexNum); this.Map.AutoTextureChanges.VertexChanged(vertexNum); _int2.X = vertexNum.X + 1; _int2.Y = vertexNum.Y; if ((((_int2.X >= 0) & (_int2.X <= this.Map.Terrain.TileSize.X)) & (_int2.Y >= 0)) & (_int2.Y <= this.Map.Terrain.TileSize.Y)) { if (CliffAction == modProgram.enumFillCliffAction.StopAfter) { _int4 = new modMath.sXY_int(vertexNum.X, vertexNum.Y); flag = this.Map.SideHIsCliffOnBothSides(_int4); } else { flag = false; } if (!flag && (this.Map.Terrain.Vertices[_int2.X, _int2.Y].Terrain == terrain)) { if (_intArray.GetUpperBound(0) < index) { _intArray = (modMath.sXY_int[]) Utils.CopyArray((Array) _intArray, new modMath.sXY_int[((index * 2) + 1) + 1]); } _intArray[index] = _int2; index++; } } _int2.X = vertexNum.X - 1; _int2.Y = vertexNum.Y; if ((((_int2.X >= 0) & (_int2.X <= this.Map.Terrain.TileSize.X)) & (_int2.Y >= 0)) & (_int2.Y <= this.Map.Terrain.TileSize.Y)) { if (CliffAction == modProgram.enumFillCliffAction.StopAfter) { _int4 = new modMath.sXY_int(vertexNum.X - 1, vertexNum.Y); flag = this.Map.SideHIsCliffOnBothSides(_int4); } else { flag = false; } if (!flag && (this.Map.Terrain.Vertices[_int2.X, _int2.Y].Terrain == terrain)) { if (_intArray.GetUpperBound(0) < index) { _intArray = (modMath.sXY_int[]) Utils.CopyArray((Array) _intArray, new modMath.sXY_int[((index * 2) + 1) + 1]); } _intArray[index] = _int2; index++; } } _int2.X = vertexNum.X; _int2.Y = vertexNum.Y + 1; if ((((_int2.X >= 0) & (_int2.X <= this.Map.Terrain.TileSize.X)) & (_int2.Y >= 0)) & (_int2.Y <= this.Map.Terrain.TileSize.Y)) { if (CliffAction == modProgram.enumFillCliffAction.StopAfter) { _int4 = new modMath.sXY_int(vertexNum.X, vertexNum.Y); flag = this.Map.SideVIsCliffOnBothSides(_int4); } else { flag = false; } if (!flag && (this.Map.Terrain.Vertices[_int2.X, _int2.Y].Terrain == terrain)) { if (_intArray.GetUpperBound(0) < index) { _intArray = (modMath.sXY_int[]) Utils.CopyArray((Array) _intArray, new modMath.sXY_int[((index * 2) + 1) + 1]); } _intArray[index] = _int2; index++; } } _int2.X = vertexNum.X; _int2.Y = vertexNum.Y - 1; if ((((_int2.X >= 0) & (_int2.X <= this.Map.Terrain.TileSize.X)) & (_int2.Y >= 0)) & (_int2.Y <= this.Map.Terrain.TileSize.Y)) { if (CliffAction == modProgram.enumFillCliffAction.StopAfter) { _int4 = new modMath.sXY_int(vertexNum.X, vertexNum.Y - 1); flag = this.Map.SideVIsCliffOnBothSides(_int4); } else { flag = false; } if (!flag && (this.Map.Terrain.Vertices[_int2.X, _int2.Y].Terrain == terrain)) { if (_intArray.GetUpperBound(0) < index) { _intArray = (modMath.sXY_int[]) Utils.CopyArray((Array) _intArray, new modMath.sXY_int[((index * 2) + 1) + 1]); } _intArray[index] = _int2; index++; } } } num6++; if (num6 >= 0x20000) { int num4 = index - num6; int num2 = Math.Min(num6, num4); int num3 = index - num2; int num7 = num2 - 1; for (int i = 0; i <= num7; i++) { _intArray[i] = _intArray[num3 + i]; } index -= num6; num6 = 0; if ((index * 3) < (_intArray.GetUpperBound(0) + 1)) { _intArray = (modMath.sXY_int[]) Utils.CopyArray((Array) _intArray, new modMath.sXY_int[((index * 2) + 1) + 1]); } } } this.Map.Update(); this.Map.UndoStepCreate("Ground Fill"); this.MapView.DrawViewLater(); } } }
private void ViewPosClamp() { this.ViewPos.X = modMath.Clamp_int(this.ViewPos.X, -1048576, (this.Map.Terrain.TileSize.X * 0x80) + 0x100000); this.ViewPos.Z = modMath.Clamp_int(this.ViewPos.Z, ((0 - this.Map.Terrain.TileSize.Y) * 0x80) - 0x100000, 0x100000); modMath.sXY_int horizontal = new modMath.sXY_int(this.ViewPos.X, 0 - this.ViewPos.Z); this.ViewPos.Y = modMath.Clamp_int(this.ViewPos.Y, ((int) Math.Round(Math.Ceiling(this.Map.GetTerrainHeight(horizontal)))) + 0x10, 0x100000); }
public clsResult GenerateLayout() { int num; int num2; int level; int num5; bool flag; int num6; int baseLevel; int num9; modMath.sXY_int _int; Position.XY_dbl _dbl; bool flag2; int num12; int num13; int num14; clsNearest nearest; modProgram.sResult result3; modMath.sXY_int _int4; clsPassageNode node; clsPassageNode other; clsPassageNode node3; modMath.sXY_int _int5; int num41; int[] mapLevelCount; clsResult result4 = new clsResult("Layout"); this.TotalPlayerCount = this.TopLeftPlayerCount * this.SymmetryBlockCount; _int4.X = (int) Math.Round((double) (((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X))); _int4.Y = (int) Math.Round((double) (((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y))); int num19 = (int) Math.Round((double) (128f * this.NodeScale)); int num16 = (int) Math.Round(Math.Ceiling((double) (((((2.0 * this.TileSize.X) * 128.0) * this.TileSize.Y) * 128.0) / ((3.1415926535897931 * num19) * num19)))); this.PassageNodes = new clsPassageNode[(this.SymmetryBlockCount - 1) + 1, (num16 - 1) + 1]; int x = 0; if (this.SymmetryBlockCountXY.X == 1) { _int.X = (int) Math.Round(((double) (((this.TileSize.X * 0x80) - (x * 2.0)) / ((double) ((this.NodeScale * 128f) * 2f))))); _dbl.X = ((this.TileSize.X * 0x80) - (x * 2.0)) / ((double) _int.X); _int.X--; } else { _int.X = (int) Math.Round(((double) ((((((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X)) - x) / ((double) ((this.NodeScale * 128f) * 2f))) - 0.5))); _dbl.X = ((((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X)) - x) / (((double) ((((((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X)) - x) / ((double) ((this.NodeScale * 128f) * 2f))) - 0.5)) + 0.5); } if (this.SymmetryBlockCountXY.Y == 1) { _int.Y = (int) Math.Round(((double) (((this.TileSize.Y * 0x80) - (x * 2.0)) / ((double) ((this.NodeScale * 128f) * 2f))))); _dbl.Y = ((this.TileSize.Y * 0x80) - (x * 2.0)) / ((double) _int.Y); _int.Y--; } else { _int.Y = (int) Math.Round(((double) ((((((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y)) - x) / ((double) ((this.NodeScale * 128f) * 2f))) - 0.5))); _dbl.Y = ((((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y)) - x) / (((double) ((((((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y)) - x) / ((double) ((this.NodeScale * 128f) * 2f))) - 0.5)) + 0.5); } this.PassageNodeCount = 0; int y = _int.Y; for (int i = 0; i <= y; i++) { _int5 = new modMath.sXY_int(x, x + ((int) Math.Round((double) (i * _dbl.Y)))); if (!this.MakePassageNodes(_int5, true)) { result4.ProblemAdd("Error: Bad border node."); return result4; } if (this.SymmetryBlockCountXY.X == 1) { _int5 = new modMath.sXY_int((this.TileSize.X * 0x80) - x, x + ((int) Math.Round((double) (i * _dbl.Y)))); if (!this.MakePassageNodes(_int5, true)) { result4.ProblemAdd("Error: Bad border node."); return result4; } } } int num26 = _int.X; for (int j = 1; j <= num26; j++) { _int5 = new modMath.sXY_int(x + ((int) Math.Round((double) (j * _dbl.X))), x); if (!this.MakePassageNodes(_int5, true)) { result4.ProblemAdd("Error: Bad border node."); return result4; } if (this.SymmetryBlockCountXY.Y == 1) { _int5 = new modMath.sXY_int(x + ((int) Math.Round((double) (j * _dbl.X))), (this.TileSize.Y * 0x80) - x); if (!this.MakePassageNodes(_int5, true)) { result4.ProblemAdd("Error: Bad border node."); return result4; } } } Label_0538: num14 = 0; do { modMath.sXY_int _int2; if (this.SymmetryBlockCountXY.X == 1) { _int2.X = x + ((int) Math.Round((double) ((float) (App.Random.Next() * ((_int4.X - (x * 2)) + 1))))); } else { _int2.X = x + ((int) Math.Round((double) ((float) (App.Random.Next() * ((_int4.X - x) + 1))))); } if (this.SymmetryBlockCountXY.Y == 1) { _int2.Y = x + ((int) Math.Round((double) ((float) (App.Random.Next() * ((_int4.Y - (x * 2)) + 1))))); } else { _int2.Y = x + ((int) Math.Round((double) ((float) (App.Random.Next() * ((_int4.Y - x) + 1))))); } int num27 = this.PassageNodeCount - 1; num = 0; while (num <= num27) { int num28 = this.SymmetryBlockCount - 1; num2 = 0; while (num2 <= num28) { _int5 = this.PassageNodes[num2, num].Pos - _int2; if (_int5.ToDoubles().GetMagnitude() < (num19 * 2)) { break; } num2++; } num++; } if ((num == this.PassageNodeCount) && this.MakePassageNodes(_int2, false)) { goto Label_0538; } num14++; } while (num14 < ((int) Math.Round((double) (((64f * this.TileSize.X) * this.TileSize.Y) / (this.NodeScale * this.NodeScale))))); this.PassageNodes = (clsPassageNode[,]) Utils.CopyArray((Array) this.PassageNodes, new clsPassageNode[(this.SymmetryBlockCount - 1) + 1, (this.PassageNodeCount - 1) + 1]); int num15 = (num19 * 2) * 4; num15 *= num15; this.Nearests = new clsNearest[((this.PassageNodeCount * 0x40) - 1) + 1]; clsTestNearestArgs args2 = new clsTestNearestArgs(); int num17 = (int) Math.Round((double) ((this.NodeScale * 1.25f) * 128f)); args2.MaxConDist2 = num15; args2.MinConDist = num17; int num29 = this.PassageNodeCount - 1; num = 0; while (num <= num29) { args2.PassageNodeA = this.PassageNodes[0, num]; int num30 = this.PassageNodeCount - 1; num2 = num; while (num2 <= num30) { int num31 = this.SymmetryBlockCount - 1; num5 = 0; while (num5 <= num31) { args2.PassageNodeB = this.PassageNodes[num5, num2]; if (args2.PassageNodeA != args2.PassageNodeB) { this.TestNearest(args2); } num5++; } num2++; } num++; } int num32 = this.NearestCount - 1; for (num12 = 0; num12 <= num32; num12++) { nearest = this.Nearests[num12]; int num33 = nearest.NodeCount - 1; num = 0; while (num <= num33) { node = nearest.NodeA[num]; other = nearest.NodeB[num]; int num34 = this.NearestCount - 1; num13 = 0; while (num13 <= num34) { clsNearest nearest2 = this.Nearests[num13]; if (nearest2 != nearest) { if (nearest2.Dist2 < nearest.Dist2) { flag2 = true; } else if (nearest2.Dist2 == nearest.Dist2) { flag2 = nearest.Num > nearest2.Num; } else { flag2 = false; } if (flag2) { int num35 = nearest2.NodeCount - 1; num2 = 0; while (num2 <= num35) { if (!((((node == nearest2.NodeA[num2]) | (node == nearest2.NodeB[num2])) | (other == nearest2.NodeA[num2])) | (other == nearest2.NodeB[num2])) && modMath.GetLinesIntersectBetween(node.Pos, other.Pos, nearest2.NodeA[num2].Pos, nearest2.NodeB[num2].Pos).Exists) { break; } num2++; } if (num2 < nearest2.NodeCount) { clsNearest nearest3 = nearest; nearest3.BlockedCount++; clsNearest nearest4 = nearest2; nearest4.BlockedNearests[nearest4.BlockedNearestCount] = nearest; nearest3 = nearest4; nearest3.BlockedNearestCount++; nearest4 = null; } } } num13++; } num++; } } this.Connections = new clsConnection[((this.PassageNodeCount * 0x10) - 1) + 1]; do { num6 = 0; num12 = 0; while (num12 < this.NearestCount) { nearest = this.Nearests[num12]; flag2 = true; if ((nearest.BlockedCount == 0) & flag2) { int connectionCount = this.ConnectionCount; int num36 = nearest.NodeCount - 1; baseLevel = 0; while (baseLevel <= num36) { this.Connections[this.ConnectionCount] = new clsConnection(nearest.NodeA[baseLevel], nearest.NodeB[baseLevel]); this.ConnectionCount++; baseLevel++; } int num37 = nearest.NodeCount - 1; baseLevel = 0; while (baseLevel <= num37) { num = connectionCount + baseLevel; this.Connections[num].ReflectionCount = nearest.NodeCount - 1; this.Connections[num].Reflections = new clsConnection[(this.Connections[num].ReflectionCount - 1) + 1]; num2 = 0; int num38 = nearest.NodeCount - 1; num9 = 0; while (num9 <= num38) { if (num9 != baseLevel) { this.Connections[num].Reflections[num2] = this.Connections[connectionCount + num9]; num2++; } num9++; } baseLevel++; } int num39 = nearest.BlockedNearestCount - 1; num5 = 0; while (num5 <= num39) { nearest.BlockedNearests[num5].Invalid = true; num5++; } this.NearestCount--; num13 = nearest.Num; nearest.Num = -1; if (num13 != this.NearestCount) { this.Nearests[num13] = this.Nearests[this.NearestCount]; this.Nearests[num13].Num = num13; } num6++; } else { if (!flag2) { nearest.Invalid = true; } num12++; } } num12 = 0; while (num12 < this.NearestCount) { nearest = this.Nearests[num12]; if (nearest.Invalid) { nearest.Num = -1; int num40 = nearest.BlockedNearestCount - 1; baseLevel = 0; while (baseLevel <= num40) { clsNearest[] blockedNearests = nearest.BlockedNearests; num41 = baseLevel; blockedNearests[num41].BlockedCount--; baseLevel++; } this.NearestCount--; if (num12 != this.NearestCount) { this.Nearests[num12] = this.Nearests[this.NearestCount]; this.Nearests[num12].Num = num12; } } else { num12++; } } } while (num6 > 0); int num42 = this.PassageNodeCount - 1; for (num = 0; num <= num42; num++) { int num43 = this.SymmetryBlockCount - 1; for (num2 = 0; num2 <= num43; num2++) { this.PassageNodes[num2, num].ReorderConnections(); this.PassageNodes[num2, num].CalcIsNearBorder(); } } clsPassageNode[] nodeArray2 = new clsPassageNode[(this.PassageNodeCount - 1) + 1]; int index = 0; clsPassageNode[] nodeArray3 = new clsPassageNode[(this.PassageNodeCount - 1) + 1]; int num44 = this.PassageNodeCount - 1; num = 0; while (num <= num44) { nodeArray2[index] = this.PassageNodes[0, num]; index++; num++; } num2 = 0; while (index > 0) { num = (int) Math.Round((double) ((float) (App.Random.Next() * index))); nodeArray3[num2] = nodeArray2[num]; num2++; index--; nodeArray2[num] = nodeArray2[index]; } this.LevelHeight = 255f / ((float) (this.LevelCount - 1)); clsPassageNodeHeightLevelArgs args = new clsPassageNodeHeightLevelArgs { PassageNodesMinLevel = { Nodes = new int[(this.PassageNodeCount - 1) + 1] }, PassageNodesMaxLevel = { Nodes = new int[(this.PassageNodeCount - 1) + 1] }, MapLevelCount = new int[(this.LevelCount - 1) + 1] }; int num45 = this.PassageNodeCount - 1; num = 0; while (num <= num45) { args.PassageNodesMinLevel.Nodes[num] = 0; args.PassageNodesMaxLevel.Nodes[num] = this.LevelCount - 1; num++; } double[] numArray = new double[(this.BaseFlatArea - 1) + 1]; clsPassageNode[] nodeArray = new clsPassageNode[(this.BaseFlatArea - 1) + 1]; int[] numArray2 = new int[(this.BaseFlatArea - 1) + 1]; this.PlayerBases = new sPlayerBase[(this.TotalPlayerCount - 1) + 1]; int num46 = this.TopLeftPlayerCount - 1; num2 = 0; while (num2 <= num46) { int num3 = 0; int num47 = this.PassageNodeCount - 1; num = 0; while (num <= num47) { int num48 = this.SymmetryBlockCount - 1; num9 = 0; while (num9 <= num48) { node = this.PassageNodes[num9, num]; if (!node.IsOnBorder) { _int5 = node.Pos - this.PlayerBasePos[num2]; double magnitude = _int5.ToDoubles().GetMagnitude(); num5 = num3 - 1; while (num5 >= 0) { if (magnitude > numArray[num5]) { break; } num5 += -1; } num5++; int num49 = num5; baseLevel = Math.Min((int) (num3 - 1), (int) (this.BaseFlatArea - 2)); while (baseLevel >= num49) { numArray[baseLevel + 1] = numArray[baseLevel]; nodeArray[baseLevel + 1] = nodeArray[baseLevel]; baseLevel += -1; } if (num5 < this.BaseFlatArea) { numArray[num5] = magnitude; nodeArray[num5] = node; num3 = Math.Max(num3, num5 + 1); } } num9++; } num++; } if (this.BaseLevel < 0) { baseLevel = (int) Math.Round((double) ((float) (App.Random.Next() * this.LevelCount))); } else { baseLevel = this.BaseLevel; } mapLevelCount = args.MapLevelCount; num41 = baseLevel; mapLevelCount[num41] += num3; int num50 = num3 - 1; num = 0; while (num <= num50) { if (nodeArray[num].MirrorNum == 0) { numArray2[num] = -1; } else { int num51 = ((int) Math.Round((double) (((double) this.SymmetryBlockCount) / 2.0))) - 1; num5 = 0; while (num5 <= num51) { if (this.SymmetryBlocks[0].ReflectToNum[num5] == nodeArray[num].MirrorNum) { break; } num5++; } numArray2[num] = num5; } num++; } int num52 = this.SymmetryBlockCount - 1; num = 0; while (num <= num52) { num9 = (num * this.TopLeftPlayerCount) + num2; this.PlayerBases[num9].NodeCount = num3; this.PlayerBases[num9].Nodes = new clsPassageNode[(this.PlayerBases[num9].NodeCount - 1) + 1]; int num53 = num3 - 1; num5 = 0; while (num5 <= num53) { if (numArray2[num5] < 0) { this.PlayerBases[num9].Nodes[num5] = this.PassageNodes[num, nodeArray[num5].Num]; } else { this.PlayerBases[num9].Nodes[num5] = this.PassageNodes[this.SymmetryBlocks[num].ReflectToNum[numArray2[num5]], nodeArray[num5].Num]; } this.PlayerBases[num9].Nodes[num5].PlayerBaseNum = num9; this.PlayerBases[num9].Nodes[num5].Level = baseLevel; this.PassageNodesMinLevelSet(this.PlayerBases[num9].Nodes[num5], args.PassageNodesMinLevel, baseLevel, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(this.PlayerBases[num9].Nodes[num5], args.PassageNodesMaxLevel, baseLevel, this.MaxLevelTransition); num5++; } _int5 = new modMath.sXY_int(_int4.X - 1, _int4.Y - 1); modMath.sXY_int _int3 = TileOrientation.GetRotatedPos(this.SymmetryBlocks[num].Orientation, this.PlayerBasePos[num2], _int5); this.PlayerBases[num9].Pos.X = (this.SymmetryBlocks[num].XYNum.X * _int4.X) + _int3.X; this.PlayerBases[num9].Pos.Y = (this.SymmetryBlocks[num].XYNum.Y * _int4.Y) + _int3.Y; num++; } num2++; } int num54 = this.PassageNodeCount - 1; for (num = 0; num <= num54; num++) { node = nodeArray3[num]; if ((node.Level < 0) & !node.IsOnBorder) { int num20; int num22; int num21 = 0; int num55 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num55) { if (node.Connections[num2].GetOther().IsWater) { num21++; } num2++; } flag = true; int num56 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num56) { if (args.PassageNodesMinLevel.Nodes[node.Connections[num2].GetOther().Num] > 0) { flag = false; } num2++; } if (((flag & (((num21 == 0) & (num22 < this.WaterSpawnQuantity)) | ((num21 == 1) & ((this.TotalWaterQuantity - num20) > (this.WaterSpawnQuantity - num22))))) & (args.PassageNodesMinLevel.Nodes[node.Num] == 0)) & (num20 < this.TotalWaterQuantity)) { if (num21 == 0) { num22++; } num20++; num5 = node.Num; int num57 = this.SymmetryBlockCount - 1; baseLevel = 0; while (baseLevel <= num57) { this.PassageNodes[baseLevel, num5].IsWater = true; this.PassageNodes[baseLevel, num5].Level = 0; baseLevel++; } this.PassageNodesMinLevelSet(node, args.PassageNodesMinLevel, 0, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(node, args.PassageNodesMaxLevel, 0, this.MaxLevelTransition); mapLevelCount = args.MapLevelCount; num41 = 0; mapLevelCount[num41]++; int num58 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num58) { other = node.Connections[num2].GetOther(); this.PassageNodesMinLevelSet(other, args.PassageNodesMinLevel, 0, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(other, args.PassageNodesMaxLevel, 0, this.MaxLevelTransition); num2++; } } } } args.FlatsCutoff = 1; args.PassagesCutoff = 1; args.VariationCutoff = 1; args.ActionTotal = 1; int num59 = this.PassageNodeCount - 1; for (num = 0; num <= num59; num++) { node = nodeArray3[num]; if (((node.Level < 0) & !node.IsOnBorder) & node.IsNearBorder) { args.PassageNode = node; result3 = this.PassageNodeHeightLevel(args); if (!result3.Success) { result4.ProblemAdd(result3.Problem); return result4; } } } args.FlatsCutoff = this.FlatsChance; args.PassagesCutoff = args.FlatsCutoff + this.PassagesChance; args.VariationCutoff = args.PassagesCutoff + this.VariationChance; args.ActionTotal = args.VariationCutoff; if (args.ActionTotal <= 0) { result4.ProblemAdd("All height level behaviors are zero"); return result4; } int num60 = this.PassageNodeCount - 1; for (num = 0; num <= num60; num++) { node = nodeArray3[num]; if ((node.Level < 0) & !node.IsOnBorder) { args.PassageNode = node; result3 = this.PassageNodeHeightLevel(args); if (!result3.Success) { result4.ProblemAdd(result3.Problem); return result4; } } } int num61 = this.PassageNodeCount - 1; for (num = 0; num <= num61; num++) { node = this.PassageNodes[0, num]; if (node.IsOnBorder) { if (node.Level >= 0) { result4.ProblemAdd("Error: Border has had its height set."); return result4; } node3 = null; flag = true; int num62 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num62) { other = node.Connections[num2].GetOther(); if ((((other.Level >= 0) & !other.IsOnBorder) && ((args.PassageNodesMinLevel.Nodes[node.Num] <= other.Level) & (args.PassageNodesMaxLevel.Nodes[node.Num] >= other.Level))) && (node3 == null)) { node3 = other; } if (args.PassageNodesMinLevel.Nodes[other.Num] > 0) { flag = false; } num2++; } if (node3 != null) { level = node3.Level; this.PassageNodesMinLevelSet(node, args.PassageNodesMinLevel, level, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(node, args.PassageNodesMaxLevel, level, this.MaxLevelTransition); int num63 = this.SymmetryBlockCount - 1; baseLevel = 0; while (baseLevel <= num63) { this.PassageNodes[baseLevel, num].IsWater = node3.IsWater & flag; this.PassageNodes[baseLevel, num].Level = level; baseLevel++; } if (node.IsWater) { int num64 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num64) { other = node.Connections[num2].GetOther(); this.PassageNodesMinLevelSet(other, args.PassageNodesMinLevel, node.Level, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(other, args.PassageNodesMaxLevel, node.Level, this.MaxLevelTransition); num2++; } } } } else if (node.Level < 0) { result4.ProblemAdd("Error: Node height not set"); return result4; } } int num65 = this.PassageNodeCount - 1; for (num = 0; num <= num65; num++) { node = this.PassageNodes[0, num]; if (node.IsOnBorder & (node.Level < 0)) { node3 = null; flag = true; int num66 = node.ConnectionCount - 1; num2 = 0; while (num2 <= num66) { other = node.Connections[num2].GetOther(); if (((other.Level >= 0) && ((args.PassageNodesMinLevel.Nodes[node.Num] <= other.Level) & (args.PassageNodesMaxLevel.Nodes[node.Num] >= other.Level))) && (node3 == null)) { node3 = other; } if (args.PassageNodesMinLevel.Nodes[other.Num] > 0) { flag = false; } num2++; } if (node3 == null) { result4.ProblemAdd("Error: No connection for border node"); return result4; } level = node3.Level; this.PassageNodesMinLevelSet(node, args.PassageNodesMinLevel, level, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(node, args.PassageNodesMaxLevel, level, this.MaxLevelTransition); int num67 = this.SymmetryBlockCount - 1; for (baseLevel = 0; baseLevel <= num67; baseLevel++) { this.PassageNodes[baseLevel, num].IsWater = node3.IsWater & flag; this.PassageNodes[baseLevel, num].Level = level; } if (node.IsWater) { int num68 = node.ConnectionCount - 1; for (num2 = 0; num2 <= num68; num2++) { other = node.Connections[num2].GetOther(); this.PassageNodesMinLevelSet(other, args.PassageNodesMinLevel, node.Level, this.MaxLevelTransition); this.PassageNodesMaxLevelSet(other, args.PassageNodesMaxLevel, node.Level, this.MaxLevelTransition); } } } } this.RampBase = 1.0; this.MaxDisconnectionDist = 99999f; clsResult resultToAdd = this.GenerateRamps(); result4.Add(resultToAdd); return result4; }
public void MouseOver_Pos_Calc() { if (this.GetMouseLeftDownOverMinimap() != null) { if ((this.MouseOver != null) && this.IsViewPosOverMinimap(this.MouseOver.ScreenPos)) { modMath.sXY_int tileNum = new modMath.sXY_int((int) Math.Round(Conversion.Int((double) (this.MouseOver.ScreenPos.X * this.Tiles_Per_Minimap_Pixel))), (int) Math.Round(Conversion.Int((double) (this.MouseOver.ScreenPos.Y * this.Tiles_Per_Minimap_Pixel)))); this.Map.TileNumClampToMap(tileNum); this.LookAtTile(tileNum); } } else { Position.XY_dbl _dbl; clsMouseOver.clsOverTerrain terrain = new clsMouseOver.clsOverTerrain(); bool flag = false; if (modSettings.Settings.DirectPointer) { if (this.ScreenXY_Get_TerrainPos(this.MouseOver.ScreenPos, ref terrain.Pos) && this.Map.PosIsOnMap(terrain.Pos.Horizontal)) { flag = true; } } else { terrain.Pos.Altitude = (int) Math.Round((double) (127.5 * this.Map.HeightMultiplier)); if (this.ScreenXY_Get_ViewPlanePos(this.MouseOver.ScreenPos, (double) terrain.Pos.Altitude, ref _dbl)) { terrain.Pos.Horizontal.X = (int) Math.Round(_dbl.X); terrain.Pos.Horizontal.Y = (int) Math.Round(-_dbl.Y); if (this.Map.PosIsOnMap(terrain.Pos.Horizontal)) { terrain.Pos.Altitude = (int) Math.Round(this.Map.GetTerrainHeight(terrain.Pos.Horizontal)); flag = true; } } } if (flag) { IEnumerator enumerator; this.MouseOver.OverTerrain = terrain; terrain.Tile.Normal.X = (int) Math.Round(Conversion.Int((double) (((double) terrain.Pos.Horizontal.X) / 128.0))); terrain.Tile.Normal.Y = (int) Math.Round(Conversion.Int((double) (((double) terrain.Pos.Horizontal.Y) / 128.0))); terrain.Vertex.Normal.X = (int) Math.Round(Math.Round((double) (((double) terrain.Pos.Horizontal.X) / 128.0))); terrain.Vertex.Normal.Y = (int) Math.Round(Math.Round((double) (((double) terrain.Pos.Horizontal.Y) / 128.0))); terrain.Tile.Alignment = terrain.Vertex.Normal; terrain.Vertex.Alignment = new modMath.sXY_int(terrain.Tile.Normal.X + 1, terrain.Tile.Normal.Y + 1); terrain.Triangle = this.Map.GetTerrainTri(terrain.Pos.Horizontal); _dbl.X = terrain.Pos.Horizontal.X - (terrain.Vertex.Normal.X * 0x80); _dbl.Y = terrain.Pos.Horizontal.Y - (terrain.Vertex.Normal.Y * 0x80); double introduced10 = Math.Abs(_dbl.Y); if (introduced10 <= Math.Abs(_dbl.X)) { terrain.Side_IsV = false; terrain.Side_Num.X = terrain.Tile.Normal.X; terrain.Side_Num.Y = terrain.Vertex.Normal.Y; } else { terrain.Side_IsV = true; terrain.Side_Num.X = terrain.Vertex.Normal.X; terrain.Side_Num.Y = terrain.Tile.Normal.Y; } modMath.sXY_int posSectorNum = this.Map.GetPosSectorNum(terrain.Pos.Horizontal); try { enumerator = this.Map.Sectors[posSectorNum.X, posSectorNum.Y].Units.GetEnumerator(); while (enumerator.MoveNext()) { clsMap.clsUnitSectorConnection current = (clsMap.clsUnitSectorConnection) enumerator.Current; clsMap.clsUnit newItem = current.Unit; _dbl.X = newItem.Pos.Horizontal.X - terrain.Pos.Horizontal.X; _dbl.Y = newItem.Pos.Horizontal.Y - terrain.Pos.Horizontal.Y; modMath.sXY_int _int = newItem.Type.get_GetFootprintSelected(newItem.Rotation); if ((Math.Abs(_dbl.X) <= (Math.Max((double) (((double) _int.X) / 2.0), (double) 0.5) * 128.0)) & (Math.Abs(_dbl.Y) <= (Math.Max((double) (((double) _int.Y) / 2.0), (double) 0.5) * 128.0))) { terrain.Units.Add(newItem); } } } finally { if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } if (this.MouseLeftDown != null) { if (modTools.Tool == modTools.Tools.TerrainBrush) { this.Apply_Terrain(); if (modMain.frmMainInstance.cbxAutoTexSetHeight.Checked) { this.Apply_Height_Set(modProgram.TerrainBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]); } } else if (modTools.Tool == modTools.Tools.HeightSetBrush) { this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetL.SelectedIndex]); } else if (modTools.Tool == modTools.Tools.TextureBrush) { this.Apply_Texture(); } else if (modTools.Tool == modTools.Tools.CliffTriangle) { this.Apply_CliffTriangle(false); } else if (modTools.Tool == modTools.Tools.CliffBrush) { this.Apply_Cliff(); } else if (modTools.Tool == modTools.Tools.CliffRemove) { this.Apply_Cliff_Remove(); } else if (modTools.Tool == modTools.Tools.RoadPlace) { this.Apply_Road(); } else if (modTools.Tool == modTools.Tools.RoadRemove) { this.Apply_Road_Remove(); } } if (this.MouseRightDown != null) { if (modTools.Tool == modTools.Tools.HeightSetBrush) { if (this.MouseLeftDown == null) { this.Apply_Height_Set(modProgram.HeightBrush, modMain.frmMainInstance.HeightSetPalette[modMain.frmMainInstance.tabHeightSetR.SelectedIndex]); } } else if (modTools.Tool == modTools.Tools.CliffTriangle) { this.Apply_CliffTriangle(true); } } } } this.MapView.Pos_Display_Update(); this.MapView.DrawViewLater(); }
public clsBooleanMap GetWaterMap() { clsBooleanMap map2 = new clsBooleanMap(); map2.Blank(this.Map.Terrain.TileSize.X + 1, this.Map.Terrain.TileSize.Y + 1); int y = this.Map.Terrain.TileSize.Y; for (int i = 0; i <= y; i++) { int x = this.Map.Terrain.TileSize.X; for (int j = 0; j <= x; j++) { bool isWater; float magnitude; modMath.sXY_int _int4; float maxValue = float.MaxValue; modMath.sXY_int point = new modMath.sXY_int(j * 0x80, i * 0x80); int num9 = this.ConnectionCount - 1; int index = 0; while (index <= num9) { if (this.Connections[index].PassageNodeA.IsWater == this.Connections[index].PassageNodeB.IsWater) { modMath.sXY_int _int3 = modMath.PointGetClosestPosOnLine(this.Connections[index].PassageNodeA.Pos, this.Connections[index].PassageNodeB.Pos, point) - point; magnitude = (float) _int3.ToDoubles().GetMagnitude(); if (magnitude < maxValue) { maxValue = magnitude; _int3 = point - this.Connections[index].PassageNodeA.Pos; _int4 = point - this.Connections[index].PassageNodeB.Pos; if (_int3.ToDoubles().GetMagnitude() <= _int4.ToDoubles().GetMagnitude()) { isWater = this.Connections[index].PassageNodeA.IsWater; } else { isWater = this.Connections[index].PassageNodeB.IsWater; } } } index++; } int num10 = this.PassageNodeCount - 1; for (int k = 0; k <= num10; k++) { int num11 = this.SymmetryBlockCount - 1; for (index = 0; index <= num11; index++) { _int4 = point - this.PassageNodes[index, k].Pos; magnitude = (float) _int4.ToDoubles().GetMagnitude(); if (magnitude < maxValue) { maxValue = magnitude; isWater = this.PassageNodes[index, k].IsWater; } } } map2.ValueData.Value[i, j] = isWater; } } return map2; }
private bool MakePassageNodes(modMath.sXY_int Pos, bool IsOnBorder) { int num; modMath.sXY_int _int; modMath.sXY_int _int3; modMath.sXY_int[] _intArray = new modMath.sXY_int[4]; _int3.X = (int) Math.Round((double) (((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X))); _int3.Y = (int) Math.Round((double) (((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y))); _int.X = _int3.X - 1; _int.Y = _int3.Y - 1; int num3 = this.SymmetryBlockCount - 1; for (num = 0; num <= num3; num++) { modMath.sXY_int _int2 = TileOrientation.GetRotatedPos(this.SymmetryBlocks[num].Orientation, Pos, _int); _intArray[num].X = (this.SymmetryBlocks[num].XYNum.X * _int3.X) + _int2.X; _intArray[num].Y = (this.SymmetryBlocks[num].XYNum.Y * _int3.Y) + _int2.Y; int num4 = num - 1; for (int i = 0; i <= num4; i++) { modMath.sXY_int _int4 = _intArray[num] - _intArray[i]; if (_int4.ToDoubles().GetMagnitude() < ((this.NodeScale * 128f) * 2.0)) { return false; } } } int num5 = this.SymmetryBlockCount - 1; for (num = 0; num <= num5; num++) { clsPassageNode node = new clsPassageNode(); this.PassageNodes[num, this.PassageNodeCount] = node; node.Num = this.PassageNodeCount; node.MirrorNum = num; node.Pos = _intArray[num]; node.IsOnBorder = IsOnBorder; } this.PassageNodeCount++; return true; }
public void PerformActionMapSectors(clsMap.clsAction Tool, sPosNum Centre) { modMath.sXY_int lastValidNum = new modMath.sXY_int(Tool.Map.SectorCount.X - 1, Tool.Map.SectorCount.Y - 1); this.PerformAction(Tool, Centre, lastValidNum); }
public modProgram.sResult GenerateGateways() { int num5; modProgram.sResult result2; int num6; int x; result2.Success = false; result2.Problem = ""; clsMap.clsTerrain terrain = this.Map.Terrain; sPossibleGateway[] gatewayArray = new sPossibleGateway[(((terrain.TileSize.X * terrain.TileSize.Y) * 2) - 1) + 1]; int num10 = terrain.TileSize.Y - 1; int y = 0; while (y <= num10) { num6 = 0; int num11 = terrain.TileSize.X - 1; for (x = 0; x <= num11; x++) { if (this.GenerateTerrainTiles[x, y].Node.GetClearance >= 1) { if (this.GenerateTerrainTiles[x, y].Node.GetClearance == 1) { if ((num6 > 3) & (num6 <= 9)) { gatewayArray[num5].StartPos.X = x - num6; gatewayArray[num5].StartPos.Y = y; gatewayArray[num5].Length = num6 + 1; gatewayArray[num5].IsVertical = false; gatewayArray[num5].MiddlePos.X = (gatewayArray[num5].StartPos.X * 0x80) + (gatewayArray[num5].Length * 0x40); gatewayArray[num5].MiddlePos.Y = gatewayArray[num5].StartPos.Y * 0x80; num5++; } num6 = 1; } else { num6++; } } } y++; } int num12 = terrain.TileSize.X - 1; x = 0; while (x <= num12) { num6 = 0; y = 0; while (y < terrain.TileSize.Y) { if (this.GenerateTerrainTiles[x, y].Node.GetClearance >= 1) { if (this.GenerateTerrainTiles[x, y].Node.GetClearance == 1) { if ((num6 >= 3) & (num6 <= 9)) { gatewayArray[num5].StartPos.X = x; gatewayArray[num5].StartPos.Y = y - num6; gatewayArray[num5].Length = num6 + 1; gatewayArray[num5].IsVertical = true; gatewayArray[num5].MiddlePos.X = gatewayArray[num5].StartPos.X * 0x80; gatewayArray[num5].MiddlePos.Y = (gatewayArray[num5].StartPos.Y * 0x80) + (gatewayArray[num5].Length * 0x40); num5++; } num6 = 1; } else { num6++; } } y++; } x++; } bool[,] flagArray = new bool[(terrain.TileSize.X - 1) + 1, (terrain.TileSize.Y - 1) + 1]; while (num5 > 0) { modMath.sXY_int _int2; int index = -1; float maxValue = float.MaxValue; int num13 = num5 - 1; int num = 0; while (num <= num13) { float length = gatewayArray[num].Length; if (length < maxValue) { maxValue = length; index = num; } num++; } if (gatewayArray[index].IsVertical) { _int2 = new modMath.sXY_int(gatewayArray[index].StartPos.X, (gatewayArray[index].StartPos.Y + gatewayArray[index].Length) - 1); this.Map.GatewayCreateStoreChange(gatewayArray[index].StartPos, _int2); int num14 = (gatewayArray[index].StartPos.Y + gatewayArray[index].Length) - 1; y = gatewayArray[index].StartPos.Y; while (y <= num14) { flagArray[gatewayArray[index].StartPos.X, y] = true; y++; } } else { _int2 = new modMath.sXY_int((gatewayArray[index].StartPos.X + gatewayArray[index].Length) - 1, gatewayArray[index].StartPos.Y); this.Map.GatewayCreateStoreChange(gatewayArray[index].StartPos, _int2); int num15 = (gatewayArray[index].StartPos.X + gatewayArray[index].Length) - 1; x = gatewayArray[index].StartPos.X; while (x <= num15) { flagArray[x, gatewayArray[index].StartPos.Y] = true; x++; } } modMath.sXY_int middlePos = gatewayArray[index].MiddlePos; double num4 = gatewayArray[index].Length * 0x80; num = 0; while (num < num5) { bool flag = true; if (gatewayArray[num].IsVertical) { int num16 = (gatewayArray[num].StartPos.Y + gatewayArray[num].Length) - 1; for (y = gatewayArray[num].StartPos.Y; y <= num16; y++) { if (flagArray[gatewayArray[num].StartPos.X, y]) { flag = false; break; } } } else { int num17 = (gatewayArray[num].StartPos.X + gatewayArray[num].Length) - 1; for (x = gatewayArray[num].StartPos.X; x <= num17; x++) { if (flagArray[x, gatewayArray[num].StartPos.Y]) { flag = false; break; } } } if (flag) { _int2 = middlePos - gatewayArray[num].MiddlePos; if (_int2.ToDoubles().GetMagnitude() < num4) { flag = false; } } if (!flag) { num5--; if (num != num5) { gatewayArray[num] = gatewayArray[num5]; } } else { num++; } } } result2.Success = true; return result2; }
public void PerformActionMapTiles(clsMap.clsAction Tool, sPosNum Centre) { modMath.sXY_int lastValidNum = new modMath.sXY_int(Tool.Map.Terrain.TileSize.X - 1, Tool.Map.Terrain.TileSize.Y - 1); this.PerformAction(Tool, Centre, lastValidNum); }
public static bool WorldPosFromINIText(string Text, ref modProgram.clsWorldPos Result) { clsSplitCommaText text = new clsSplitCommaText(Text); if (text.PartCount != 3) { return false; } int[] numArray = new int[3]; int index = 0; do { int num2; if (InvariantParse_int(text.Parts[index], ref num2)) { numArray[index] = num2; } else { return false; } index++; } while (index <= 2); modMath.sXY_int newHorizontal = new modMath.sXY_int(numArray[0], numArray[1]); modProgram.sWorldPos newWorldPos = new modProgram.sWorldPos(newHorizontal, numArray[2]); Result = new modProgram.clsWorldPos(newWorldPos); return true; }
public clsXY_int(modMath.sXY_int XY) { this.XY = XY; }
public sXY_int(int X, int Y) { this = new modMath.sXY_int(); this.X = X; this.Y = Y; }
public sWorldPos(modMath.sXY_int NewHorizontal, int NewAltitude) { this = new modProgram.sWorldPos(); this.Horizontal = NewHorizontal; this.Altitude = NewAltitude; }