Пример #1
0
	public void UpdateMeshesOnThread(MyMesh MeshData, Blocks MyBlocks) {
		if (!IsUpdatingMesh) {
			IsUpdatingMesh = true;
			UnityThreading.ActionThread NewThread = UnityThreadHelper.CreateThread(() =>
			                                                                       {
				// thread processing
				GenerateAllMeshes(MeshData, MyBlocks);
			});
		}
	}
		void Deobfuscate(MethodDef method, Action<Blocks> handler) {
			if (HasNonEmptyBody(method)) {
				var blocks = new Blocks(method);

				handler(blocks);

				IList<Instruction> allInstructions;
				IList<ExceptionHandler> allExceptionHandlers;
				blocks.GetCode(out allInstructions, out allExceptionHandlers);
				DotNetUtils.RestoreBody(method, allInstructions, allExceptionHandlers);
			}
		}
        public static Blocks ModelToEnity(this BlocksModel model, bool virtualActive = false)
        {
            Blocks entity = new Blocks()
            {
                BlockName=model.BlockName,
                Id = model.Id,
                IsActive = model.IsActive
            };
            if (virtualActive)
            {
                entity.BlockFloors = model.BlockFloors;

            }
            return entity;
        }
Пример #4
0
 public OnePlayerLevel(IList<IItem> i, IList<IEnemy> e, IList<IBlock> b, IList<IProjectile> p, Mario m, Camera c, HUD h, SoundEffects s, Blocks.Flagpole f)
 {
     itemList = i;
     enemyList = e;
     blockList = b;
     projectileList = p;
     mario = m;
     camera = c;
     background = new BackgroundOne(c);
     undergroundBackground = new UndergroundBackground(c);
     hud = h;
     sound = s;
     flagpole = f;
     onFlagpole = false;
 }
		public MethodDef Deobfuscate(MethodDef method) {
			MethodDef deobfuscatedMethod;
			if (deobfuscated.TryGetValue(method, out deobfuscatedMethod))
				return deobfuscatedMethod;

			if (method.Body == null || method.Body.Instructions.Count == 0) {
				deobfuscated[method] = method;
				return method;
			}

			deobfuscatedMethod = DotNetUtils.Clone(method);
			deobfuscated[method] = deobfuscatedMethod;

			var blocks = new Blocks(deobfuscatedMethod);
			Deobfuscate(blocks);
			IList<Instruction> allInstructions;
			IList<ExceptionHandler> allExceptionHandlers;
			blocks.GetCode(out allInstructions, out allExceptionHandlers);
			DotNetUtils.RestoreBody(deobfuscatedMethod, allInstructions, allExceptionHandlers);

			return deobfuscatedMethod;
		}
Пример #6
0
        public MapSpot(int id, Blocks blocks, int width, int height, ISignFormat signFormat)
        {
            Id = id;
            Width = width;
            Height = height;

            var spotWidth = Width + 4;
            var spotHeight = Height + 4;
            var mapsInRow = (blocks.Width - 2)/spotWidth;
            var x = spotWidth*(id%mapsInRow);
            var y = spotHeight*(id/mapsInRow);

            SignPoint = new Point(x + 2, y + 2);
            MapPoint = new Point(x + 3, y + 3);

            var block = blocks.At(SignPoint).Foreground.Block;
            if (block.Type != ForegroundType.Sign)
                return;

            MapData mapData;
            if (!signFormat.TryGetMapData(block.Text, "", out mapData))
                return;
            Map = new Map(blocks, new Rectangle(MapPoint.X, MapPoint.Y, Width, Height), mapData.Name, mapData.Creators);
        }
Пример #7
0
	/*public void ClearTerrain(Blocks MyBlocks) {
		for (int i = 0; i < MyBlocks.Size.x; i++)
			for (int j = 0; j < MyBlocks.Size.y; j++)
			for (int k = 0; k < MyBlocks.Size.z; k++) {
				MyBlocks.ClearBlockMesh(new Vector3(i,j,k));
			}
	}*/

	public void GenerateAllMeshes(MyMesh MeshData, Blocks MyBlocks) {
		//CreateSunlight ();
		MeshData.ClearMesh ();
		if (!IsSmoothTerrain) {
			// Just want to update any blocks that were changed and its surrounding ones
			// MyBlocks class keeps the mesh data stored in memory rather then remaking the meshes every time
			if (IsSubDivided) {
				//CreateMeshFromBlocksSubdivision (DefaultSubDivisionLevel);
			} else {
				CreateMeshFromBlocks (MyBlocks, MeshData);
			}
			for (int i = 0; i < MyBlocks.Size.x; i++)
				for (int j = 0; j < MyBlocks.Size.y; j++)
				for (int k = 0; k < MyBlocks.Size.z; k++) {
					if (MyBlocks.GetBlockType(new Vector3(i,j,k)) != 0) {
						MeshData.Add (MyBlocks.GetBlock(new Vector3(i,j,k)).GetBlockMesh());
					}
				}
			CanUpdateMesh = true;
		} else {
			//CreateSmoothTerrain ();
			//UpdateMesh ();
		}
	}
Пример #8
0
 void drawBlock(Blocks j) {
     foreach(Point x in j.Points) {drawCube(x,j.Color); }
 }
Пример #9
0
 private void drawBlock(Blocks j, bool clean,Graphics g){
     Blocks s=new Blocks(0,0,j.Type);
     foreach(Point x in s.Points) {drawCube(x,clean?Color.Black:j.Color,g); }
 }
 public bool ShouldSerializeAttachments() => Blocks?.Any() ?? false;
Пример #11
0
        public sealed override Task <bool> Initialize()
        {
            // Add a block that represents entry points
            var entryPointOutputs = new[]
            {
                nameof(GraphicsCompositorAsset.Game),
                nameof(GraphicsCompositorAsset.SingleView),
                nameof(GraphicsCompositorAsset.Editor)
            };
            var entryPoint = new EntryPointBlockViewModel(this, graphicsCompositorNode, entryPointOutputs);

            entryPoint.Initialize();
            entryPoint.UpdateSlots();
            Blocks.Add(entryPoint);

            // Add blocks
            sharedRenderersNode.ItemChanged += SharedRenderersChanged;
            foreach (var sharedRendererNode in sharedRenderersNode.ItemReferences)
            {
                var sharedRenderer = (ISharedRenderer)sharedRendererNode.TargetNode.Retrieve();
                AddSharedRendererViewModel(sharedRenderer);
            }

            // Now that we have all blocks with all slots, we can update all links
            foreach (var block in Blocks)
            {
                foreach (var slot in block.OutputSlots.Cast <GraphicsCompositorSlotViewModel>())
                {
                    slot.UpdateLink();
                }
            }

            // TODO: Relayout the graph?

            // Add render stages
            renderStagesNode.ItemChanged += RenderStagesChanged;
            foreach (var renderStage in (IEnumerable <RenderStage>)renderStagesNode.Retrieve())
            {
                RenderStages.Add(new RenderStageViewModel(this, renderStage));
            }

            // Add render features
            renderFeaturesNode.ItemChanged += RenderFeaturesChanged;
            foreach (var renderFeature in (IEnumerable <RenderFeature>)renderFeaturesNode.Retrieve())
            {
                RenderFeatures.Add(new RenderFeatureViewModel(this, renderFeature));
            }

            // Add camera slots
            cameraSlotsNode.ItemChanged += CamerasSlotsChanged;
            foreach (var cameraSlot in (IEnumerable <SceneCameraSlot>)cameraSlotsNode.Retrieve())
            {
                CameraSlots.Add(new GraphicsCompositorCameraSlotsViewModel(this, cameraSlot));
            }

            // Update property grid on selected events
            SelectedRenderStages.CollectionChanged    += SelectionChanged;
            SelectedRenderFeatures.CollectionChanged  += SelectionChanged;
            SelectedCameraSlots.CollectionChanged     += SelectionChanged;
            SelectedSharedRenderers.CollectionChanged += SelectionChanged;
            SelectedRendererLinks.CollectionChanged   += SelectionChanged;

            // Make selection scope exclusives
            ServiceProvider.Get <SelectionService>().RegisterSelectionScope(id => RenderStages.FirstOrDefault(x => x.Id == id), obj => (obj as RenderStageViewModel)?.Id, SelectedRenderStages);
            ServiceProvider.Get <SelectionService>().RegisterSelectionScope(id => RenderFeatures.FirstOrDefault(x => x.Id == id), obj => (obj as RenderFeatureViewModel)?.Id, SelectedRenderFeatures);
            ServiceProvider.Get <SelectionService>().RegisterSelectionScope(id => CameraSlots.FirstOrDefault(x => x.Id == id), obj => (obj as GraphicsCompositorCameraSlotsViewModel)?.Id, SelectedCameraSlots);
            ServiceProvider.Get <SelectionService>().RegisterSelectionScope(id => Blocks.OfType <GraphicsCompositorBlockViewModel>().FirstOrDefault(x => x.Id == id), obj => (obj as GraphicsCompositorBlockViewModel)?.Id, SelectedSharedRenderers);

            // Update available types for factories
            UpdateAvailableTypes();
            AssemblyRegistry.AssemblyRegistered   += AssembliesUpdated;
            AssemblyRegistry.AssemblyUnregistered += AssembliesUpdated;

            return(Task.FromResult(true));
        }
