当前位置: 首页>>代码示例>>C#>>正文


C# Entities.findAllWithAttribute方法代码示例

本文整理汇总了C#中Entities.findAllWithAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Entities.findAllWithAttribute方法的具体用法?C# Entities.findAllWithAttribute怎么用?C# Entities.findAllWithAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entities的用法示例。


在下文中一共展示了Entities.findAllWithAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decompile

	// METHODS
	
	// +decompile()
	// Attempts to convert the BSP file back into a .MAP file.
	public virtual Entities decompile() {
		DecompilerThread.OnMessage(this, "Decompiling...");
		// In the decompiler, it is not necessary to copy all entities to a new object, since
		// no writing is ever done back to the BSP file.
		mapFile = BSPObject.Entities;
		int numTotalItems = 0;
		worldspawn = mapFile[mapFile.findAllWithAttribute("classname", "worldspawn")[0]];
		int onePercent = (int)((BSPObject.Brushes.Count + BSPObject.Entities.Count + BSPObject.Faces.Count)/100);
		if(onePercent < 1) {
			onePercent = 1;
		}
		// I need to go through each entity and see if it's brush-based.
		// Worldspawn is brush-based as well as any entity with model *#.
		for (int i = 0; i < BSPObject.Entities.Count; i++) {
			// For each entity
			//DecompilerThread.OnMessage(this, "Entity " + i + ": " + mapFile[i]["classname"]);
			numBrshs = 0; // Reset the brush count for each entity
			// getModelNumber() returns 0 for worldspawn, the *# for brush based entities, and -1 for everything else
			int currentModel = mapFile[i].ModelNumber;
			if (currentModel > - 1) {
				// If this is still -1 then it's strictly a point-based entity. Move on to the next one.
				int firstBrush = BSPObject.Models[currentModel].FirstBrush;
				int numBrushes = BSPObject.Models[currentModel].NumBrushes;
				numBrshs = 0;
				for (int j = 0; j < numBrushes; j++) {
					// For each brush
					//Console.Write("Brush " + j);
					decompileBrush(BSPObject.Brushes[j + firstBrush], i); // Decompile the brush
					numBrshs++;
					numTotalItems++;
					if(numTotalItems%onePercent == 0) {
						parent.OnProgress(this, numTotalItems/(double)(BSPObject.Brushes.Count + BSPObject.Entities.Count + BSPObject.Faces.Count));
					}
				}
			}
			numTotalItems++;
			if(numTotalItems%onePercent == 0) {
				parent.OnProgress(this, numTotalItems/(double)(BSPObject.Brushes.Count + BSPObject.Entities.Count + BSPObject.Faces.Count));
			}
		}
		if (!Settings.skipPlaneFlip) {
			DecompilerThread.OnMessage(this, "Num simple corrected brushes: " + numSimpleCorrects);
			DecompilerThread.OnMessage(this, "Num advanced corrected brushes: " + numAdvancedCorrects);
			DecompilerThread.OnMessage(this, "Num good brushes: " + numGoodBrushes);
		}
		foreach(Face face in BSPObject.Faces) {
			if(face.Facetype == Face.faceType.PATCH) {
				MAPPatch mapPatch = new MAPPatch(face.PatchSize[0], face.PatchSize[1], BSPObject.Textures[face.Texture].Name);
				for(int i=0; i<face.NumVertices; i++) {
					mapPatch.Add(BSPObject.Vertices[face.FirstVertex+i]);
				}
				MAPBrush mapBrush = new MAPBrush(mapPatch);
				worldspawn.Brushes.Add(mapBrush);
			}
		}
		parent.OnProgress(this, 1.0);
		return mapFile;
	}
开发者ID:Avatarchik,项目名称:bsp-decompiler-1,代码行数:62,代码来源:BSP46Decompiler.cs


注:本文中的Entities.findAllWithAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。