private void Handle(DistrictAreaModifyCommand command) { DistrictHandler.IgnoreAreaModified.Add(command.StartPosition); DistrictTool.ApplyBrush(command.Layer, command.District, command.BrushRadius, command.StartPosition, command.EndPosition); DistrictManager.instance.NamesModified(); DistrictHandler.IgnoreAreaModified.Remove(command.StartPosition); }
protected override void Handle(DistrictAreaModifyCommand command) { IgnoreHelper.StartIgnore(); DistrictTool.ApplyBrush(command.Layer, command.District, command.BrushRadius, command.StartPosition, command.EndPosition); DistrictManager.instance.NamesModified(); DistrictManager.instance.ParkNamesModified(); IgnoreHelper.EndIgnore(); }
public override void Handle(DistrictAreaModifyCommand command) { DistrictHandler.IgnoreAll = true; DistrictTool.ApplyBrush(command.Layer, command.District, command.BrushRadius, command.StartPosition, command.EndPosition); DistrictManager.instance.NamesModified(); DistrictManager.instance.ParkNamesModified(); DistrictHandler.IgnoreAll = false; }
private static void ApplyBrush(DistrictTool dt, byte district) { GameAreaManager instance = Singleton<GameAreaManager>.instance; DistrictManager.Cell[] districtGrid = FakeDistrictManager.m_districtGrid; float num = 19.2f; float num2 = dt.m_brushSize * 0.35f + num; int num3 = FakeDistrictManager.GRID; Vector3 vector = (Vector3)m_lastPaintPosition.GetValue(dt); Vector3 mousePosition = (Vector3)m_mousePosition.GetValue(dt); if (vector.x < -50000f) { vector = mousePosition; } vector.y = 0f; mousePosition.y = 0f; Vector3 vector2 = Vector3.Min(vector, mousePosition); Vector3 vector3 = Vector3.Max(vector, mousePosition); int num4 = Mathf.Max((int)((vector2.x - num2) / num + (float)num3 * 0.5f), 0); int num5 = Mathf.Max((int)((vector2.z - num2) / num + (float)num3 * 0.5f), 0); int num6 = Mathf.Min((int)((vector3.x + num2) / num + (float)num3 * 0.5f), num3 - 1); int num7 = Mathf.Min((int)((vector3.z + num2) / num + (float)num3 * 0.5f), num3 - 1); int num8 = num3; int num9 = -1; int num10 = num3; int num11 = -1; for (int i = num5; i <= num7; i++) { for (int j = num4; j <= num6; j++) { Vector3 vector4 = new Vector3(((float)j - (float)num3 * 0.5f + 0.5f) * num, 0f, ((float)i - (float)num3 * 0.5f + 0.5f) * num); Vector3 a = vector4; if (instance.ClampPoint(ref a)) { float a2 = Mathf.Sqrt(Segment3.DistanceSqr(vector, mousePosition, vector4)) - num2 + num * 2f; float num12 = Vector3.Distance(a, vector4); float num13 = Mathf.Max(a2, num12) - num * 2f; float num14 = Mathf.Clamp01(-num13 / (num * 2f)); if (num14 != 0f) { int min = Mathf.Clamp((int)(256f * num14), 0, 255); bool flag; if (num12 > 1f && district != 0) { flag = ForceDistrictAlpha(j, i, district, min, 255); } else { flag = SetDistrictAlpha(j, i, district, min, 255); } if (flag) { num8 = Mathf.Min(num8, j); num9 = Mathf.Max(num9, j); num10 = Mathf.Min(num10, i); num11 = Mathf.Max(num11, i); } } } } } int num15 = num8; int num16 = num9; int num17 = num10; int num18 = num11; int num19 = 0; bool flag2; do { num4 = Mathf.Max(num8 - 1, 0); num6 = Mathf.Min(num9 + 1, num3 - 1); num5 = Mathf.Max(num10 - 1, 0); num7 = Mathf.Min(num11 + 1, num3 - 1); num8 = num3; num9 = -1; num10 = num3; num11 = -1; flag2 = false; for (int k = num5; k <= num7; k++) { for (int l = num4; l <= num6; l++) { DistrictManager.Cell cell = districtGrid[k * num3 + l]; bool flag3 = false; bool flag4 = false; if (cell.m_alpha1 != 0) { bool flag5 = cell.m_district1 == district; int num20; int num21; CheckNeighbourCells(l, k, cell.m_district1, out num20, out num21); if (!flag5 && Mathf.Min((int)(cell.m_alpha1 + 120), 255) > num21) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district1, 0, Mathf.Max(0, num21 - 120))); } else if (flag5 && Mathf.Max((int)(cell.m_alpha1 - 120), 0) < num20) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district1, Mathf.Min(255, num20 + 120), 255)); } if (flag5) { flag3 = true; } } if (cell.m_alpha2 != 0) { bool flag6 = cell.m_district2 == district; int num22; int num23; CheckNeighbourCells(l, k, cell.m_district2, out num22, out num23); if (!flag6 && Mathf.Min((int)(cell.m_alpha2 + 120), 255) > num23) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district2, 0, Mathf.Max(0, num23 - 120))); } else if (flag6 && Mathf.Max((int)(cell.m_alpha2 - 120), 0) < num22) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district2, Mathf.Min(255, num22 + 120), 255)); } if (flag6) { flag3 = true; } } if (cell.m_alpha3 != 0) { bool flag7 = cell.m_district3 == district; int num24; int num25; CheckNeighbourCells(l, k, cell.m_district3, out num24, out num25); if (!flag7 && Mathf.Min((int)(cell.m_alpha3 + 120), 255) > num25) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district3, 0, Mathf.Max(0, num25 - 120))); } else if (flag7 && Mathf.Max((int)(cell.m_alpha3 - 120), 0) < num24) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district3, Mathf.Min(255, num24 + 120), 255)); } if (flag7) { flag3 = true; } } if (cell.m_alpha4 != 0) { bool flag8 = cell.m_district4 == district; int num26; int num27; CheckNeighbourCells(l, k, cell.m_district4, out num26, out num27); if (!flag8 && Mathf.Min((int)(cell.m_alpha4 + 120), 255) > num27) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district4, 0, Mathf.Max(0, num27 - 120))); } else if (flag8 && Mathf.Max((int)(cell.m_alpha4 - 120), 0) < num26) { flag4 = (flag4 || SetDistrictAlpha(l, k, cell.m_district4, Mathf.Min(255, num26 + 120), 255)); } if (flag8) { flag3 = true; } } if (!flag3) { int num28; int num29; CheckNeighbourCells(l, k, district, out num28, out num29); if (0 < num28) { flag4 = (flag4 || SetDistrictAlpha(l, k, district, Mathf.Min(255, num28 + 120), 255)); } } if (flag4) { num8 = Mathf.Min(num8, l); num9 = Mathf.Max(num9, l); num10 = Mathf.Min(num10, k); num11 = Mathf.Max(num11, k); flag2 = true; } } } num15 = Mathf.Min(num15, num8); num16 = Mathf.Max(num16, num9); num17 = Mathf.Min(num17, num10); num18 = Mathf.Max(num18, num11); } while (++num19 < 10 && flag2); Singleton<DistrictManager>.instance.AreaModified(num15, num17, num16, num18, true); Singleton<DistrictManager>.instance.m_districtsNotUsed.Disable(); }
private static void Normalize(DistrictTool tool, ref DistrictManager.Cell cell, int ignoreIndex) { UnityEngine.Debug.Log($"{tool}-{cell}-{ignoreIndex}"); }
private static int GetAlpha(DistrictTool tool, ref DistrictManager.Cell cell, byte district) { UnityEngine.Debug.Log($"{tool}-{cell}-{district}"); return(0); }