Пример #12
0
        private ScriptBlockStatement ParseBlockStatement(ScriptNode parentStatement, bool parseEndOfStatementAfterEnd = true)
        {
            Debug.Assert(!(parentStatement is ScriptBlockStatement));

            Blocks.Push(parentStatement);

            _blockLevel++;
            EnterExpression();

            var blockStatement         = Open <ScriptBlockStatement>();
            var previousBlockStatement = _currentBlockStatement;

            _currentBlockStatement = blockStatement;
            try
            {
                ScriptStatement statement;
                bool            hasEnd;
                while (TryParseStatement(parentStatement, parseEndOfStatementAfterEnd, out statement, out hasEnd))
                {
                    // statement may be null if we have parsed an else continuation of a previous block
                    if (statement != null)
                    {
                        blockStatement.Statements.Add(statement);
                    }

                    if (hasEnd)
                    {
                        break;
                    }
                }

                // Don't emit an EOS for an end statement that doesn't expect it
                if (!parseEndOfStatementAfterEnd && statement is ScriptEndStatement endStatement)
                {
                    endStatement.ExpectEos = false;
                }

                if (!hasEnd)
                {
                    // If there are any end block not matching, we have an error
                    if (_blockLevel > 1)
                    {
                        if (_isLiquid)
                        {
                            var syntax = ScriptSyntaxAttribute.Get(parentStatement);
                            LogError(parentStatement, parentStatement?.Span ?? CurrentSpan, $"The `end{syntax.TypeName}` was not found");
                        }
                        else
                        {
                            // unit test: 201-if-else-error2.txt
                            LogError(parentStatement, GetSpanForToken(Previous), $"The <end> statement was not found");
                        }
                    }
                }
            }
            finally
            {
                _currentBlockStatement = previousBlockStatement;
                LeaveExpression();
                _blockLevel--;
            }


            Blocks.Pop();
            return(Close(blockStatement));
        }
Пример #13
0
 public override void DoRollbackOthers(object[] ules)
 {
     Debug.Assert(othersULE != null);
     Debug.Assert(!othersULE.IsDirty);
     for (int i = 0, n = ules.Length; i < n; i++)
     {
         if (ules[i] == null)
             continue;
         OthersULE ule = (OthersULE)ules[i];
         if (ule.nextBlockChanged)
             privNextBlock = ule.savedNextBlock;
         if (ule.handlerBlockChanged)
             privHandlerBlock = ule.savedHandlerBlock;
     }
 }
Пример #14
0
 protected virtual void deobfuscateEnd(Blocks blocks, IList <Block> allBlocks)
 {
 }
		public virtual void DeobfuscateBegin(Blocks blocks) {
			this.blocks = blocks;
		}
Пример #16
0
    //Haalt de resultaten op voor de beheerder (toont zowel de winnaar als het aantal stemmen per team)
    public static string UitslagStemmingBeheerder(string Stemming)
    {
        if (GebruikBlockchain)
        {
            Blocks.Decodeer(Stemming);
        }

        DatabaseConnectie dbconnect     = new DatabaseConnectie();
        SqlConnection     sqlConnection = new SqlConnection(dbconnect.dbConnectie);

        string Uitslag = "<h1>Uitslagen van " + Stemming + "</h1></br> ";

        //Haalt de winnaar op
        SqlCommand winnaar = new SqlCommand("SELECT GestemdOp, Count(GestemdOp)AS 'AantalGestemd' FROM UC WHERE StemmingsNaam = '" + Stemming + "' GROUP BY GestemdOp ORDER BY AantalGestemd DESC;", sqlConnection);

        sqlConnection.Open();

        //Selecteert het project met de meeste stemmen
        if (GebruikBlockchain)
        {
            ////Winnaar ophalen met LINQ werkt nog niet goed
            //var maxValue = Blocks.GestemdOp.Max(x => x);
            //var Winnaar = Blocks.GestemdOp.Select(x => x == maxValue);
            ////string Winnaar = ((from x in Blocks.GestemdOp select x.Count())).Max();
            //Console.WriteLine(Winnaar);
            //Uitslag += "<h4>Winnaar:<br />" + Winnaar + "</h4><br />";

            //Haalt de winnaar op zonder blockchain (omdat met blockchain nog niet werkt):
            Uitslag += "<h4>Winnaar:<br />" + winnaar.ExecuteScalar() + "</h4><br />";
        }
        else
        {
            Uitslag += "<h4>Winnaar:<br />" + winnaar.ExecuteScalar() + "</h4><br />";
        }

        //Haalt op hoeveel unieke codes er bij deze stemming zijn aangemaakt
        SqlCommand AantalUniekeCodes = new SqlCommand("SELECT COUNT(UniekeCode) FROM UC WHERE StemmingsNaam = '" + Stemming + "'", sqlConnection);
        int        AantalCodes       = (int)AantalUniekeCodes.ExecuteScalar();

        //Haalt op hoeveel unieke codes er bij deze stemming met een telefoonnummer gelinkt zijn
        SqlCommand UitgegevenUniekeCodes = new SqlCommand("SELECT COUNT(UniekeCode) FROM UC WHERE StemmingsNaam = '" + Stemming + "' AND HashTelNr IS NOT NULL", sqlConnection);
        int        UitgegevenCodes       = (int)UitgegevenUniekeCodes.ExecuteScalar();

        //Haalt op hoe vaak er gestemd is:
        SqlCommand AantalKeerGestemd = new SqlCommand("SELECT COUNT(UniekeCode) FROM UC WHERE StemmingsNaam = '" + Stemming + "' AND GestemdOp IS NOT NULL", sqlConnection);
        int        KeerGestemd       = (int)AantalKeerGestemd.ExecuteScalar();

        Uitslag += "<h5>Voor deze stemming zijn " + AantalCodes + " unieke codes aangemaakt.<br />";
        Uitslag += "Er zijn " + UitgegevenCodes + " SMS'jes verstuurd.<br />";
        Uitslag += "Uiteindelijk is er " + KeerGestemd + " keer gestemd.<br /><h5>";

        //Gesorteerd op hoeveelheid stemmen
        SqlDataAdapter asd = new SqlDataAdapter("SELECT project.naam, Count(UC.GestemdOp) as aantal_stemmen FROM project LEFT JOIN(SELECT gestemdOp FROM UC WHERE UC.stemmingsnaam = '" + Stemming + "') as UC ON project.naam = UC.gestemdOp WHERE project.stemmingsnaam = '" + Stemming + "' GROUP BY project.naam ORDER BY aantal_stemmen DESC", sqlConnection);

        //Gesorteerd op naam
        //SqlDataAdapter asd = new SqlDataAdapter("SELECT project.naam, Count(UC.GestemdOp) as aantal_stemmen FROM project LEFT JOIN(SELECT gestemdOp FROM UC WHERE UC.stemmingsnaam = '" + Stemming + "') as UC ON project.naam = UC.gestemdOp WHERE project.stemmingsnaam = '" + Stemming + "' GROUP BY project.naam", sqlConnection);

        DataTable dt = new DataTable();

        asd.Fill(dt);

        Uitslag += "<table>";
        foreach (DataRow row in dt.Rows)
        {
            //Haalt het aantal keer dat op een project gestemd is op
            if (GebruikBlockchain)
            {
                int AantalStemmen = 0;
                AantalStemmen = (from x in Blocks.GestemdOp where x == (string)row["Naam"] select x).Count();
                Uitslag      += "<tr><td>" + row["Naam"] + "</td><td>" + AantalStemmen + "</td></tr>";
            }
            else
            {
                Uitslag += "<tr><td>" + row["Naam"] + "</td><td>" + row["aantal_stemmen"] + "</td></tr>";
            }
        }
        Uitslag += "</table>";
        sqlConnection.Close();
        //Returnt een string met daarin de winnaar en daaronder per project het aantal stemmen
        return(Uitslag);
    }
Пример #17
0
 protected abstract bool deobfuscate(Blocks blocks, IList <Block> allBlocks);
Пример #18
0
 public bool ContainsBlockType(BlockType type)
 {
     return(Blocks.Exists(b => b.Type == type));
 }
Пример #19
0
 public Block GetBlockByType(BlockType type)
 {
     return(Blocks.Find(b => b.Type == type));
 }
