// Use this for initialization void Start() { bsBlockSets [0] = new BlockSet(); bsBlockSets [0].sBlock_Type = "LBLOCK"; bsBlockSets [0].iaBlock_Orient = new int[4][]; bsBlockSets [0].iaBlock_Orient[0] = new int[]{4,8,12,13}; bsBlockSets [0].iaBlock_Orient[1] = new int[]{4,5,9,13}; bsBlockSets [0].iaBlock_Orient[2] = new int[]{10,12,13,14}; bsBlockSets [0].iaBlock_Orient[3] = new int[]{8,9,10,12}; bsBlockSets [1] = new BlockSet(); bsBlockSets [1].sBlock_Type = "JBLOCK"; bsBlockSets [1].iaBlock_Orient = new int[4][]; bsBlockSets [1].iaBlock_Orient[0] = new int[]{5,9,12,13}; bsBlockSets [1].iaBlock_Orient[1] = new int[]{4,5,8,12}; bsBlockSets [1].iaBlock_Orient[2] = new int[]{8,9,10,14}; bsBlockSets [1].iaBlock_Orient[3] = new int[]{8,12,13,14}; bsBlockSets [2] = new BlockSet(); bsBlockSets [2].sBlock_Type = "LONGBLOCK"; bsBlockSets [2].iaBlock_Orient = new int[4][]; bsBlockSets [2].iaBlock_Orient[0] = new int[]{0,4,8,12}; bsBlockSets [2].iaBlock_Orient[1] = new int[]{0,4,8,12}; bsBlockSets [2].iaBlock_Orient[2] = new int[]{12,13,14,15}; bsBlockSets [2].iaBlock_Orient[3] = new int[]{12,13,14,15}; bsBlockSets [3] = new BlockSet(); bsBlockSets [3].sBlock_Type = "BOXBLOCK"; bsBlockSets [3].iaBlock_Orient = new int[4][]; bsBlockSets [3].iaBlock_Orient[0] = new int[]{8,9,12,13}; bsBlockSets [3].iaBlock_Orient[1] = new int[]{8,9,12,13}; bsBlockSets [3].iaBlock_Orient[2] = new int[]{8,9,12,13}; bsBlockSets [3].iaBlock_Orient[3] = new int[]{8,9,12,13}; bsBlockSets [4] = new BlockSet(); bsBlockSets [4].sBlock_Type = "TBLOCK"; bsBlockSets [4].iaBlock_Orient = new int[4][]; bsBlockSets [4].iaBlock_Orient[0] = new int[]{8,9,10,13}; bsBlockSets [4].iaBlock_Orient[1] = new int[]{9,12,13,14}; bsBlockSets [4].iaBlock_Orient[2] = new int[]{4,8,9,12}; bsBlockSets [4].iaBlock_Orient[3] = new int[]{5,8,9,13}; bsBlockSets [5] = new BlockSet(); bsBlockSets [5].sBlock_Type = "ZBLOCK"; bsBlockSets [5].iaBlock_Orient = new int[4][]; bsBlockSets [5].iaBlock_Orient[0] = new int[]{5,8,9,12}; bsBlockSets [5].iaBlock_Orient[1] = new int[]{5,8,9,12}; bsBlockSets [5].iaBlock_Orient[2] = new int[]{8,9,13,14}; bsBlockSets [5].iaBlock_Orient[3] = new int[]{8,9,13,14}; bsBlockSets [6] = new BlockSet(); bsBlockSets [6].sBlock_Type = "SBLOCK"; bsBlockSets [6].iaBlock_Orient = new int[4][]; bsBlockSets [6].iaBlock_Orient[0] = new int[]{4,8,9,13}; bsBlockSets [6].iaBlock_Orient[1] = new int[]{4,8,9,13}; bsBlockSets [6].iaBlock_Orient[2] = new int[]{9,10,12,13}; bsBlockSets [6].iaBlock_Orient[3] = new int[]{9,10,12,13}; InvokeRepeating("Spawn", spawnDelay, spawnTime); }
/** * DrawInventory draws the current Inventory and handles choosing the new selected block */ private static Block DrawInventory(BlockSet blockSet, ref Vector2 scrollPosition, Block selected) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); for (int index = 0, y = 0; index < blockSet.GetCount(); y++) { GUILayout.BeginHorizontal(); for (int x = 0; x < 8; x++, index++) { Block block = blockSet.GetBlock(index); if (DrawBlock(block, block == selected && selected != null)) { selected = block; } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); return(selected); }
void Start() { Map map = (Map)GameObject.FindObjectOfType(typeof(Map)); IsBlockUnderSelection = false; blockSet = map.GetBlockSet(); Block[] blocks = blockSet.GetBlocks(); for (int i = 0; i < blocks.Length; ++i) { blocks[i].Index = i; } blockSet.SetBlocks(blocks); if (MultiplayerGame.Player != null) { builder = MultiplayerGame.Player.GetComponent <Builder>(); } }
private CubeAction DetermineBelongingCoset(CubeAction e) { var eState = new BlockSet(ToStablize); e.Act(eState.State); if (!OrbitToCoset.ContainsKey(eState)) { return(null); } var cosetRepresentative = OrbitToCoset[eState]; if (Utils.ShouldVerify()) { { var cosetReprState = new BlockSet(ToStablize); cosetRepresentative.Act(cosetReprState.State); Utils.DebugAssert(cosetReprState.Equals(eState)); } { // States in orbit 1-to-1 maps to each *left* coset (gH). I.e. // iff. e^(-1) * cosetRepresentative stablizes the BlockSet being // observed. This deduces that, group actions in same *left* // coset, always act the BlockSet being observed to the same state. var reCosetRep = e.Reverse().Mul(cosetRepresentative); Utils.DebugAssert(Stablized.IsStablizedBy(reCosetRep)); } { // Iff. e * cosetRepresentative^(-1) stablizes the BlockSet being // observed. This is the condition for *right* coset. It is not what // we need here, and group actions in same *right* coset, may act the // BlockSet being observed to different states. var eRCosetRep = e.Mul(cosetRepresentative.Reverse()); // Utils.DebugAssert(observed.IsStablizedBy(eRCosetRep)); // Doesn't hold } } return(cosetRepresentative); }
public BlockPage Process(BlockPage page) { IBlock last = null; BlockSet <IBlock> currentBlockSet = null; var result = new BlockPage(); foreach (var block in page.AllBlocks) { bool shouldBreak = false; if (last != null) { // expect: previous >~ next float previous = last.GetH(); float next = block.GetH(); // previous >> next if (previous > next + statDownInTheBottom) { shouldBreak = true; } // previous < next if (previous < next - statGoingUp) { shouldBreak = true; } } if ((currentBlockSet == null) || shouldBreak) { currentBlockSet = new BlockSet <IBlock>(); result.Add(currentBlockSet); } currentBlockSet.Add(block); last = block; } return(result); }
BlockColumn CopyColumnMetadata(BlockPage2 blocksetInfo, BlockColumn column) { var columnInfo = new BlockColumn(blocksetInfo, column.ColumnType, column.X1, column.W); var block = new Block() { H = column.GetH(), X = column.GetX(), Height = column.GetHeight(), Width = column.GetWidth(), Text = $"Column [{columnInfo.ColumnType}:{columnInfo.X1}]" }; var bset = new BlockSet <IBlock>(blocksetInfo); bset.Add(block); columnInfo.Add(bset); return(columnInfo); }
bool HasLineOverlap(BlockSet <IBlock> a, BlockSet <IBlock> b) { // why it would happen? if (a.Count() < 2) { PdfReaderException.AlwaysThrow("a.Count() < 2"); } var lastLines = a.TakeLast(2); var firstLine = b.Take(1).First(); var last = lastLines.First(); if (Block.AreSameLine(last, firstLine)) { return(true); } return(false); }
private void DrawBlockSet(BlockSet blockSet) { GUILayout.BeginVertical(GUI.skin.box); Block oldSelectedBlock = selectedBlock; selectedBlock = BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300)); if (selectedBlock != oldSelectedBlock) { GUIUtility.keyboardControl = 0; } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button("New Block")) { Block newBlock = (Block)Activator.CreateInstance(typeof(Block)); newBlock.Name = "NewBlock"; blockSet.Blocks.Add(newBlock); EditorGUIUtility.keyboardControl = 0; GUI.changed = true; } GUILayout.EndHorizontal(); if (GUILayout.Button("Remove")) { blockSet.Blocks.Remove(selectedBlock); GUI.changed = true; } if (GUILayout.Button("Force Save")) { EditorUtility.SetDirty(blockSet); } GUILayout.EndVertical(); }
public override void Load(TagCompound c) { TagList paletteList = (TagList)c["Palette"]; long[] data = c.GetLongArray("BlockStates"); BlockSet[] palette = new BlockSet[paletteList.Count]; for (int i = 0; i < palette.Length; i++) { TagCompound r = (TagCompound)paletteList[i]; IBlock block = GameData.JavaEdition.GetBlock(r.GetString("Name")); if (r.ContainsKey("Properties", TagType.Compound)) { Dictionary <string, string> ps = new Dictionary <string, string>(); foreach (TagString tag in (TagCompound)r["Properties"]) { ps.Add(tag.Name, tag.Value); } palette[i] = block.GetBlock(ps); } else { palette[i] = new BlockSet(block, block.DefaultBlockSet.Properties, block.DefaultBlockSet.RuntimeId); } } DenseArray array = new DenseArray(data, data.Length * 64 / 4096); for (int y = 0; y < Height; y++) { for (int z = 0; z < Length; z++) { for (int x = 0; x < Width; x++) { int blockIndex = (y * Length + z) * Width + x; int val = array[blockIndex]; _blocks[x, y, z] = palette[val].RuntimeId; } } } base.Load(c); }
BlockSet <IBlock> FindBlockCore(BlockSet <IBlock> blockset) { var blocks = blockset.ToList(); int total = blocks.Count - 1; float limit = blockset.GetWidth() / 2; int start = ScanBlock(i => blocks[i], blockset.GetX() + limit); int end = ScanBlock(i => blocks[total - i], blockset.GetX() + limit); int ini = start; int tot = total + 1 - end; var core = new BlockSet <IBlock>(); // get the core for (int i = start; i <= total - end; i++) { core.Add(blocks[i]); } return(core); }
static void Main(string[] args) { var inputList = readInput("input.txt").First().Split(new char[] { '\t' }).Select(s => int.Parse(s)); var blocks = new BlockSet(inputList); var history = new List <string> { blocks.ToString() }; var counter = 0; var cycleStartState = string.Empty; while (true) { counter++; Redistribute(blocks.Blocks); var state = blocks.ToString(); if (history.Contains(state)) { cycleStartState = state; break; } else { history.Add(state); } } Console.WriteLine($"Part 1: {counter}"); counter = 0; do { counter++; Redistribute(blocks.Blocks); } while (cycleStartState != blocks.ToString()); Console.WriteLine($"Part 2: {counter}"); Console.ReadLine(); }
public void HoldNow() { if (FallingBlockSet == null) { return; } if (!Held) { FallingTimer.Stop(); FallingBlockSet.Initial(); if (FallingBlockSet is BlocksS || FallingBlockSet is BlocksT || FallingBlockSet is BlocksZ) { FallingBlockSet.SetOrigin(BombingPointX, -1); } else { FallingBlockSet.SetOrigin(BombingPointX, 0); } if (BlockSetHold != null) { BlockSet bs = BlockSetHold; BlockSetHold = FallingBlockSet; FallingBlockSet = bs; } else { BlockSetHold = FallingBlockSet; FallingBlockSet = NextBlockSet(); } Held = true; Show(); FallingTimer.Start(); } }
private static Entity DrawInventory(BlockSet blockSet, ref Vector2 scrollPosition, Entity selected) { scrollPosition = GUILayout.BeginScrollView(scrollPosition); int y = 0; for (int i = 0; i < blockSet.GetBlockCount(); y++) { GUILayout.BeginHorizontal(); for (int x = 0; x < 8; x++, i++) { Block block = blockSet.GetBlock(i); if (DrawBlock(block, block == BlockUnderSelection && BlockUnderSelection != null)) { selected = block; IsBlockUnderSelection = true; } } GUILayout.EndHorizontal(); } for (int i = 0; i < blockSet.GetItemCount(); y++) { GUILayout.BeginHorizontal(); for (int x = 0; x < 8; x++, i++) { Item item = blockSet.GetItem(i); if (DrawBlock(item, item == ItemUnderSelection && ItemUnderSelection != null)) { selected = item; IsItemUnderSelection = true; } } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); return(selected); }
private List <BlockSet> StablizerChain_FixedStep(int stepLength) { var ret = new List <BlockSet>(); var state = new CubeState(); var solvingOrder = Enumerable.Range(0, state.Blocks.Length) .OrderBy(i => i, new CubeBlockIndexComparator(state)) .ToList(); var iterator = solvingOrder.GetEnumerator(); bool moveForward = true; while (moveForward) { var blockSet = new BlockSet(state); for (int i = 0; i < stepLength; i++) { if (iterator.MoveNext()) { blockSet.Indexes.Add(iterator.Current); } else { moveForward = false; break; } } if (blockSet.Indexes.Count > 0) { ret.Add(blockSet); } } return(ret); }
/** * DrawBlockSetEditor draws and handles the editing of the BlockSet */ private static void DrawBlockSetEditor(BlockSet blockSet) { GUILayout.BeginVertical("box"); selectedBlock = DrawBlockList(blockSet, selectedBlock, ref blockSetScrollPosition); EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Cube")) { selectedBlock = blockSet.Add(new Cube("new Cube")); } if (GUILayout.Button("Add Cross")) { selectedBlock = blockSet.Add(new Cross("new Cross")); } GUILayout.EndHorizontal(); if (GUILayout.Button("Remove") && blockSet.GetBlock(selectedBlock) != null) { Undo.RecordObject(blockSet, "Remove block"); blockSet.Remove(selectedBlock); selectedBlock = Mathf.Clamp(selectedBlock, 0, blockSet.GetCount() - 1); } GUILayout.EndVertical(); }
public BlockSet[] GetBlockSetsAsArray(){ BlockSet[] bs = new BlockSet[54]; bs[0] = Empty; bs[1] = Bottom_Left; bs[2] = Bottom_Alone; bs[3] = Bottom_Right; bs[4] = Bottom_Surrounded; bs[5] = Right_Alone; bs[6] = Centre_Alone; bs[7] = Left_Alone; bs[8] = Centre_Surrounded; bs[9] = Top_Right; bs[10] = Top_Alone; bs[11] = Top_Left; bs[12] = Top_Surrounded; bs[13] = Right_Surrounded; bs[14] = Left_Surrounded; bs[15] = Centre_Horizontal_Surrounded; bs[16] = Centre_Vertical_Surrounded; bs[17] = Top_Right_Inner_Corner; bs[18] = Top_Left_Inner_Corner; bs[19] = Bottom_Right_Inner_Corner; bs[20] = Bottom_Left_Inner_Corner; bs[21] = Right_Diagonal; bs[22] = Left_Diagonal; bs[23] = Lower_Right_Filled_Diagonal; bs[24] = Lower_Left_Filled_Diagonal; bs[25] = Upper_Right_Filled_Diagonal; bs[26] = Upper_Left_Filled_Diagonal; bs[27] = Cross_Hub; bs[28] = Downward_T_Hub; bs[29] = Upward_T_Hub; bs[30] = Leftward_T_Hub; bs[31] = Rightward_T_Hub; bs[32] = Border_Bottom_Left; bs[33] = Border_Bottom_Right; bs[34] = Border_Top_Left; bs[35] = Border_Top_Right; bs[36] = Diagonal_Gate_Left; bs[37] = Diagonal_Gate_Right; bs[38] = Fork_Bottom_Left; bs[39] = Fork_Bottom_Right; bs[40] = Fork_Top_Left; bs[41] = Fork_Top_Right; bs[42] = Funnel_Bottom; bs[43] = Funnel_Left; bs[44] = Funnel_Right; bs[45] = Funnel_Top; bs[46] = Taper_Bottom_Left; bs[47] = Taper_Bottom_Right; bs[48] = Taper_Left_Bottom; bs[49] = Taper_Left_Top; bs[50] = Taper_Right_Bottom; bs[51] = Taper_Right_Top; bs[52] = Taper_Top_Left; bs[53] = Taper_Top_Right; return bs; }
BlockSet <IBlock>[] SplitBlock(BlockSet <IBlock> blockset) { var blocks = blockset.ToList(); int total = blocks.Count - 1; float limit = blockset.GetWidth() / 2; int start = ScanBlock(i => blocks[i], blockset.GetX() + limit); int end = ScanBlock(i => blocks[total - i], blockset.GetX() + limit); // no split if (start == 0 && end == 0) { // VALIDATE //System.Diagnostics.Debugger.Break(); return(new BlockSet <IBlock>[] { blockset }); } // split into 2 pieces int middle = -1; // split into 2 pieces: there is a clear division middle = (start + end > total) ? (start) : middle; middle = (start == 0) ? (total - end + 1) : middle; middle = (end == 0) ? (start) : middle; if (middle > 0) { var blockA = new BlockSet <IBlock>(); var blockB = new BlockSet <IBlock>(); blockA.AddRange(blocks.Take(middle)); blockB.AddRange(blocks.TakeLast(total - middle + 1)); int count2 = blockA.Count() + blockB.Count(); if (count2 != blocks.Count) { PdfReaderException.AlwaysThrow("count2 != blocks.Count"); } // VALIDATE //System.Diagnostics.Debugger.Break(); return(new BlockSet <IBlock>[] { blockA, blockB }); } // split into 3 pieces var topBlock = new BlockSet <IBlock>(); var coreBlock = new BlockSet <IBlock>(); var bottomBlock = new BlockSet <IBlock>(); topBlock.AddRange(blocks.Take(start)); for (int i = start; i <= total - end; i++) { coreBlock.Add(blocks[i]); } bottomBlock.AddRange(blocks.TakeLast(end)); int count3 = topBlock.Count() + coreBlock.Count() + bottomBlock.Count(); if (count3 != blocks.Count) { PdfReaderException.AlwaysThrow("count3 != blocks.Count"); } // VALIDATE //System.Diagnostics.Debugger.Break(); return(new BlockSet <IBlock>[] { topBlock, coreBlock, bottomBlock }); }
IBlockSet <IBlock> GetOverlapBlockSet(Block overlap, BlockSet <IBlock> block1, BlockSet <IBlock> block2) { var b1 = block1.Where(b => HasOverlapY(b, overlap)); var b2 = block2.Where(b => HasOverlapY(b, overlap)); if (b1.Count() == 0 || b2.Count() == 0) { PdfReaderException.Throw("b1.Count() == 0 || b2.Count() == 0"); } var blockMerge = new BlockMerge(); blockMerge.Merge(b1); blockMerge.Merge(b2); return(blockMerge); }
//Dictionary<string,Rect> outlineRects = new Dictionary<string, Rect>(); void DrawBlockSet(BlockSet blocks, BlockOrientation orientation){ string orientationName = orientation.ToString(); if(!scrollPositions.ContainsKey(orientationName)){ scrollPositions.Add(orientationName,Vector2.zero); } EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); EditorGUILayout.BeginVertical(GUILayout.Width(150)); EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); Texture2D icon = GetIcon(orientation.ToString()); GUILayout.Label(new GUIContent("",orientationName),GUILayout.ExpandWidth(false), GUILayout.MinWidth(100),GUILayout.MinHeight(100)); GUI.DrawTexture(GUILayoutUtility.GetLastRect(),icon,ScaleMode.ScaleAndCrop,false); bool isDefault = GUILayout.Toggle(blocks.IsDefault(),new GUIContent("",TidyMessages.BLOCK_EDITOR_BLOCKSET_IS_DEFAULT_TOOLTIP),GUILayout.Height(25)); if(isDefault && !blocks.IsDefault()){ workingBlock.ClearDefault(); blocks.SetIsDefault(true); SetBlockDirty(workingBlock); hasWorkingBlockChanged = true; if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } } if(!isDefault && blocks.IsDefault()){ workingBlock.ClearDefault(); hasWorkingBlockChanged = true; SetBlockDirty(workingBlock); if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } } EditorGUILayout.EndHorizontal(); if(!newObjects.ContainsKey(orientationName)){ newObjects.Add(orientationName,null); } newObjects[orientationName] = EditorGUILayout.ObjectField(newObjects[orientationName],typeof(GameObject),false,GUILayout.Width(150)) as GameObject; //Change as at 30/12/2011: No more button, automatic addition if(GUILayout.Button(new GUIContent(TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT, TidyMessages.BLOCK_EDITOR_BLOCKSET_ADD_VARIANT_TOOLTIP)) && (newObjects[orientationName] != null && !newObjects[orientationName].Equals(workingBlock.gameObject))){ //GameObject newBlock = EditorUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //PREFAB //GameObject newBlock = PrefabUtility.InstantiatePrefab(newObjects[orientationName]) as GameObject; //newBlock.name = newObjects[orientationName].name; //newBlock.SetActiveRecursively(false); workingBlock.Editor_AddToBlockSet(orientation,newObjects[orientationName]); if(workingBlock.GetDefaultSet() == null){ blocks.SetIsDefault(true); } hasWorkingBlockChanged = true; if(!initialPreviewGenerated){ //there will be no other opportunity to refresh GetPreviewForGameObject(workingBlock.GetDefaultBlock(),true); initialPreviewGenerated = true; } SetBlockDirty(workingBlock); newObjects[orientationName] = null; mapCreator.RefreshAllMaps(); } EditorGUILayout.EndVertical(); Vector2 scrollPos = scrollPositions[orientationName]; //scrollPos = GUILayout.BeginScrollView(scrollPos,GUILayout.MinHeight(130),GUILayout.ExpandWidth(true)); Rect r = EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true),GUILayout.MinHeight(130)); GUI.Box(r,""); if(blocks != null && blocks.blockSet != null){ for(int i = 0; i < blocks.blockSet.Length; i++){ DrawObjectPreview(blocks.blockSet[i],orientation); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); //GUILayout.EndScrollView(); //GUI.Box(GUILayoutUtility.GetLastRect(),""); scrollPositions[orientationName] = scrollPos; EditorGUILayout.EndHorizontal(); }
public BlockSetTest() { _fx = new MemoryStoreFixture(); _set = new BlockSet <DumbAction>(_fx.GetHashAlgorithm, _fx.Store); }
public override void Init(BlockSet blockSet) { base.Init(blockSet); _face = ToTexCoords(inactiveFace); }
public BlockSetTest() { _fx = new DefaultStoreFixture(); _set = new BlockSet <DumbAction>(_fx.Store); }
public JerrumFilter(BlockSet stablized, List <BlockSet> stablizerChain) { InitStablizingOrder(stablizerChain); InitStablizedIdx(stablized); IniitGeneratorCountLimit(); }
static void Main(string[] args) { string[] worldPath = Environment.GetCommandLineArgs(); if (worldPath.Length <= 1) { Console.WriteLine("ソフトウェアの実行ファイル(exe)にワールドのディレクトリをドラッグ&ドロップしてください"); Console.ReadKey(); return; } // ワールドを読み込み using (var w = OrangeNBT.World.Anvil.AnvilWorld.Load(worldPath[1])) { // 全てのディメンションを順に読み込み foreach (var dim in w.Dimensions) { var coords = dim.Value.Chunks.ListAllCoords(); int count = coords.Count(); foreach (var coord in coords) { Console.WriteLine("ディメンション:{0} 残り{1}チャンク", dim.Key, count); var chunk = dim.Value.Chunks.GetChunk(coord); for (int x = 0; x < 16; x++) { for (int y = 0; y < 256; y++) { for (int z = 0; z < 16; z++) { // 全ブロック取得 BlockSet block = chunk.GetBlock(x, y, z); switch (block.Name) { case "minecraft:coal_ore": case "minecraft:iron_ore": case "minecraft:gold_ore": case "minecraft:diamond_ore": case "minecraft:redstone_ore": case "minecraft:emerald_ore": case "minecraft:lapis_ore": // チャンク座標からワールドのX座標に変換 var worldX = (coord.X << 4) + x; // チャンク座標からワールドのZ座標に変換 var worldZ = (coord.Z << 4) + z; dim.Value.Blocks.SetBlock(worldX, y, worldZ, "minecraft:stone"); break; } } } } count--; } Console.WriteLine("ディメンション:{0} 保存中...", dim.Key); dim.Value.Save(); } } Console.WriteLine("完了!エンターを押して終了してください"); Console.ReadKey(); }
public void SetBlockSet(BlockSet blockSet) { this.blockSet = blockSet; }
public void LoadLevel() { int verticalOffset = 85; Debug.Log("About to load level folder: " + _fullMapPath + "."); Substrate.AnvilWorld mcWorld = Substrate.AnvilWorld.Create(_fullMapPath); Substrate.AnvilRegionManager mcAnvilRegionManager = mcWorld.GetRegionManager(); BlockSet blockSet = _map.GetBlockSet(); _map.GetSunLightmap().SetSunHeight(3, 3, 3); foreach (Substrate.AnvilRegion mcAnvilRegion in mcAnvilRegionManager) { // Loop through x-axis of chunks in this region for (int iMCChunkX = 0; iMCChunkX < mcAnvilRegion.XDim; iMCChunkX++) { // Loop through z-axis of chunks in this region. for (int iMCChunkZ = 0; iMCChunkZ < mcAnvilRegion.ZDim; iMCChunkZ++) { // Retrieve the chunk at the current position in our 2D loop... Substrate.ChunkRef mcChunkRef = mcAnvilRegion.GetChunkRef(iMCChunkX, iMCChunkZ); if (mcChunkRef != null) { if (mcChunkRef.IsTerrainPopulated) { // Ok...now to stick the blocks in... for (int iMCChunkInternalX = 0; iMCChunkInternalX < mcChunkRef.Blocks.XDim; iMCChunkInternalX++) { for (int iMCChunkInternalY = 0; iMCChunkInternalY < mcChunkRef.Blocks.YDim; iMCChunkInternalY++) { for (int iMCChunkInternalZ = 0; iMCChunkInternalZ < mcChunkRef.Blocks.ZDim; iMCChunkInternalZ++) { int iBlockID = mcChunkRef.Blocks.GetID(iMCChunkInternalX, iMCChunkInternalY, iMCChunkInternalZ); Vector3i blockPos = new Vector3i(iMCChunkInternalX, iMCChunkInternalY + verticalOffset, iMCChunkInternalZ); if (iBlockID != 0) { switch (iBlockID) { case 3: // Dirt to first grass iBlockID = 1; break; case 12: // Grass to grass iBlockID = 1; break; case 13: // Gravel to stone iBlockID = 4; break; case 1: // Stone to second stone iBlockID = 5; break; case 16: // Coal ore to fungus iBlockID = 17; break; case 15: // Iron ore to pumpkin iBlockID = 20; break; case 9: // Water to water iBlockID = 8; break; default: Debug.Log("Unmapped BlockID: " + iBlockID); break; } Block newBlock = blockSet.GetBlock(iBlockID); _map.SetBlock(new BlockData(newBlock), blockPos); Vector3i chunkPos = Chunk.ToChunkPosition(blockPos); _map.SetDirty(chunkPos); } } // End for (int iMCChunkInternalZ = 0; iMCChunkInternalZ < mcChunkRef.Blocks.ZDim; iMCChunkInternalZ++) } // End for (int iMCChunkInternalY = 0; iMCChunkInternalY < mcChunkRef.Blocks.YDim; iMCChunkInternalY++) } // End for (int iMCChunkInternalX = 0; iMCChunkInternalX < mcChunkRef.Blocks.XDim; iMCChunkInternalX++) } // End if (mcChunkRef.IsTerrainPopulated) } // End if (mcChunkRef != null) } // End for (int iMCChunkZ = 0; iMCChunkZ < mcAnvilRegion.ZDim; iMCChunkZ++) } // End for (int iMCChunkX = 0; iMCChunkX < mcAnvilRegion.XDim; iMCChunkX++) } // End foreach( Substrate.AnvilRegion mcAnvilRegion in mcAnvilRegionManager ) Debug.Log("Loaded level: " + _fullMapPath + "."); _map.AddColliders(); // List3D<Chunk> chunkList = _map.GetChunks (); // // for (int minX = chunkList.GetMinX(); minX < chunkList.GetMaxX(); minX++) // { // for (int minY = chunkList.GetMinY(); minY < chunkList.GetMaxY(); minY++) // { // for (int minZ = chunkList.GetMinZ(); minZ < chunkList.GetMaxZ(); minZ++) // { // Vector3i chunkPos = new Vector3i(minX, minY, minZ); // // Chunk mapChunk = _map.GetChunk (chunkPos); // // Debug.Log ("LOL [" + minX + ", " + minY + ", " + minZ + "]."); // } // } // } // // foreach (Chunk loadedChunk in _map.Get // { // Vector3i loadedChunkPos = loadedChunk.GetPosition(); // Debug.Log ("MOG A CHUNK!!! [" + loadedChunkPos.x + ", " + loadedChunkPos.y + ", " + loadedChunkPos.z + "]."); // } } // End public void LoadLevel()
public override void Init(BlockSet blockSet) { base.Init(blockSet); texCoords = ToTexCoords(face); }
public string Validate(BlockSet <MarkLine> marks) { bool overlap = HasTableOverlap(marks); return((overlap) ? "mark orange no overlap" : null); }
public BlockSet[] GetBlockSetsAsArray() { BlockSet[] bs = new BlockSet[54]; bs[0] = Empty; bs[1] = Bottom_Left; bs[2] = Bottom_Alone; bs[3] = Bottom_Right; bs[4] = Bottom_Surrounded; bs[5] = Right_Alone; bs[6] = Centre_Alone; bs[7] = Left_Alone; bs[8] = Centre_Surrounded; bs[9] = Top_Right; bs[10] = Top_Alone; bs[11] = Top_Left; bs[12] = Top_Surrounded; bs[13] = Right_Surrounded; bs[14] = Left_Surrounded; bs[15] = Centre_Horizontal_Surrounded; bs[16] = Centre_Vertical_Surrounded; bs[17] = Top_Right_Inner_Corner; bs[18] = Top_Left_Inner_Corner; bs[19] = Bottom_Right_Inner_Corner; bs[20] = Bottom_Left_Inner_Corner; bs[21] = Right_Diagonal; bs[22] = Left_Diagonal; bs[23] = Lower_Right_Filled_Diagonal; bs[24] = Lower_Left_Filled_Diagonal; bs[25] = Upper_Right_Filled_Diagonal; bs[26] = Upper_Left_Filled_Diagonal; bs[27] = Cross_Hub; bs[28] = Downward_T_Hub; bs[29] = Upward_T_Hub; bs[30] = Leftward_T_Hub; bs[31] = Rightward_T_Hub; bs[32] = Border_Bottom_Left; bs[33] = Border_Bottom_Right; bs[34] = Border_Top_Left; bs[35] = Border_Top_Right; bs[36] = Diagonal_Gate_Left; bs[37] = Diagonal_Gate_Right; bs[38] = Fork_Bottom_Left; bs[39] = Fork_Bottom_Right; bs[40] = Fork_Top_Left; bs[41] = Fork_Top_Right; bs[42] = Funnel_Bottom; bs[43] = Funnel_Left; bs[44] = Funnel_Right; bs[45] = Funnel_Top; bs[46] = Taper_Bottom_Left; bs[47] = Taper_Bottom_Right; bs[48] = Taper_Left_Bottom; bs[49] = Taper_Left_Top; bs[50] = Taper_Right_Bottom; bs[51] = Taper_Right_Top; bs[52] = Taper_Top_Left; bs[53] = Taper_Top_Right; return(bs); }
public BlockSetTest() { _fx = new FileStoreFixture(); _set = new BlockSet <BaseAction>(_fx.Store); }
public BlockSet GetSetForOrientation(BlockOrientation orientation, bool includeEmptySets) { BlockSet targetSet = null; switch (orientation) { case BlockOrientation.Bottom_Alone: { targetSet = Bottom_Alone; break; } case BlockOrientation.Bottom_Left: { targetSet = Bottom_Left; break; } case BlockOrientation.Bottom_Right: { targetSet = Bottom_Right; break; } case BlockOrientation.Bottom_Surrounded: { targetSet = Bottom_Surrounded; break; } case BlockOrientation.Centre_Alone: { targetSet = Centre_Alone; break; } case BlockOrientation.Centre_Horizontal_Surrounded: { targetSet = Centre_Horizontal_Surrounded; break; } case BlockOrientation.Centre_Surrounded: { targetSet = Centre_Surrounded; break; } case BlockOrientation.Centre_Vertical_Surrounded: { targetSet = Centre_Vertical_Surrounded; break; } case BlockOrientation.Left_Alone: { targetSet = Left_Alone; break; } case BlockOrientation.Left_Surrounded: { targetSet = Left_Surrounded; break; } case BlockOrientation.Right_Alone: { targetSet = Right_Alone; break; } case BlockOrientation.Right_Surrounded: { targetSet = Right_Surrounded; break; } case BlockOrientation.Top_Alone: { targetSet = Top_Alone; break; } case BlockOrientation.Top_Left: { targetSet = Top_Left; break; } case BlockOrientation.Top_Right: { targetSet = Top_Right; break; } case BlockOrientation.Top_Surrounded: { targetSet = Top_Surrounded; break; } case BlockOrientation.Bottom_Left_Inner_Corner: { targetSet = Bottom_Left_Inner_Corner; break; } case BlockOrientation.Bottom_Right_Inner_Corner: { targetSet = Bottom_Right_Inner_Corner; break; } case BlockOrientation.Top_Left_Inner_Corner: { targetSet = Top_Left_Inner_Corner; break; } case BlockOrientation.Top_Right_Inner_Corner: { targetSet = Top_Right_Inner_Corner; break; } case BlockOrientation.Left_Diagonal: { targetSet = Left_Diagonal; break; } case BlockOrientation.Right_Diagonal: { targetSet = Right_Diagonal; break; } case BlockOrientation.Lower_Left_Filled_Diagonal: { targetSet = Lower_Left_Filled_Diagonal; break; } case BlockOrientation.Lower_Right_Filled_Diagonal: { targetSet = Lower_Right_Filled_Diagonal; break; } case BlockOrientation.Upper_Left_Filled_Diagonal: { targetSet = Upper_Left_Filled_Diagonal; break; } case BlockOrientation.Upper_Right_Filled_Diagonal: { targetSet = Upper_Right_Filled_Diagonal; break; } case BlockOrientation.Cross_Hub: { targetSet = Cross_Hub; break; } case BlockOrientation.Downward_T_Hub: { targetSet = Downward_T_Hub; break; } case BlockOrientation.Upward_T_Hub: { targetSet = Upward_T_Hub; break; } case BlockOrientation.Leftward_T_Hub: { targetSet = Leftward_T_Hub; break; } case BlockOrientation.Rightward_T_Hub: { targetSet = Rightward_T_Hub; break; } //Gee. Regrets //There was probably a better way to do this //But here we are case BlockOrientation.Border_Bottom_Left: { targetSet = Border_Bottom_Left; break; } case BlockOrientation.Border_Bottom_Right: { targetSet = Border_Bottom_Right; break; } case BlockOrientation.Border_Top_Left: { targetSet = Border_Top_Left; break; } case BlockOrientation.Border_Top_Right: { targetSet = Border_Top_Right; break; } case BlockOrientation.Diagonal_Gate_Left: { targetSet = Diagonal_Gate_Left; break; } case BlockOrientation.Diagonal_Gate_Right: { targetSet = Diagonal_Gate_Right; break; } case BlockOrientation.Fork_Bottom_Left: { targetSet = Fork_Bottom_Left; break; } case BlockOrientation.Fork_Bottom_Right: { targetSet = Fork_Bottom_Right; break; } case BlockOrientation.Fork_Top_Left: { targetSet = Fork_Top_Left; break; } case BlockOrientation.Fork_Top_Right: { targetSet = Fork_Top_Right; break; } case BlockOrientation.Funnel_Bottom: { targetSet = Funnel_Bottom; break; } case BlockOrientation.Funnel_Left: { targetSet = Funnel_Left; break; } case BlockOrientation.Funnel_Right: { targetSet = Funnel_Right; break; } case BlockOrientation.Funnel_Top: { targetSet = Funnel_Top; break; } case BlockOrientation.Taper_Bottom_Left: { targetSet = Taper_Bottom_Left; break; } case BlockOrientation.Taper_Bottom_Right: { targetSet = Taper_Bottom_Right; break; } case BlockOrientation.Taper_Left_Bottom: { targetSet = Taper_Left_Bottom; break; } case BlockOrientation.Taper_Left_Top: { targetSet = Taper_Left_Top; break; } case BlockOrientation.Taper_Right_Bottom: { targetSet = Taper_Right_Bottom; break; } case BlockOrientation.Taper_Right_Top: { targetSet = Taper_Right_Top; break; } case BlockOrientation.Taper_Top_Left: { targetSet = Taper_Top_Left; break; } case BlockOrientation.Taper_Top_Right: { targetSet = Taper_Top_Right; break; } } if (targetSet == null || !targetSet.HasBlocks() && !includeEmptySets) { targetSet = GetDefaultSet(); } return(targetSet); }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other, bool render) { // Finds the branch point. Block <T> topmostCommon = null; if (render && !(Tip is null || other.Tip is null)) { long shorterHeight = Math.Min(this.LongCount(), other.LongCount()) - 1; for ( Block <T> t = this[shorterHeight], o = other[shorterHeight]; t.PreviousHash is HashDigest <SHA256> tp && o.PreviousHash is HashDigest <SHA256> op; t = Blocks[tp], o = other.Blocks[op] ) { if (t.Equals(o)) { topmostCommon = t; break; } } } if (render) { // Unrender stale actions. for ( Block <T> b = Tip; !(b is null) && b.Index > (topmostCommon?.Index ?? -1) && b.PreviousHash is HashDigest <SHA256> ph; b = Blocks[ph] ) { List <ActionEvaluation> evaluations = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a)) .Select(te => te.Item2).ToList(); if (Policy.BlockAction is IAction) { evaluations.Add(EvaluateBlockAction(b, evaluations)); } evaluations.Reverse(); foreach (var evaluation in evaluations) { evaluation.Action.Unrender( evaluation.InputContext, evaluation.OutputStates ); } } } try { _rwlock.EnterWriteLock(); var tipChangedEventArgs = new TipChangedEventArgs { PreviousHash = Tip?.Hash, PreviousIndex = Tip?.Index, Hash = other.Tip.Hash, Index = other.Tip.Index, }; Guid obsoleteId = Id; Id = other.Id; Store.SetCanonicalChainId(Id); Blocks = new BlockSet <T>(Store); TipChanged?.Invoke(this, tipChangedEventArgs); Transactions = new TransactionSet <T>(Store); Store.DeleteChainId(obsoleteId); } finally { _rwlock.ExitWriteLock(); } if (render) { // Render actions that had been behind. IEnumerable <Block <T> > blocksToRender = topmostCommon is Block <T> branchPoint ? this.SkipWhile(b => b.Index <= branchPoint.Index) : this; foreach (Block <T> b in blocksToRender) { List <ActionEvaluation> evaluations = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a)) .Select(te => te.Item2).ToList(); if (Policy.BlockAction is IAction) { evaluations.Add(EvaluateBlockAction(b, evaluations)); } foreach (var evaluation in evaluations) { evaluation.Action.Render( evaluation.InputContext, evaluation.OutputStates ); } } } }
// FIXME it's very dangerous because replacing Id means // ALL blocks (referenced by MineBlock(), etc.) will be changed. // we need to add a synchronization mechanism to handle this correctly. internal void Swap(BlockChain <T> other) { // Finds the branch point. Block <T> topmostCommon = null; long shorterHeight = Math.Min(this.LongCount(), other.LongCount()) - 1; for ( Block <T> t = this[shorterHeight], o = other[shorterHeight]; t.PreviousHash is HashDigest <SHA256> tp && o.PreviousHash is HashDigest <SHA256> op; t = Blocks[tp], o = other.Blocks[op] ) { if (t.Equals(o)) { topmostCommon = t; break; } } // Unrender stale actions. for ( Block <T> b = Tip; !(b is null) && b.Index > (topmostCommon?.Index ?? -1) && b.PreviousHash is HashDigest <SHA256> ph; b = Blocks[ph] ) { var actions = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a) ).Reverse(); foreach (var(_, evaluation) in actions) { evaluation.Action.Unrender( evaluation.InputContext, evaluation.OutputStates ); } } try { _rwlock.EnterWriteLock(); Id = other.Id; Blocks = new BlockSet <T>(Store); Transactions = new TransactionSet <T>(Store); } finally { _rwlock.ExitWriteLock(); } // Render actions that had been behind. IEnumerable <Block <T> > blocksToRender = topmostCommon is Block <T> branchPoint ? this.SkipWhile(b => b.Index <= branchPoint.Index) : this; foreach (Block <T> b in blocksToRender) { var actions = b.EvaluateActionsPerTx(a => GetStates(new[] { a }, b.PreviousHash).GetValueOrDefault(a) ); foreach (var(_, evaluation) in actions) { evaluation.Action.Render( evaluation.InputContext, evaluation.OutputStates ); } } }