public RectInt GetOffsetArea(Vector2Int pos, Vector2Int mapSize) { var area = new RectInt(pos, affectedArea.size); area.ClampToBounds(new RectInt(0, 0, mapSize.x, mapSize.y)); return(area); }
public void PrepareTopFaces(RectInt area, float tileSize) { var cellData = data.GetCellData(); area.ClampToBounds(data.Rect); //build normal verts and normals for (var x = area.xMin; x < area.xMax; x++) { for (var y = area.yMin; y < area.yMax; y++) { var cell = data.Cell(x, y); //var x1 = x - ChunkBounds.xMin; //var y1 = y - ChunkBounds.yMin; var tv = new Vector3[4]; if (cell == null) { Debug.LogError($"Could not find cell in bounds at {x},{y}"); } tv[0] = new Vector3((x + 0) * tileSize, cell.Heights[0] * RoMapData.YScale, (y + 1) * tileSize); tv[1] = new Vector3((x + 1) * tileSize, cell.Heights[1] * RoMapData.YScale, (y + 1) * tileSize); tv[2] = new Vector3((x + 0) * tileSize, cell.Heights[2] * RoMapData.YScale, (y + 0) * tileSize); tv[3] = new Vector3((x + 1) * tileSize, cell.Heights[3] * RoMapData.YScale, (y + 0) * tileSize); vertexData[x + y * data.Width] = tv; var normal = VectorHelper.CalcQuadNormal(tv[0], tv[1], tv[2], tv[3]); cellNormals[x + y * data.Width] = normal; var normals = new Vector3[4]; for (var i = 0; i < 4; i++) { normals[i] = normal; } normalData[x + y * data.Width] = normals; cellColors[x + y * data.Width] = cell.Top.Color; } } }
//public bool RedoChange(out RectInt affectedRegion) //{ // var success = ChangeTracker.Redo(out var cells, out affectedRegion); // if(success) // { // container.CellData = cells; // EditorUtility.SetDirty(this); // } // return success; //} private void UpdateWalkCellData(RectInt area) { area = area.ExpandRect(1); area.ClampToBounds(Rect); for (var x = area.xMin; x < area.xMax; x++) { for (var y = area.yMin; y < area.yMax; y++) { var wc = WalkCellData.Cells[x + y * Width]; var cell = Cell(x, y); wc.Heights = cell.Heights; wc.Type = RagnarokWalkData.ColorToCellMask(cell.Top.Texture); WalkCellData.Cells[x + y * Width] = wc; } } EditorUtility.SetDirty(WalkCellData); }
public void Register(RectInt area, Vector2Int mapSize, Cell[] cells) { //var bytes = SerializationUtility.SerializeValue(cells, DataFormat.Binary); if (count > MaxChanges) { changeData.RemoveAt(0); count--; } //Debug.Log($"Storing undo into position {count} covering area {area}"); area.ClampToBounds(new RectInt(0, 0, mapSize.x, mapSize.y)); var data = new MapSubsetData(); data.Store(cells, mapSize, area); changeData.Add(data); //Debug.Log($"Adding {data} to changeData, new count is: {changeData.Count}"); count++; }