Пример #20
0
        /// <summary>
        /// Reads the given <see cref="Stream"/>.
        /// </summary>
        /// <param name="input">The input <see cref="Stream"/> to read from.</param>
        public void Read(Stream input)
        {
            Reader = new BinaryReader(input);

            FileSize = Reader.ReadUInt32();

            if (FileSize == 0x55AA1234)
            {
                throw new InvalidDataException("Use ValvePak library to parse VPK files.\nSee https://github.com/SteamDatabase/ValvePak");
            }

            if (FileSize == CompiledShader.MAGIC)
            {
                throw new InvalidDataException("Use CompiledShader() class to parse compiled shader files.");
            }

            // TODO: Some real files seem to have different file size
            if (FileSize != Reader.BaseStream.Length)
            {
                //throw new Exception(string.Format("File size does not match size specified in file. {0} != {1}", FileSize, Reader.BaseStream.Length));
            }

            HeaderVersion = Reader.ReadUInt16();

            if (HeaderVersion != KnownHeaderVersion)
            {
                throw new InvalidDataException(string.Format("Bad header version. ({0} != expected {1})", HeaderVersion, KnownHeaderVersion));
            }

            Version = Reader.ReadUInt16();

            var blockOffset = Reader.ReadUInt32();
            var blockCount  = Reader.ReadUInt32();

            Reader.BaseStream.Position += blockOffset - 8; // 8 is 2 uint32s we just read

            for (var i = 0; i < blockCount; i++)
            {
                var blockType = Encoding.UTF8.GetString(Reader.ReadBytes(4));

                var   position = Reader.BaseStream.Position;
                var   offset   = (uint)position + Reader.ReadUInt32();
                var   size     = Reader.ReadUInt32();
                Block block    = null;

                // Peek data to detect VKV3
                // Valve has deprecated NTRO as reported by resourceinfo.exe
                if (size >= 4 && blockType == "DATA")
                {
                    Reader.BaseStream.Position = offset;

                    var magic = Reader.ReadUInt32();

                    if (magic == BinaryKV3.MAGIC || magic == BinaryKV3.MAGIC2)
                    {
                        block = new BinaryKV3();
                    }

                    Reader.BaseStream.Position = position;
                }

                if (block == null)
                {
                    block = ConstructFromType(blockType);
                }

                block.Offset = offset;
                block.Size   = size;
                block.Read(Reader, this);

                Blocks.Add(block);

                switch (block.Type)
                {
                case BlockType.REDI:
                    // Try to determine resource type by looking at first compiler indentifier
                    if (ResourceType == ResourceType.Unknown && EditInfo.Structs.ContainsKey(ResourceEditInfo.REDIStruct.SpecialDependencies))
                    {
                        var specialDeps = (SpecialDependencies)EditInfo.Structs[ResourceEditInfo.REDIStruct.SpecialDependencies];

                        if (specialDeps.List.Count > 0)
                        {
                            ResourceType = DetermineResourceTypeByCompilerIdentifier(specialDeps.List[0]);
                        }
                    }

                    break;

                case BlockType.NTRO:
                    if (ResourceType == ResourceType.Unknown && IntrospectionManifest.ReferencedStructs.Count > 0)
                    {
                        switch (IntrospectionManifest.ReferencedStructs[0].Name)
                        {
                        case "VSoundEventScript_t":
                            ResourceType = ResourceType.SoundEventScript;
                            break;

                        case "CWorldVisibility":
                            ResourceType = ResourceType.WorldVisibility;
                            break;
                        }
                    }

                    break;
                }

                Reader.BaseStream.Position = position + 8;
            }
        }
		public void Initialize(Blocks blocks, bool emulateFromFirstInstruction) {
			Initialize(blocks.Method, emulateFromFirstInstruction);
		}
Пример #22
0
 protected override void deobfuscateEnd(Blocks blocks, IList <Block> allBlocks)
 {
     fixBrokenCalls(blocks.Method, allBlocks);
 }
Пример #23
0
 public BlockAreaEnumerable(Blocks blocks, Rectangle area)
 {
     this.Blocks = blocks;
     this.Area = area;
 }
        public void deobfuscate(Blocks blocks)
        {
            if (arrayDecrypter == null)
            {
                return;
            }

            var infos = new List <ArrayInfo>();

            foreach (var block in blocks.MethodBlocks.getAllBlocks())
            {
                var instrs = block.Instructions;
                infos.Clear();
                for (int i = 0; i < instrs.Count - 6; i++)
                {
                    int index = i;

                    var ldci4 = instrs[index++];
                    if (!ldci4.isLdcI4())
                    {
                        continue;
                    }

                    var newarr = instrs[index++];
                    if (newarr.OpCode.Code != Code.Newarr)
                    {
                        continue;
                    }
                    if (newarr.Operand == null || newarr.Operand.ToString() != "System.Byte")
                    {
                        continue;
                    }

                    if (instrs[index++].OpCode.Code != Code.Dup)
                    {
                        continue;
                    }

                    var ldtoken = instrs[index++];
                    if (ldtoken.OpCode.Code != Code.Ldtoken)
                    {
                        continue;
                    }
                    var field = ldtoken.Operand as FieldDef;
                    if (field == null)
                    {
                        continue;
                    }

                    var call1 = instrs[index++];
                    if (call1.OpCode.Code != Code.Call && call1.OpCode.Code != Code.Callvirt)
                    {
                        continue;
                    }
                    if (!DotNetUtils.isMethod(call1.Operand as IMethod, "System.Void", "(System.Array,System.RuntimeFieldHandle)"))
                    {
                        continue;
                    }

                    var call2 = instrs[index++];
                    if (call2.OpCode.Code != Code.Call && call2.OpCode.Code != Code.Callvirt)
                    {
                        continue;
                    }
                    if (!MethodEqualityComparer.CompareDeclaringTypes.Equals(call2.Operand as IMethod, arrayDecrypter))
                    {
                        continue;
                    }

                    var castclass = instrs[index++];
                    if (castclass.OpCode.Code != Code.Castclass)
                    {
                        continue;
                    }
                    var arrayType = (castclass.Operand as ITypeDefOrRef).TryGetSZArraySig();
                    if (arrayType == null)
                    {
                        continue;
                    }
                    if (arrayType.Next.ElementType.GetPrimitiveSize() == -1)
                    {
                        Logger.w("Can't decrypt non-primitive type array in method {0:X8}", blocks.Method.MDToken.ToInt32());
                        continue;
                    }

                    infos.Add(new ArrayInfo(i, index - i, field, arrayType));
                }

                infos.Reverse();
                foreach (var info in infos)
                {
                    var elemSize  = info.arrayType.Next.ElementType.GetPrimitiveSize();
                    var decrypted = decryptArray(info.encryptedField.InitialValue, elemSize);

                    initializedDataCreator.addInitializeArrayCode(block, info.start, info.len, info.arrayType.Next.ToTypeDefOrRef(), decrypted);
                    Logger.v("Decrypted {0} array: {1} elements", info.arrayType.Next.ToString(), decrypted.Length / elemSize);
                }
            }
        }
