private JournalOperation ExtractCargoDump(JObject data) { var dump = new DumpOperation { ResetFilter = new HashSet <Kind> { Kind.Commodity }, DumpOperations = new List <MaterialOperation>() }; foreach (var jToken in data["Inventory"]) { dynamic cc = jToken; var materialName = converter.GetOrCreate((string)cc.Name); int? count = cc.Value ?? cc.Count; var operation = new MaterialOperation { MaterialName = materialName, Size = count ?? 1 }; dump.DumpOperations.Add(operation); } return(dump); }
private JournalOperation ExtractCargoDump(JObject data) { var dump = new DumpOperation { ResetFilter = new HashSet <Kind>() { Kind.Commodity }, DumpOperations = new List <MaterialOperation>() }; foreach (var jToken in data["Inventory"]) { dynamic cc = jToken; string materialName = cc.Name; int? count = cc.Value ?? cc.Count; if (!converter.TryGet(materialName, out materialName)) { MessageBox.Show(string.Format(languages.Translate("Unknown material, please contact the author ! {0}"), (string)data["Name"])); continue; } var operation = new MaterialOperation() { MaterialName = materialName, Size = count ?? 1 }; dump.DumpOperations.Add(operation); } return(dump); }
private JournalOperation ExtractMaterialsDump(JObject data) { var dump = new DumpOperation { ResetFilter = new HashSet <Kind> { Kind.Data, Kind.Material }, DumpOperations = new List <MaterialOperation>() }; foreach (var jToken in data["Raw"].Union(data["Manufactured"]).Union(data["Encoded"])) { dynamic cc = jToken; var materialName = converter.GetOrCreate((string)cc.Name); int? count = cc.Value ?? cc.Count; var operation = new MaterialOperation { MaterialName = materialName, Size = count ?? 1 }; dump.DumpOperations.Add(operation); } return(dump); }
private JournalOperation ExtractMaterialsDump(JObject data) { var dump = new DumpOperation { ResetFilter = new HashSet <Kind>() { Kind.Data, Kind.Material }, DumpOperations = new List <MaterialOperation>() }; foreach (var jToken in data["Raw"].Union(data["Manufactured"]).Union(data["Encoded"])) { dynamic cc = jToken; string materialName; int? count = cc.Value ?? cc.Count; if (!converter.TryGet((string)cc.Name, out materialName)) { MessageBox.Show(string.Format(languages.Translate("Unknown material, please contact the author ! {0}"), cc.Name)); continue; } var operation = new MaterialOperation() { MaterialName = materialName, Size = count ?? 1 }; dump.DumpOperations.Add(operation); } return(dump); }
private void Update() { if (upButton.IsPressed) { cursor.IncreaseSize(); } if (downButton.IsPressed) { cursor.DecreaseSize(); } if (isWorking) { cursor.UpdateActiveChunks(); if (trigger.Value <= 0.2) { isWorking = false; Dictionary <Chunk, float[]> afterEdit = new Dictionary <Chunk, float[]>(); Dictionary <Chunk, float[]> afterColor = new Dictionary <Chunk, float[]>(); foreach (Chunk chunk in beforeEdit.Keys) { float[] voxels = new float[chunk.voxels.Volume]; float[] colors = new float[chunk.voxels.Volume * 3]; chunk.voxels.VoxelBuffer.GetData(voxels); chunk.voxels.ColorBuffer.GetData(colors); afterEdit.Add(chunk, voxels); afterColor.Add(chunk, colors); } MaterialOperation op = new MaterialOperation(beforeEdit, beforeColor, afterEdit, afterColor); OperationManager.Instance.PushOperation(op); } foreach (Chunk chunk in LayerManager.Instance.activeChunks) { if (!beforeEdit.ContainsKey(chunk)) { float[] voxels = new float[chunk.voxels.Volume]; float[] colors = new float[chunk.voxels.Volume * 3]; chunk.voxels.VoxelBuffer.GetData(voxels); chunk.voxels.ColorBuffer.GetData(colors); beforeEdit.Add(chunk, voxels); beforeColor.Add(chunk, colors); } } PerformAction(); } if (trigger.Value > 0.2) { if (!isWorking) { isWorking = true; beforeEdit = new Dictionary <Chunk, float[]>(); beforeColor = new Dictionary <Chunk, float[]>(); } } }
private JournalOperation ExtractCargoDump(JObject data) { // ED version 3.3 (December 11th 2018) made some breaking changes: // - Cargo event was added after buying/selling/scooping/ejecting commodities/limpets // - But unfortunately this Cargo event is different to normal Cargo event and does not contain the Inventory key (so it needs to be ignored) // - Note that when cmdr is loaded/game is started, Cargo event DOES contain the Inventory field if (data["Inventory"] == null) { return(null); } var dump = new DumpOperation { ResetFilter = new HashSet <Kind> { Kind.Commodity }, DumpOperations = new List <MaterialOperation>() }; var inventoryData = data["Inventory"]; if (inventoryData != null) { foreach (var jToken in inventoryData) { dynamic cc = jToken; if (!converter.TryGet(Kind.Commodity, (string)cc.Name, out var commodityName)) { continue; } int?count = cc.Value ?? cc.Count; var operation = new MaterialOperation { MaterialName = commodityName, Size = count ?? 1 }; dump.DumpOperations.Add(operation); } } return(dump); }
public static void UndoAdd(HexCell centerCell, TerrainBrush brush) { List <HexCell> cellList = new List <HexCell>(); int centerX = centerCell.coordinates.X; int centerZ = centerCell.coordinates.Z; for (int l = 0, z = centerZ; z >= centerZ - brush.brushRange + 1; l++, z--) { for (int x = centerX - brush.brushRange + 1 + l; x <= centerX + brush.brushRange - 1; x++) { if (HexGrid.instance.GetCell(new HexCoordinates(x, z)) != null) { cellList.Add(HexGrid.instance.GetCell(new HexCoordinates(x, z))); } } } for (int l = 1, z = centerZ + 1; z <= centerZ + brush.brushRange - 1; l++, z++) { for (int x = centerX - brush.brushRange + 1; x <= centerX + brush.brushRange - 1 - l; x++) { if (HexGrid.instance.GetCell(new HexCoordinates(x, z)) != null) { cellList.Add(HexGrid.instance.GetCell(new HexCoordinates(x, z))); } } } List <UndoRedoOperation.UndoRedoInfo> undoRedoInfoList = new List <UndoRedoOperation.UndoRedoInfo>(); for (int i = 0; i < cellList.Count; i++) { UndoRedoOperation.UndoRedoInfo undoRedoInfo = new UndoRedoOperation.UndoRedoInfo(); undoRedoInfo.hexCell = cellList[i]; switch (brush.m_editorType) { case EditorType.HeightEditor: undoRedoInfo.parma = new object[] { cellList[i].Elevation }; break; case EditorType.WaterEditor: undoRedoInfo.parma = new object[] { cellList[i].WaterLevel }; break; case EditorType.EdgeEditor: undoRedoInfo.parma = new object[] { cellList[i].isStepDirection[0], cellList[i].isStepDirection[1], cellList[i].isStepDirection[2], cellList[i].isStepDirection[3], cellList[i].isStepDirection[4], cellList[i].isStepDirection[5] }; break; case EditorType.MaterialEditor: if (HexMetrics.instance.isEditorTexture) { undoRedoInfo.parma = new object[] { cellList[i].TerrainTypeIndex }; } else { undoRedoInfo.parma = new object[] { cellList[i].color }; } break; } undoRedoInfoList.Add(undoRedoInfo); } string name = ""; if (brush.m_editorType == EditorType.HeightEditor || brush.m_editorType == EditorType.WaterEditor || brush.m_editorType == EditorType.EdgeEditor) { MeshOperation.OperationType operationType = MeshOperation.OperationType.HeightEdit; switch (brush.m_editorType) { case EditorType.HeightEditor: name = "高度编辑"; operationType = MeshOperation.OperationType.HeightEdit; break; case EditorType.WaterEditor: name = "水平线编辑"; operationType = MeshOperation.OperationType.WaterLevelEdit; break; case EditorType.EdgeEditor: name = "边界编辑"; operationType = MeshOperation.OperationType.EdgeEdit; break; } MeshOperation meshOperation = new MeshOperation(operationType, name, undoRedoInfoList); undoStack.Push(meshOperation); } else if (brush.m_editorType == EditorType.MaterialEditor) { MaterialOperation.OperationType operationType = MaterialOperation.OperationType.WholeCellEdit; name = "材质编辑"; MaterialOperation materialOperation = new MaterialOperation(operationType, name, undoRedoInfoList); undoStack.Push(materialOperation); } LimitStackCount(); }