Пример #25
0
	/*public void CreateMeshFromBlocksSubdivision(int SubDivisionLevel) {	// example im coding for is 2
		ClearMeshes ();
		TerrainMesh.FaceCount = 0;
		//customMesh.ClearMesh();
		Debug.Log ("Adding Cubes as Models.");
		CubeCount = 0;
		float MaxSize = MyBlocks.Size.x;
		if (MaxSize < MyBlocks.Size.y)
			MaxSize = MyBlocks.Size.y;
		if (MaxSize < MyBlocks.Size.z)
			MaxSize = MyBlocks.Size.z;
		if (MaxSize % 2 == 1) 
			MaxSize += 1;
		float MaxX = MaxSize;	//MyBlocks.Size.x-(Mathf.RoundToInt(MyBlocks.Size.x) % SubDivisionLevel);
		float MaxY = MaxSize;	//MyBlocks.Size.y-(Mathf.RoundToInt(MyBlocks.Size.y) % SubDivisionLevel);
		float MaxZ = MaxSize;	//MyBlocks.Size.z-(Mathf.RoundToInt(MyBlocks.Size.z) % SubDivisionLevel);
		Debug.LogError ("MaxX: " + MaxX + " : MaxY: " + MaxY + " : MaxZ: " + MaxZ);
		for (int i = 0; i < MaxX; i += SubDivisionLevel)
			for (int j = 0; j < MaxY;  j += SubDivisionLevel)
			for (int k = 0; k < MaxZ;  k += SubDivisionLevel) {
				MyBlocks.GetBlockMesh(new Vector3(i,j,k)).ClearMesh ();
				
				int NewBlockType = GetBlockTypeInGroup(i, j, k, SubDivisionLevel);
				//Debug.LogError ("At block: " + i + ": j: " + j + ":k:" + k + " BlockType: " + NewBlockType);
				if (NewBlockType > 0) {	// if no mesh create a mesh 
					//if (MyBlocks.GetBlock(new Vector3(i,j,k)).HasChanged) {	// if no mesh create a mesh 
					MyBlocks.GetBlock(new Vector3(i,j,k)).HasChanged = false;
					CubeCount++;
					//Debug.Log ("Adding Cube number: " + CubeCount + " Pos: " + i + " : " + j + " : " + k);
					bool IsFrontFace = false;
					bool IsBackFace = false;
					bool IsLeftFace = false;
					bool IsRightFace = false;
					bool IsTopFace = false;
					bool IsBottomFace = false;
					
					// the bug is definitely here in the culling
					
					//if (i+SubDivisionLevel <= MaxX)
					if (!IsBlockInGroup(i+SubDivisionLevel+1,j,k,SubDivisionLevel)) // should be something that searches the chunk, then searches the world which is referenced in chunk
						IsRightFace = true;
					//if (i-SubDivisionLevel >= 0)
					if (!IsBlockInGroup(i-SubDivisionLevel-1,j,k,SubDivisionLevel)) 
						IsLeftFace = true;
					
					//if (k+SubDivisionLevel <= MaxZ)
					if (!IsBlockInGroup(i,j,k+SubDivisionLevel+1,SubDivisionLevel)) 
						IsFrontFace = true;
					//if (k-SubDivisionLevel >= 0)
					if (!IsBlockInGroup(i,j,k-SubDivisionLevel-1,SubDivisionLevel))
						IsBackFace = true;
					
					//if (j+SubDivisionLevel <=MaxY)
					if (!IsBlockInGroup(i,j+SubDivisionLevel+1,k,SubDivisionLevel))
						IsTopFace = true;
					//if (j-SubDivisionLevel >= 0)
					if (!IsBlockInGroup(i,j-SubDivisionLevel-1,k,SubDivisionLevel))
						IsBottomFace = true;
					
					IsLeftFace = true;
						IsRightFace = true;
						IsBottomFace = true;
						IsTopFace = true;
						IsBackFace = true;	// this one faces cam
						IsFrontFace = true;
					
					
					Vector3 TemporaryCubeSize = new Vector3(CubeSize.x*SubDivisionLevel, CubeSize.y*SubDivisionLevel,CubeSize.z*SubDivisionLevel);
					
					Vector3 NewCubePosition = new Vector3 (((float)(i)) * TemporaryCubeSize.x/((float)SubDivisionLevel),
					                                       ((float)(j)) * TemporaryCubeSize.y/((float)SubDivisionLevel), 
					                                       ((float)(k)) * TemporaryCubeSize.z/((float)SubDivisionLevel));
					//MyBlocks.Data [i].Data [j].Data [k].BlockMesh.FaceCount = TerrainMesh.FaceCount;	// has to correspond to its positioning in the mesh
					
					int TileIndex = NewBlockType;	//MyBlocks.GetBlockType (new Vector3(i,j,k));
					//TileIndex = 2;
					Vector2 TilesPosition = new Vector2();
					// Every Column
					TilesPosition.x = (TileIndex % MaxTiles);	// 4 = 3,1  - 5 = 2,1 - 6 = 1,1 - 7 = 0,1
					// Every Row
					TilesPosition.y = (TileIndex / MaxTiles);		// 4 - 1 = 5 - 1
					
					//Debug.LogError ("Now updating with tile index: " + TileIndex + " : At TilePosition: " + TilesPosition.ToString());
					
					MyBlocks.GetBlockMesh(new Vector3(i,j,k)).CreateCube (NewCubePosition,
					                                                      TemporaryCubeSize, 
					                                                      IsFrontFace, IsBackFace, IsLeftFace, IsRightFace, IsTopFace, IsBottomFace, 
					                                                      TilesPosition, 
					                                                      new Color32(255,255,255,255));
					
					// MyBlocks.Data[i].Data[j].Data[k].MyColor);
					
					//MyBlocks.Data [i].Data [j].Data [k].BlockMesh.FaceCount -= TerrainMesh.FaceCount;
					//TerrainMesh.FaceCount += MyBlocks.Data [i].Data [j].Data [k].BlockMesh.FaceCount;
					
					//TerrainMesh.Add (MyBlocks.Data [i].Data [j].Data [k].BlockMesh);
				} else {
					//Debug.LogError ("At block: " + i + ": j: " + j + ":k:" + k + " BlockType: " + NewBlockType);
				}
			}
	}*/
	// creates the mesh - should keep track of the mesh
	public void CreateMeshFromBlocks(Blocks MyBlocks, MyMesh TerrainMesh) {
		TerrainMesh.FaceCount = 0;
		
		for (int i = 0; i < MyBlocks.Size.x; i++)
			for (int j = 0; j < MyBlocks.Size.y; j++)
			for (int k = 0; k < MyBlocks.Size.z; k++) {
				//MyBlocks.Data [i].Data [j].Data [k].BlockMesh.ClearMesh ();
				//if (MyBlocks.Data [i].Data [j].Data [k].Type != 0) 
				if (MyBlocks.GetBlock(new Vector3(i,j,k)).HasChanged()) { //has no mesh create a mesh 
					MyBlocks.ClearBlockMesh(new Vector3(i,j,k));
					//Debug.Log ("Adding Cube number: " + CubeCount + " Pos: " + i + " : " + j + " : " + k);
					bool IsFrontFace = false;
					bool IsBackFace = false;
					bool IsLeftFace = false;
					bool IsRightFace = false;
					bool IsTopFace = false;
					bool IsBottomFace = false;
					
					if (i != MyBlocks.Size.x - 1)
						if (MyBlocks.GetBlockType (new Vector3 (i + 1, j, k)) == 0)	// should be something that searches the chunk, then searches the world which is referenced in chunk
							IsRightFace = true;
					if (i != 0) 
						if (MyBlocks.GetBlockType (new Vector3 (i - 1, j, k)) == 0)
							IsLeftFace = true;
					if (k != MyBlocks.Size.z - 1) 	// if not on edge
						if (MyBlocks.GetBlockType (new Vector3 (i, j, k + 1)) == 0)
							IsFrontFace = true;
					if (k != 0)
						if (MyBlocks.GetBlockType (new Vector3 (i, j, k - 1)) == 0)
							IsBackFace = true;
					if (j != MyBlocks.Size.y - 1)
						if (MyBlocks.GetBlockType (new Vector3 (i, j + 1, k)) == 0)
							IsTopFace = true;
					if (j != 0)
						if (MyBlocks.GetBlockType (new Vector3 (i, j - 1, k)) == 0)
							IsBottomFace = true;
					if (i == 0)
						IsLeftFace = true;
					if (i == MyBlocks.Size.x - 1)
						IsRightFace = true;
					if (j == 0)
						IsBottomFace = true;
					if (j == MyBlocks.Size.y - 1)
						IsTopFace = true;
					if (k == 0)
						IsBackFace = true;
					if (k == MyBlocks.Size.z - 1)
						IsFrontFace = true;
					
					Vector3 NewCubePosition = new Vector3 (((float)(i)) * MyBlocks.Scale.x, 
					                                       ((float)(j)) * MyBlocks.Scale.y, 
					                                       ((float)(k)) * MyBlocks.Scale.z);
					//MyBlocks.Data [i].Data [j].Data [k].BlockMesh.FaceCount = TerrainMesh.FaceCount;
					
					int TileIndex = MyBlocks.GetBlockType (new Vector3(i,j,k));
					//TileIndex = 2;
					Vector2 TilesPosition = new Vector2();
					// Every Column
					TilesPosition.x = (TileIndex % TileMapLength);	// 4 = 3,1  - 5 = 2,1 - 6 = 1,1 - 7 = 0,1
					// Every Row
					TilesPosition.y = (TileIndex / TileMapLength);		// 4 - 1 = 5 - 1
					
					//Debug.LogError ("Now updating with tile index: " + TileIndex + " : At TilePosition: " + TilesPosition.ToString());
					
					MyBlocks.GetBlockMesh(new Vector3(i,j,k)).CreateCube (NewCubePosition, 
					                                                      MyBlocks.Scale, 
					                                                          IsFrontFace, IsBackFace, IsLeftFace, IsRightFace, IsTopFace, IsBottomFace, 
					                                                          TilesPosition, 
					                                                          new Color32(255,255,255,255));
					// MyBlocks.Data[i].Data[j].Data[k].MyColor);
				}
			}
	}
Пример #26
0
        public Block GetBlock(short x, short z)
        {
            uint index = GetIndexForCoords(x, z);

            return(Blocks.ContainsKey(index) ? Blocks[index] : null);
        }
Пример #27
0
        void ProcessBlockLocked(Block block)
        {
            var prevId = block.PreviousHash;

            Block prev;

            if (!Blocks.TryGetValue(prevId, out prev))
            {
                // If the previous block is not under the block tree, mark the
                // block as floating.
                List <ByteString> blocks;
                if (!floatingBlocks.TryGetValue(prevId, out blocks))
                {
                    floatingBlocks[prevId] = blocks = new List <ByteString>();
                }
                blocks.Add(block.Id);
                return;
            }

            // Mark the block as the connected block.
            block.Height          = prev.Height + 1;
            block.TotalDifficulty = prev.TotalDifficulty + block.Difficulty;

            // Avoid processing duplicate block from the past.
            if (Blocks.ContainsKey(block.Id))
            {
                return;
            }
            Blocks.Add(block.Id, block);

            // If the block difficulty does not surpass the current latest,
            // skip the execution.  Once the descendant block comes later,
            // evaluate the difficulty then again.
            if (Latest.TotalDifficulty >= block.TotalDifficulty)
            {
                CheckFloatingBlocks(block.Id);
                return;
            }

            // Otherwise, try to execute the block.  Considering the block folk,
            // first revert all the applied blocks prior to the fork point in
            // past blocks, if exists.  Then apply blocks after the fork.
            var fork = BlockchainUtil.LowestCommonAncestor(
                Latest, block, Blocks);
            var revertingChain = Latest.Ancestors(Blocks)
                                 .TakeWhile(x => !x.Id.Equals(fork.Id))
                                 .ToList();
            var applyingChain = block.Ancestors(Blocks)
                                .TakeWhile(x => !x.Id.Equals(fork.Id))
                                .Reverse()
                                .ToList();

            revertingChain.ForEach(Revert);

            int?failureIndex = null;

            for (var i = 0; i < applyingChain.Count; i++)
            {
                var applyBlock = applyingChain[i];
                try { Run(applyBlock); }
                catch
                {
                    // The block was invalid.  Revert.
                    PurgeBlock(applyBlock.Id);

                    failureIndex = i;
                    break;
                }

                Apply(applyBlock);
            }

            if (failureIndex.HasValue)
            {
                // Failure occurred during the block execution.  Perform
                // opposite to revert to the state before the execution.
                applyingChain.Take(failureIndex.Value)
                .Reverse().ToList().ForEach(Revert);

                revertingChain.Reverse();
                revertingChain.ForEach(Apply);
                return;
            }

            CheckFloatingBlocks(block.Id);
        }
Пример #28
0
 public bool HasBlock(short x, short z)
 {
     return(Blocks.ContainsKey(GetIndexForCoords(x, z)));
 }
Пример #29
0
 public static bool IsLiquid(Blocks material)
 {
     return material == Blocks.Still_Water || material == Blocks.Still_Lava || material == Blocks.Water || material == Blocks.Lava;
 }
Пример #30
0
 public void RemoveBlock(short x, short z)
 {
     Blocks.Remove(GetIndexForCoords(x, z));
 }
Пример #31
0
 public void AddBlock(BlockInfo block)
 {
     Blocks.Add(block);
     OnBlockAdded?.Invoke(block);
 }
Пример #32
0
 public void init(Blocks blocks, List <Block> allBlocks)
 {
     this.blocks    = blocks;
     this.allBlocks = allBlocks;
 }
Пример #33
0
        private static async Task RestClientTest()
        {
            var testAddress = "ANrL4vPnQCCi5Mro4fqKK1rxrkxEHqmp2E";

            var restService = new NeoScanRestService(NeoScanNet.MainNet); // service creation
            var token       = await restService.GetAllTokens();

            var tokenList = JsonConvert.DeserializeObject <TokenList>(token);

            // api calls
            var getBalance = await restService.GetBalanceAsync(testAddress);

            var getClaimed = await restService.GetClaimedAsync(testAddress);

            var getClaimable = await restService.GetClaimableAsync(testAddress);

            var getUnclaimed = await restService.GetUnclaimedAsync(testAddress);

            var getAddress = await restService.GetAddressAsync(testAddress);

            var nodes = await restService.GetAllNodesAsync();

            var transaction = await restService.GetTransactionAsync("599dec5897d416e9a668e7a34c073832fe69ad01d885577ed841eec52c1c52cf");

            var assets = await restService.GetAssetsAsync();

            var asset = await restService.GetAssetAsync("089cd37714d43511e304dc559e05a5a965274685dc21686bdcd05a45e17aab7a");

            var height = await restService.GetHeight();

            var highestBlock = await restService.GetHighestBlock();

            var lastBlocks = await restService.GetLastBlocks();

            var feesInRange = await restService.GetFeesInRange(4, 6);

            var abstractAddress = await restService.GetAddressAbstracts("AGbj6WKPUWHze12zRyEL5sx8nGPVN6NXUn", 0);

            var neonAddress = await restService.GetNeonAddress("AGbj6WKPUWHze12zRyEL5sx8nGPVN6NXUn");

            var addressToAddressAbstract = await restService.GetAddressToAddressAbstract("AJ5UVvBoz3Nc371Zq11UV6C2maMtRBvTJK",
                                                                                         "AZCcft1uYtmZXxzHPr5tY7L6M85zG7Dsrv", 0);

            var block = await restService.GetBlock("54ffd56d6a052567c5d9abae43cc0504ccb8c1efe817c2843d154590f0b572f7");

            var lastTransactions = await restService.GetLastTransactions();

            var lastTransactionsByAddress =
                await restService.GetLastTransactionsByAddress("AGbj6WKPUWHze12zRyEL5sx8nGPVN6NXUn", 0);

            //Deserialization
            var  balanceDto                   = AddressBalance.FromJson(getBalance);
            var  claimedDto                   = Claimed.FromJson(getClaimed);
            var  claimableDto                 = Claimable.FromJson(getClaimable);
            var  unclaimedDto                 = Unclaimed.FromJson(getUnclaimed);
            var  addressDto                   = AddressHistory.FromJson(getAddress);
            var  nodesDto                     = Node.FromJson(nodes);
            var  transactionDto               = Transaction.FromJson(transaction);
            var  assetsDto                    = Asset.FromJsonList(assets);
            var  assetDto                     = Asset.FromJson(asset);
            long chainHeight                  = Convert.ToInt64(height);
            var  highestBlockDto              = Rest.DTOs.Block.FromJson(highestBlock);
            var  lastBlocksDto                = Blocks.FromJson(lastBlocks);
            var  feesInRangeDto               = FeesInRange.FromJson(feesInRange);
            var  abstractAddressDto           = AbstractAddress.FromJson(abstractAddress);
            var  neonAddressDto               = NeonAddress.FromJson(neonAddress);
            var  addressToAddressAbstractDto  = AbstractAddress.FromJson(addressToAddressAbstract);
            var  blockDto                     = Block.FromJson(block);
            var  lastTransactionsDto          = Transactions.FromJson(lastTransactions);
            var  lastTransactionsByAddressDto = Transactions.FromJson(lastTransactionsByAddress);
        }
Пример #34
0
 public override void DeobfuscateMethodBegin(Blocks blocks)
 {
     proxyCallFixer.Deobfuscate(blocks);
     base.DeobfuscateMethodBegin(blocks);
 }
Пример #35
0
 private void drawBlock(Blocks j, bool clean){
     foreach(Point x in j.Points) {drawCube(x,clean?Color.Black:j.Color); }
 }
Пример #36
0
 public Entity(MobType type, int hp, string noise, Blocks loot)
 {
     // FIXME
 }
Пример #37
0
	//List<float> MarchingCubesData = new List<float>();
	// the outter edges of the data file will be the other chunks blocks, but they won't be rendered
	public void PolygonizeData(Blocks MyBlocks, Vector3 WorldSize_) {
		data.Clear ();
		for (int i = 0; i < (MyBlocks.Size.x)*(MyBlocks.Size.y)*(MyBlocks.Size.z); i++)
			data.Add(0.0f);
		for (int i = 0; i < MyBlocks.Size.x; i++)
			for (int j = 0; j < MyBlocks.Size.y; j++)
			for (int k = 0; k < MyBlocks.Size.z; k++) {
				Vector3 loc = new Vector3 (i, j, k);
				//Debug.Log ("Added cube " + MyBlocks.GetBlockType(loc).ToString());
				if (MyBlocks.GetBlockType(loc) != 0)  {	// if no mesh create a mes
					AddCube (loc, new Vector3 (1, 1, 1));
					//Debug.Log ("Added cube " + loc.ToString());
				}
			}

		trilist.Clear();
		CubeSize = WorldSize_;
		WorldSize = WorldSize_;
		int BlockType = 1;
		gridSize = WorldSize;
		//numxyz = WorldSize.x*WorldSize.y*WorldSize.z;
		worlddim = WorldSize;
		worldstride = new Vector3(gridSize.x / WorldSize.x, gridSize.y / WorldSize.y, gridSize.z / WorldSize.z);
		datastride = new Vector3(WorldSize_.x / gridSize.x, WorldSize_.y / gridSize.y, WorldSize_.z / gridSize.z);
		worldcenter = new Vector3(WorldSize.x / 2, WorldSize.x / 2, WorldSize.x / 2);
		
		for (int i = 0; i < MyBlocks.Size.x; i++) {
			for (int j = 0; j < MyBlocks.Size.y; j++) {
				for (int k = 0; k < MyBlocks.Size.z; k++) {
					//BlockType = NewBlockData[i].Data[j].Data[k].BlockType;// this doesn't work as the blocks don't perfec
					PolygoniseCube(i,j,k,BlockType);
				}
			}
		}
	}
Пример #38
0
        /// <summary>
        /// Generates content based on the template information
        /// </summary>
        /// <exception cref="System.Exception">ItemsPanel must be a block element</exception>
        private void GenerateContent()
        {
            if (!IsLoaded)
            {
                return;
            }

            Blocks.Clear();
            if ((ItemTemplate == null && ItemTemplateSelector == null) || ItemsSource == null)
            {
                return;
            }

            FrameworkContentElement panel = null;

            foreach (var data in ItemsSource)
            {
                if (panel == null)
                {
                    if (ItemsPanel == null)
                    {
                        panel = this;
                    }
                    else
                    {
                        var itemsPanelTemplate = LoadDataTemplate(ItemsPanel);
                        foreach (var templatePart in itemsPanelTemplate)
                        {
                            var block = templatePart as Block;
                            if (block == null)
                            {
                                throw new Exception("ItemsPanel must be a block element");
                            }
                            Blocks.Add(block);
                            panel = DocEx.GetItemsHost(block);
                            if (panel == null)
                            {
                                throw new Exception("ItemsHost not found. Did you forget to specify DocEx.IsItemsHost?");
                            }
                        }
                    }
                }

                var itemTemplate = ItemTemplateSelector != null?ItemTemplateSelector.SelectTemplate(data, this) : ItemTemplate;

                var elements = LoadDataTemplate(itemTemplate);
                foreach (var element in elements)
                {
                    element.DataContext = data;

                    var expressions = element.GetValue(DocEx.ForceRefreshExpressionProperty);
                    if (expressions != null)
                    {
                        var bindings = expressions as List <BindingToSet>;
                        if (bindings != null)
                        {
                            foreach (var binding in bindings)
                            {
                                if (binding.Binding.Source == null && binding.Binding.RelativeSource == null)
                                {
                                    binding.Binding.Source = data;
                                }
                                var frameworkElement = binding.DependencyObject as FrameworkElement;
                                if (frameworkElement != null)
                                {
                                    frameworkElement.SetBinding(binding.Property, binding.Binding);
                                }
                                else
                                {
                                    var frameworkContentElement = binding.DependencyObject as FrameworkContentElement;
                                    if (frameworkContentElement != null)
                                    {
                                        frameworkContentElement.SetBinding(binding.Property, binding.Binding);
                                    }
                                }
                            }
                        }
                    }

                    var section       = panel as Section;
                    var paragraph     = panel as Paragraph;
                    var inline        = element as Inline;
                    var tableRowGroup = panel as TableRowGroup;
                    var tableRow      = element as TableRow;
                    var list          = panel as List;
                    var listItem      = element as ListItem;

                    if (section != null)
                    {
                        section.Blocks.Add(ConvertToBlock(data, element));
                    }
                    else if (paragraph != null && inline != null)
                    {
                        if (inline.Parent == null)
                        {
                            paragraph.Inlines.Add(inline);
                        }
                    }
                    else if (tableRowGroup != null && tableRow != null)
                    {
                        if (tableRow.Parent == null)
                        {
                            tableRowGroup.Rows.Add(tableRow);
                        }
                    }
                    else if (list != null && listItem != null)
                    {
                        if (listItem.Parent == null)
                        {
                            list.ListItems.Add(listItem);
                        }
                    }
                    else if (panel != null)
                    {
                        throw new Exception(String.Format("Can't add an instance of {0} to an instance of {1}", element.GetType(), panel.GetType()));
                    }
                    else
                    {
                        throw new Exception("Unable to add child elements.");
                    }
                }
            }
        }
Пример #39
0
 public void init(Blocks blocks)
 {
     init(blocks.Method);
 }
 public void deobfuscateBegin(Blocks blocks)
 {
     this.blocks = blocks;
 }
Пример #41
0
 void deobfuscate(Blocks blocks)
 {
     cflowDeobfuscator.init(blocks);
     cflowDeobfuscator.deobfuscate();
 }
 public void deobfuscateBegin(Blocks blocks)
 {
     this.blocks = blocks;
     iteration = 0;
 }
 public bool ShouldSerializeBlocks() => Blocks?.Any() ?? false;
Пример #44
0
        public static void SetBlocks()
        {
            BlockList = new List<Blocks>();
            Blocks b = new Blocks();
            b.lowestRank = LevelPermission.Guest;

            for (int i = 0; i < 256; i++)
            {
                b = new Blocks();
                b.type = (byte)i;
                BlockList.Add(b);
            }

            List<Blocks> storedList = new List<Blocks>();

            foreach (Blocks bs in BlockList)
            {
                b = new Blocks();
                b.type = bs.type;

                switch (bs.type)
                {
                    case Zero:
                        b.lowestRank = LevelPermission.Admin;
                        break;

                    case op_glass:
                    case opsidian:
                    case op_brick:
                    case op_stone:
                    case op_cobblestone:
                    case op_air:
                    case op_water:
                    case blackrock:

                    case air_flood:
                    case air_flood_down:
                    case air_flood_layer:
                    case air_flood_up:

                    case bigtnt:
                    case rocketstart:
                    case rockethead:

                    case creeper:
                    case zombiebody:
                    case zombiehead:

                    case birdred:
                    case birdkill:
                    case birdblue:

                    case fishgold:
                    case fishsponge:
                    case fishshark:
                    case fishsalmon:
                    case fishbetta:
                    case fishlavashark:

                    case snake:
                    case snaketail:
                    case flagbase:

                        b.lowestRank = LevelPermission.Operator;
                        break;

                    case wood_float:

                    case door_air:
                    case door2_air:
                    case door3_air:
                    case door4_air:
                    case door5_air:
                    case door6_air:
                    case door7_air:
                    case door8_air:
                    case door9_air:
                    case door10_air:
                    case door11_air:
                    case door12_air:
                    case door13_air:
                    case door14_air:
                    case door_iron_air:
                    case door_grass_air:
                    case door_dirt_air:
                    case door_blue_air:
                    case door_book_air:

                    case odoor1_air:
                    case odoor2_air:
                    case odoor3_air:
                    case odoor4_air:
                    case odoor5_air:
                    case odoor6_air:
                    case odoor7_air:
                    case odoor8_air:
                    case odoor9_air:
                    case odoor10_air:
                    case odoor11_air:
                    case odoor12_air:

                    case MsgAir:
                    case MsgBlack:
                    case MsgLava:
                    case MsgWater:
                    case MsgWhite:
                    case air_portal:
                    case water_portal:
                    case lava_portal:
                    case blue_portal:
                    case orange_portal:

                    case water:
                    case lava:
                    case lava_fast:
                    case WaterDown:
                    case LavaDown:
                    case WaterFaucet:
                    case LavaFaucet:
                    case finiteWater:
                    case finiteLava:
                    case finiteFaucet:
                    case magma:
                    case geyser:
                    case deathlava:
                    case deathwater:
                    case deathair:
                    case activedeathwater:
                    case activedeathlava:
                    case fire:

                    case smalltnt:
                    case tntexplosion:
                    case firework:

                    case train:

                    case birdwhite:
                    case birdblack:
                    case birdwater:
                    case birdlava:
                        b.lowestRank = LevelPermission.AdvBuilder;
                        break;

                    case door:
                    case door2:
                    case door3:
                    case door4:
                    case door5:
                    case door6:
                    case door7:
                    case door8:
                    case door9:
                    case door10:
                    case air_door:
                    case air_switch:
                    case water_door:
                    case lava_door:
                    case door_iron:
                    case door_grass:
                    case door_dirt:
                    case door_blue:
                    case door_book:

                    case tdoor:
                    case tdoor2:
                    case tdoor3:
                    case tdoor4:
                    case tdoor5:
                    case tdoor6:
                    case tdoor7:
                    case tdoor8:
                    case tdoor9:
                    case tdoor10:
                    case tdoor11:
                    case tdoor12:
                    case tdoor13:

                    case odoor1:
                    case odoor2:
                    case odoor3:
                    case odoor4:
                    case odoor5:
                    case odoor6:
                    case odoor7:
                    case odoor8:
                    case odoor9:
                    case odoor10:
                    case odoor11:
                    case odoor12:

                        b.lowestRank = LevelPermission.Builder;
                        break;

                    default:
                        b.lowestRank = LevelPermission.Banned;
                        break;
                }

                storedList.Add(b);
            }

            //CHECK FOR SPECIAL RANK ALLOWANCES SET BY USER
            if (File.Exists("properties/block.properties"))
            {
                string[] lines = File.ReadAllLines("properties/block.properties");

                if (lines.Length == 0) ;
                else if (lines[0] == "#Version 2")
                {
                    string[] colon = new string[] { " : " };
                    foreach (string line in lines)
                    {
                        if (line != "" && line[0] != '#')
                        {
                            //Name : Lowest : Disallow : Allow
                            string[] block = line.Split(colon, StringSplitOptions.None);
                            Blocks newBlock = new Blocks();

                            if (Block.Byte(block[0]) == Block.Zero)
                            {
                                continue;
                            }
                            newBlock.type = Block.Byte(block[0]);

                            string[] disallow = new string[0];
                            if (block[2] != "")
                                disallow = block[2].Split(',');
                            string[] allow = new string[0];
                            if (block[3] != "")
                                allow = block[3].Split(',');

                            try
                            {
                                newBlock.lowestRank = (LevelPermission)int.Parse(block[1]);
                                foreach (string s in disallow) { newBlock.disallow.Add((LevelPermission)int.Parse(s)); }
                                foreach (string s in allow) { newBlock.allow.Add((LevelPermission)int.Parse(s)); }
                            }
                            catch
                            {
                                Server.s.Log("Hit an error on the block " + line);
                                continue;
                            }

                            int current = 0;
                            foreach (Blocks bS in storedList)
                            {
                                if (newBlock.type == bS.type)
                                {
                                    storedList[current] = newBlock;
                                    break;
                                }
                                current++;
                            }
                        }
                    }
                }
                else
                {
                    foreach (string s in lines)
                    {
                        if (s[0] != '#')
                        {
                            try
                            {
                                Blocks newBlock = new Blocks();
                                newBlock.type = Block.Byte(s.Split(' ')[0]);
                                newBlock.lowestRank = Level.PermissionFromName(s.Split(' ')[2]);
                                if (newBlock.lowestRank != LevelPermission.Null)
                                    storedList[storedList.FindIndex(sL => sL.type == newBlock.type)] = newBlock;
                                else
                                    throw new Exception();
                            }
                            catch { Server.s.Log("Could not find the rank given on " + s + ". Using default"); }
                        }
                    }
                }
            }

            BlockList.Clear();
            BlockList.AddRange(storedList);
            SaveBlocks(BlockList);
        }
Пример #45
0
	void CreateSmoothTerrain(MyMesh TerrainMesh, MarchingCubes marchingCubes, Blocks MyBlocks) {
		Debug.Log ("Creating Smooth Terrain");
		Vector3 BlockScale = MyBlocks.Scale;
		// Marching cubes is one too small!
		// for some reason the size has to be like this
		Vector3 WorldSize_ = MyBlocks.Size;
		int expand = 0;// WorldCore->MarchingExpand;
		WorldSize_.x += expand;
		WorldSize_.y += expand;
		WorldSize_.z += expand;
		// = 18 now out of 16 0 to 15
		// I need to perform this calculation PER CUBE and not per grid
		// So perform calculation depending on surrounding cubes, but not whole thing
		//MarchingCubesData.Clear();
		//for (int i = 0; i < (WorldSize_.x)*(WorldSize_.y)*(WorldSize_.z); i++)
		//	MarchingCubesData.Add(0.0f);
		//marchingCubes.ClearData(MarchingCubesData);
		marchingCubes = new MarchingCubes(new Vector3(WorldSize_.x, WorldSize_.x, WorldSize_.x), Mathf.RoundToInt(WorldSize_.x));
		marchingCubes.PolygonizeData(MyBlocks, WorldSize_);
		
		TerrainMesh.ClearMesh ();
		for (int i = 0; i < marchingCubes.trilist.Count; i++) {	// for every triangle in list
			marchingCubes.trilist[i].calcnormal(true);
			
			TerrainMesh.Verticies.Add (marchingCubes.trilist[i].position[0]);
			TerrainMesh.Verticies.Add (marchingCubes.trilist[i].position[1]);
			TerrainMesh.Verticies.Add (marchingCubes.trilist[i].position[2]);
			
			TerrainMesh.Colors.Add (marchingCubes.trilist[i].colors[0]);
			TerrainMesh.Colors.Add (marchingCubes.trilist[i].colors[1]);
			TerrainMesh.Colors.Add (marchingCubes.trilist[i].colors[2]);
			
			TerrainMesh.Indicies.Add (TerrainMesh.Verticies.Count-3);
			TerrainMesh.Indicies.Add (TerrainMesh.Verticies.Count-2);
			TerrainMesh.Indicies.Add (TerrainMesh.Verticies.Count-1);
		}
		Debug.Log ("Created Smooth Terrain");
	}
		public void Initialize(Blocks blocks) {
			this.blocks = blocks;
		}
Пример #47
0
 public void Handle(BallCollidedWithBlock message)
 {
     Blocks.Remove(message.Block);
 }
Пример #48
0
 public System.Collections.IEnumerator GetEnumerator()
 {
     return(Blocks.GetEnumerator());
 }
Пример #49
0
 public void init(Blocks blocks, Block block)
 {
     this.blocks = blocks;
     this.block = block;
     instructionEmulator.init(blocks.Method.HasThis, false, blocks.Method.Parameters, blocks.Locals);
 }
Пример #50
0
        public void 何もブロックの存在しないラインにブロックを落下させるテスト()
        {
            var board = new Board(8, 20);
            // 1つ目のブロック設置
            var controlBlocks = new ControlBlocks(3, 0, IBlocks);

            controlBlocks.LeftSpin();
            board.PutBlocks(controlBlocks);

            // 2つ目のブロック設置
            var controlBlocks2 = new ControlBlocks(2, 4, IBlocks);

            controlBlocks2.LeftSpin();
            board.PutBlocks(controlBlocks2);

            // 3つ目のブロック設置
            var sevenSideBlocks = new Blocks(new List <IBlock>
            {
                new Block(0, 0),
                new Block(1, 0),
                new Block(2, 0),
                new Block(3, 0),
                new Block(4, 0),
                new Block(5, 0),
                new Block(6, 0)
            });
            var controlBlocks3 = new ControlBlocks(0, 5, sevenSideBlocks);

            board.PutBlocks(controlBlocks3);

            // 4つ目のブロックを接地
            var controlBlocks4 = new ControlBlocks(4, 6, IBlocks);

            controlBlocks4.LeftSpin();
            board.PutBlocks(controlBlocks4);

            var result = board.FallToEmptyLine();

            // 移動したブロックが戻り値に入っている
            Assert.AreEqual(15, result.Count);

            // 空間にブロックが落下している
            Assert.IsFalse(board.ExistPosition(0, 0));
            Assert.IsTrue(board.ExistPosition(1, 0));
            Assert.IsTrue(board.ExistPosition(2, 0));
            Assert.IsTrue(board.ExistPosition(3, 0));
            Assert.IsTrue(board.ExistPosition(4, 0));
            Assert.IsFalse(board.ExistPosition(5, 0));
            Assert.IsFalse(board.ExistPosition(6, 0));
            Assert.IsFalse(board.ExistPosition(7, 0));

            Assert.IsTrue(board.ExistPosition(0, 1));
            Assert.IsTrue(board.ExistPosition(1, 1));
            Assert.IsTrue(board.ExistPosition(2, 1));
            Assert.IsTrue(board.ExistPosition(3, 1));
            Assert.IsFalse(board.ExistPosition(4, 1));
            Assert.IsFalse(board.ExistPosition(5, 1));
            Assert.IsFalse(board.ExistPosition(6, 1));
            Assert.IsFalse(board.ExistPosition(7, 1));

            Assert.IsTrue(board.ExistPosition(0, 2));
            Assert.IsTrue(board.ExistPosition(1, 2));
            Assert.IsTrue(board.ExistPosition(2, 2));
            Assert.IsTrue(board.ExistPosition(3, 2));
            Assert.IsTrue(board.ExistPosition(4, 2));
            Assert.IsTrue(board.ExistPosition(5, 2));
            Assert.IsTrue(board.ExistPosition(6, 2));
            Assert.IsFalse(board.ExistPosition(7, 2));

            Assert.IsFalse(board.ExistPosition(0, 3));
            Assert.IsFalse(board.ExistPosition(1, 3));
            Assert.IsTrue(board.ExistPosition(2, 3));
            Assert.IsTrue(board.ExistPosition(3, 3));
            Assert.IsTrue(board.ExistPosition(4, 3));
            Assert.IsTrue(board.ExistPosition(5, 3));
            Assert.IsFalse(board.ExistPosition(6, 3));
            Assert.IsFalse(board.ExistPosition(7, 3));
        }
Пример #51
0
 public void init(Blocks blocks)
 {
     this.blocks = blocks;
 }
Пример #52
0
        static void InitDefaults()
        {
            for (int i = 0; i < 256; i++)
            {
                Blocks b = new Blocks();
                b.type = (byte)i;
                switch (i)
                {
                case Invalid:
                    b.lowestRank = LevelPermission.Admin;
                    break;

                case op_glass:
                case opsidian:
                case op_brick:
                case op_stone:
                case op_cobblestone:
                case op_air:
                case op_water:
                case op_lava:
                case blackrock:

                case griefer_stone:

                case air_flood:
                case air_flood_down:
                case air_flood_layer:
                case air_flood_up:

                case bigtnt:
                case nuketnt:
                case rocketstart:
                case rockethead:

                case creeper:
                case zombiebody:
                case zombiehead:

                case birdred:
                case birdkill:
                case birdblue:

                case fishgold:
                case fishsponge:
                case fishshark:
                case fishsalmon:
                case fishbetta:
                case fishlavashark:

                case snake:
                case snaketail:
                case flagbase:

                    b.lowestRank = LevelPermission.Operator;
                    break;

                case wood_float:
                case lava_sponge:

                case door_tree_air:
                case door_obsidian_air:
                case door_glass_air:
                case door_stone_air:
                case door_leaves_air:
                case door_sand_air:
                case door_wood_air:
                case door_green_air:
                case door_tnt_air:
                case door_stair_air:
                case air_switch_air:
                case water_door_air:
                case lava_door_air:
                case air_door_air:
                case door_iron_air:
                case door_gold_air:
                case door_cobblestone_air:
                case door_grass_air:
                case door_dirt_air:
                case door_blue_air:
                case door_book_air:
                case door_red_air:
                case door_darkpink_air:
                case door_darkgrey_air:
                case door_lightgrey_air:
                case door_white_air:

                case odoor1_air:
                case odoor2_air:
                case odoor3_air:
                case odoor4_air:
                case odoor5_air:
                case odoor6_air:
                case odoor7_air:
                case odoor8_air:
                case odoor9_air:
                case odoor10_air:
                case odoor11_air:
                case odoor12_air:

                case MsgAir:
                case MsgBlack:
                case MsgLava:
                case MsgWater:
                case MsgWhite:
                case air_portal:
                case water_portal:
                case lava_portal:
                case blue_portal:
                case orange_portal:

                case water:
                case lava:
                case lava_fast:
                case WaterDown:
                case LavaDown:
                case WaterFaucet:
                case LavaFaucet:
                case finiteWater:
                case finiteLava:
                case finiteFaucet:
                case magma:
                case geyser:
                case deathlava:
                case deathwater:
                case deathair:
                case activedeathwater:
                case activedeathlava:
                case fastdeathlava:
                case lava_fire:

                case c4:
                case c4det:
                case smalltnt:
                case tntexplosion:
                case firework:
                case checkpoint:
                case train:

                case birdwhite:
                case birdblack:
                case birdwater:
                case birdlava:
                    b.lowestRank = LevelPermission.AdvBuilder;
                    break;

                case door_tree:
                case door_obsidian:
                case door_glass:
                case door_stone:
                case door_leaves:
                case door_sand:
                case door_wood:
                case door_green:
                case door_tnt:
                case door_stair:
                case air_door:
                case air_switch:
                case water_door:
                case lava_door:
                case door_iron:
                case door_gold:
                case door_grass:
                case door_dirt:
                case door_blue:
                case door_book:
                case door_cobblestone:
                case door_red:

                case door_orange:
                case door_yellow:
                case door_lightgreen:
                case door_aquagreen:
                case door_cyan:
                case door_lightblue:
                case door_purple:
                case door_lightpurple:
                case door_pink:
                case door_darkpink:
                case door_darkgrey:
                case door_lightgrey:
                case door_white:

                case tdoor:
                case tdoor2:
                case tdoor3:
                case tdoor4:
                case tdoor5:
                case tdoor6:
                case tdoor7:
                case tdoor8:
                case tdoor9:
                case tdoor10:
                case tdoor11:
                case tdoor12:
                case tdoor13:

                case odoor1:
                case odoor2:
                case odoor3:
                case odoor4:
                case odoor5:
                case odoor6:
                case odoor7:
                case odoor8:
                case odoor9:
                case odoor10:
                case odoor11:
                case odoor12:
                    b.lowestRank = LevelPermission.Builder;
                    break;

                default:
                    b.lowestRank = LevelPermission.Banned;
                    break;
                }
                BlockList[i] = b;
            }
        }
Пример #53
0
 public void init(Blocks blocks, Block block)
 {
     this.blocks = blocks;
     this.block = block;
     this.iteration = 0;
 }
Пример #54
0
    public string doorStatus(EasyMenuItem item)
    {
        EasyBlock door = Blocks.Named(item.Text).GetBlock(0);

        return(item.Text + ": " + ((door.Open())?"Open":"Closed"));
    }
Пример #55
0
            public override void DoRevertOthers()
            {
                Debug.Assert(othersULE != null);

                if (othersULE.nextBlockChanged)
                {
                    privNextBlock = othersULE.savedNextBlock;
                    othersULE.nextBlockChanged = false;
                }
                if (othersULE.handlerBlockChanged)
                {
                    privHandlerBlock = othersULE.savedHandlerBlock;
                    othersULE.handlerBlockChanged = false;
                }
            }
Пример #56
0
        internal IOperand CompilePROG([NotNull] IRoutineBuilder rb, [NotNull] ZilListoidBase args,
                                      [NotNull] ISourceLine src,
                                      bool wantResult, [CanBeNull] IVariable resultStorage, [NotNull] string name, bool repeat, bool catchy)
        {
            if (!args.IsCons(out var first, out var rest))
            {
                throw new CompilerError(CompilerMessages._0_Argument_1_2, name, 1, "argument must be an activation atom or binding list");
            }

            if (first is ZilAtom activationAtom)
            {
                args = rest;
            }
            else
            {
                activationAtom = null;
            }

            if (!args.IsCons(out var bindings, out var body) || !(bindings is ZilList bindingList))
            {
                throw new CompilerError(CompilerMessages._0_Missing_Binding_List, name);
            }

            if (!wantResult)
            {
                /* Recognize the "deferred return" pattern:
                 *
                 *   <PROG (... var ...)
                 *       ...
                 *       <SET var expr>
                 *       ...
                 *       <LVAL var>>
                 *
                 * In this pattern, the PROG (or BIND) binds an atom and references it exactly twice:
                 * with SET anywhere in the body, and with LVAL as the last expression in the PROG.
                 *
                 * In void context, since the variable value is discarded anyway, we can eliminate the
                 * store and the binding, transforming it to this:
                 *
                 *   <PROG (...)
                 *       ...
                 *       expr
                 *       ...>
                 */

                TransformProgArgsIfImplementingDeferredReturn(ref bindingList, ref body);
            }

            // add new locals, if any
            var innerLocals = new Queue <ZilAtom>();

            void AddLocal(ZilAtom atom)
            {
                innerLocals.Enqueue(atom);
                PushInnerLocal(rb, atom, LocalBindingType.ProgAuxiliary, src);
            }

            void AddLocalWithDefault(ZilAtom atom, ZilObject value)
            {
                innerLocals.Enqueue(atom);
                var lb  = PushInnerLocal(rb, atom, LocalBindingType.ProgAuxiliary, src);
                var loc = CompileAsOperand(rb, value, src, lb);

                if (loc != lb)
                {
                    rb.EmitStore(lb, loc);
                }

                // setting any default value counts as a write
                MarkVariableAsWritten(lb);
            }

            foreach (var obj in bindingList)
            {
                switch (obj)
                {
                case ZilAtom atom:
                    AddLocal(atom);
                    break;

                case ZilAdecl adecl when adecl.First is ZilAtom atom:
                    AddLocal(atom);
                    break;

                case ZilList list when !list.HasLength(2):
                    throw new CompilerError(CompilerMessages._0_Expected_1_Element1s_In_Binding_List, name, 2);

                case ZilList list when list.Matches(out ZilAtom atom, out ZilObject value):
                    AddLocalWithDefault(atom, value);

                    break;

                case ZilList list when list.Matches(out ZilAdecl adecl, out ZilObject value) && adecl.First is ZilAtom atom:
                    AddLocalWithDefault(atom, value);

                    break;

                case ZilAdecl _:
                case ZilList _:
                    throw new CompilerError(CompilerMessages.Invalid_Atom_Binding);

                default:
                    throw new CompilerError(CompilerMessages.Elements_Of_Binding_List_Must_Be_Atoms_Or_Lists);
                }
            }

            if (wantResult && resultStorage == null)
            {
                resultStorage = rb.Stack;
            }

            var block = new Block
            {
                Name          = activationAtom,
                AgainLabel    = rb.DefineLabel(),
                ReturnLabel   = rb.DefineLabel(),
                ResultStorage = resultStorage
            };

            if (wantResult)
            {
                block.Flags |= BlockFlags.WantResult;
            }
            if (!catchy)
            {
                block.Flags |= BlockFlags.ExplicitOnly;
            }

            rb.MarkLabel(block.AgainLabel);
            Blocks.Push(block);

            try
            {
                // generate code for prog body
                IOperand result;

                if (wantResult)
                {
                    var clauseResult = CompileClauseBody(rb, body, !repeat, resultStorage);

                    /* The resultStorage we pass to CompileClauseBody (like any other method) is just
                     * a hint, so clauseResult might be different if the result is easily accessible.
                     * For example:
                     *
                     *     <SET R <PROG () <SET X 123>>>  ;"clauseResult is X"
                     *
                     *     SET 'X,123       ;inner SET
                     *     SET 'R,X         ;outer SET
                     *
                     * But we can't always use it as-is, because there might be RETURNs inside that store
                     * a value and branch to the end of the PROG.
                     *
                     * RETURN always stores the value in our desired resultStorage, so we need to move
                     * the clause body result there too:
                     *
                     *     <SET R <PROG () <COND (.F <RETURN 123>)> 456>>
                     *
                     *     ZERO? F /L1
                     *     SET 'R,123       ;RETURN
                     *     JUMP L2
                     * L1: SET 'R,456       ;move clauseResult to resultStorage
                     * L2: ...
                     */

                    if (repeat)
                    {
                        result = resultStorage;
                    }
                    else if (clauseResult != resultStorage && (block.Flags & BlockFlags.Returned) != 0)
                    {
                        rb.EmitStore(resultStorage, clauseResult);
                        result = resultStorage;
                    }
                    else
                    {
                        result = clauseResult;
                    }
                }
                else
                {
                    CompileClauseBody(rb, body, false, null);
                    result = null;
                }

                if (repeat)
                {
                    rb.Branch(block.AgainLabel);
                }

                if ((block.Flags & BlockFlags.Returned) != 0)
                {
                    rb.MarkLabel(block.ReturnLabel);
                }

                return(result);
            }
            finally
            {
                while (innerLocals.Count > 0)
                {
                    PopInnerLocal(innerLocals.Dequeue());
                }

                Blocks.Pop();
            }
        }
Пример #57
0
 public void init(Blocks blocks, List<Block> allBlocks)
 {
     this.blocks = blocks;
     this.allBlocks = allBlocks;
 }
Пример #58
0
        private IOperand CompileBoundedLoop(
            [NotNull] IRoutineBuilder rb, [NotNull] IBoundedLoopBuilder builder,
            [NotNull] ZilListoidBase args, [NotNull] ISourceLine src,
            bool wantResult, [CanBeNull] IVariable resultStorage)
        {
            // extract loop spec ("binding list", although we don't care about the bindings here)
            // TODO: allow activation atoms in bounded loops?
            if (!args.IsCons(out var first, out var rest) || !(first is ZilList spec))
            {
                throw new CompilerError(CompilerMessages.Expected_Binding_List_At_Start_Of_0, builder.Name);
            }

            // instantiate the loop and let it check binding syntax
            var blc = new BoundedLoopContext(this, spec, src);

            using (var loop = builder.MakeLoop(blc))
            {
                // look for the optional end statements
                ZilListoidBase body;
                if (rest.StartsWith(out ZilList endStmts))
                {
                    (_, body) = rest;
                }
                else
                {
                    body = rest;
                }

                // create block
                resultStorage = wantResult ? (resultStorage ?? rb.Stack) : null;

                var block = new Block
                {
                    AgainLabel    = rb.DefineLabel(),
                    ResultStorage = resultStorage,
                    ReturnLabel   = rb.DefineLabel(),
                    Flags         = wantResult ? BlockFlags.WantResult : 0
                };

                Blocks.Push(block);
                try
                {
                    var exhaustedLabel = rb.DefineLabel();

                    // let the loop initialize counters, etc.
                    loop.BeforeBlock(rb, block, exhaustedLabel);

                    // mark the top of the block ("again" label) and let the loop add prechecks, etc.
                    rb.MarkLabel(block.AgainLabel);
                    loop.BeforeBody();

                    // compile the body
                    CompileClauseBody(rb, body, false, null);

                    // let the loop add postchecks, etc., and mark the end of the block ("exhausted" label)
                    loop.AfterBody();

                    rb.MarkLabel(exhaustedLabel);

                    // compile the end statements if present, and provide a return value if requested
                    if (endStmts != null)
                    {
                        CompileClauseBody(rb, endStmts, false, null);
                    }

                    if (wantResult)
                    {
                        rb.EmitStore(resultStorage, Game.One);
                    }

                    // if <RETURN> was used inside the loop, mark the return label
                    if ((block.Flags & BlockFlags.Returned) != 0)
                    {
                        rb.MarkLabel(block.ReturnLabel);
                    }
                }
                finally
                {
                    Blocks.Pop();
                }

                return(wantResult ? resultStorage : null);
            }
        }
Пример #59
0
 public static bool IsSolid(Blocks block)
 {
     return !Air.Contains((Blocks)block) && !IsLiquid(block);
 }
Пример #60
0
 public override void DeobfuscateBegin(Blocks blocks)
 {
     base.DeobfuscateBegin(blocks);
     InitLocalToInfo();
 }