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


C# Entities.Add方法代码示例

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


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

示例1: To_String

 public void To_String()
 {
     var list = new Entities<Entity>();
     var nestedEntity = new NestedEntity();
     var testEntity = new TestEntity(nestedEntity);
     nestedEntity.Yo = "7";
     testEntity.Zo = "8";
     list.Add(testEntity);
     var builder = new StringBuilder();
     builder.AppendLine("ZO, YO, ");
     builder.AppendLine("8, 7, ");
     Assert.That(list.ToString(), Is.EqualTo(builder.ToString()));
 }
开发者ID:mdzn,项目名称:White,代码行数:13,代码来源:EntitiesTest.cs

示例2: decompile


//.........这里部分代码省略.........
		for (int i = 0; i < BSPObject.Faces.Count; i++) {
			Face face = BSPObject.Faces[i];
			if (face.Displacement > - 1)
			{
				SourceDispInfo disp = BSPObject.DispInfos[face.Displacement];
				TexInfo currentTexInfo;
				if (face.Texture > - 1)
				{
					currentTexInfo = BSPObject.TexInfo[face.Texture];
				}
				else
				{
					Vector3D[] axes = TexInfo.textureAxisFromPlane(BSPObject.Planes[face.Plane]);
					currentTexInfo = new TexInfo(axes[0], 0, axes[1], 0, 0, BSPObject.findTexDataWithTexture("tools/toolsclip"));
				}
				SourceTexData currentTexData = BSPObject.TexDatas[currentTexInfo.Texture];
				string texture = BSPObject.Textures.getTextureAtOffset((uint)BSPObject.TexTable[currentTexData.StringTableIndex]);
				double[] textureU = new double[3];
				double[] textureV = new double[3];
				// Get the lengths of the axis vectors
				double SAxisLength = System.Math.Sqrt(System.Math.Pow((double) currentTexInfo.SAxis.X, 2) + System.Math.Pow((double) currentTexInfo.SAxis.Y, 2) + System.Math.Pow((double) currentTexInfo.SAxis.Z, 2));
				double TAxisLength = System.Math.Sqrt(System.Math.Pow((double) currentTexInfo.TAxis.X, 2) + System.Math.Pow((double) currentTexInfo.TAxis.Y, 2) + System.Math.Pow((double) currentTexInfo.TAxis.Z, 2));
				// In compiled maps, shorter vectors=longer textures and vice versa. This will convert their lengths back to 1. We'll use the actual scale values for length.
				double texScaleU = (1 / SAxisLength); // Let's use these values using the lengths of the U and V axes we found above.
				double texScaleV = (1 / TAxisLength);
				textureU[0] = ((double) currentTexInfo.SAxis.X / SAxisLength);
				textureU[1] = ((double) currentTexInfo.SAxis.Y / SAxisLength);
				textureU[2] = ((double) currentTexInfo.SAxis.Z / SAxisLength);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextSettingsIndex'&keyword='jlca1042'"
				double textureShiftU = (double) currentTexInfo.SShift;
				textureV[0] = ((double) currentTexInfo.TAxis.X / TAxisLength);
				textureV[1] = ((double) currentTexInfo.TAxis.Y / TAxisLength);
				textureV[2] = ((double) currentTexInfo.TAxis.Z / TAxisLength);
				//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextSettingsIndex'&keyword='jlca1042'"
				double textureShiftV = (double) currentTexInfo.TShift;
				
				if (face.NumEdges != 4)
				{
					DecompilerThread.OnMessage(this, "Displacement face with " + face.NumEdges + " edges!");
				}
				
				// Turn vertices and edges into arrays of vectors
				Vector3D[] froms = new Vector3D[face.NumEdges];
				Vector3D[] tos = new Vector3D[face.NumEdges];
				for (int j = 0; j < face.NumEdges; j++)
				{
					if (BSPObject.SurfEdges[face.FirstEdge + j] > 0)
					{
						froms[j] = BSPObject.Vertices[BSPObject.Edges[(int)BSPObject.SurfEdges[face.FirstEdge + j]].FirstVertex].Vector;
						tos[j] = BSPObject.Vertices[BSPObject.Edges[(int)BSPObject.SurfEdges[face.FirstEdge + j]].SecondVertex].Vector;
					}
					else
					{
						tos[j] = BSPObject.Vertices[BSPObject.Edges[(int) BSPObject.SurfEdges[face.FirstEdge + j] * (- 1)].FirstVertex].Vector;
						froms[j] = BSPObject.Vertices[BSPObject.Edges[(int) BSPObject.SurfEdges[face.FirstEdge + j] * (- 1)].SecondVertex].Vector;
					}
				}
				
				MAPBrush displacementBrush = MAPBrush.createBrushFromWind(froms, tos, texture, "TOOLS/TOOLSNODRAW", currentTexInfo);
				
				MAPDisplacement mapdisp = new MAPDisplacement(disp, BSPObject.DispVerts.getVertsInDisp(disp.DispVertStart, disp.Power));
				displacementBrush[0].Displacement = mapdisp;
				mapFile[0].Brushes.Add(displacementBrush);
			}
		}
		for (int i = 0; i < BSPObject.StaticProps.Count; i++)
		{
			Entity newStaticProp = new Entity("prop_static");
			SourceStaticProp currentProp = BSPObject.StaticProps[i];
			newStaticProp["model"] = BSPObject.StaticProps.Dictionary[currentProp.DictionaryEntry];
			newStaticProp["skin"] = currentProp.Skin + "";
			newStaticProp["origin"] = currentProp.Origin.X + " " + currentProp.Origin.Y + " " + currentProp.Origin.Z;
			newStaticProp["angles"] = currentProp.Angles.X + " " + currentProp.Angles.Y + " " + currentProp.Angles.Z;
			newStaticProp["solid"] = currentProp.Solidity + "";
			newStaticProp["fademindist"] = currentProp.MinFadeDist + "";
			newStaticProp["fademaxdist"] = currentProp.MaxFadeDist + "";
			newStaticProp["fadescale"] = currentProp.ForcedFadeScale + "";
			if (currentProp.Targetname != null)
			{
				newStaticProp["targetname"] = currentProp.Targetname;
			}
			mapFile.Add(newStaticProp);
		}
		for (int i = 0; i < BSPObject.Cubemaps.Count; i++)
		{
			Entity newCubemap = new Entity("env_cubemap");
			SourceCubemap currentCube = BSPObject.Cubemaps[i];
			newCubemap["origin"] = currentCube.Origin.X + " " + currentCube.Origin.Y + " " + currentCube.Origin.Z;
			newCubemap["cubemapsize"] = currentCube.Size + "";
			mapFile.Add(newCubemap);
		}
		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);
		}
		parent.OnProgress(this, 1.0);
		return mapFile;
	}
开发者ID:Avatarchik,项目名称:bsp-decompiler-1,代码行数:101,代码来源:SourceBSPDecompiler.cs

示例3: createLump

	public static Entities createLump(byte[] data) {
		int count = 0;
		bool inQuotes = false; // Keep track of whether or not we're currently in a set of quotation marks.
		// I came across a map where the idiot map maker used { and } within a value. This broke the code prior to revision 55.
		for (int i = 0; i < data.Length; i++) {
			if (inQuotes) {
				if (data[i] == '\"' && inQuotes) {
					inQuotes = false;
				}
			} else {
				if (data[i] == '\"') {
					inQuotes = true;
				} else {
					if (data[i] == '{') {
						count++;
					}
				}
			}
		}
		Entities lump = new Entities(data.Length, count);
		char currentChar; // The current character being read in the file. This is necessary because
		// we need to know exactly when the { and } characters occur and capture
		// all text between them.
		int offset = 0;
		for (int i = 0; i < count; i++) {
			// For every entity
			string current = ""; // This will be the resulting entity, fed into the Entity class
			currentChar = (char)data[offset]; // begin reading the file
			while (currentChar != '{') {
				// Eat bytes until we find the beginning of an entity structure
				offset++;
				currentChar = (char)data[offset];
			}
			inQuotes = false;
			do {
				if (currentChar == '\"') {
					inQuotes = !inQuotes;
				}
				current += (currentChar + ""); // adds characters to the current string
				offset++;
				currentChar = (char)data[offset];
			} while (currentChar != '}' || inQuotes); // Read bytes until we find the end of the current entity structure
			current += (currentChar + ""); // adds the '}' to the current string
			lump.Add(Entity.parseString(current));
		}
		return lump;
	}
开发者ID:Avatarchik,项目名称:bsp-decompiler-1,代码行数:47,代码来源:Entity.cs

示例4: JoinInternal

 private static Entities JoinInternal(EntityGroup g, string pname, object k)
 {
     var rlt = new Entities();
     Entities list = g.GetEntities();
     PropertyInfo info = null;
     foreach (Entity i in list)
     {
         if (info == null)
         {
             Type type = i.GetType();
             info = type.GetProperty(pname);
         }
         if (k.Equals(info.GetValue(i)))
         {
             rlt.Add(i);
         }
     }
     return rlt;
 }
开发者ID:mind0n,项目名称:hive,代码行数:19,代码来源:Entity.cs

示例5: decompile

	// METHODS
	
	// +decompile()
	// Attempts to convert a map in a Doom WAD into a usable .MAP file. This has many
	// challenges, not the least of which is the fact that the Doom engine didn't use
	// brushes (at least, not in any sane way).
	public virtual Entities decompile()
	{
		DecompilerThread.OnMessage(this, "Decompiling...");
		DecompilerThread.OnMessage(this, doomMap.MapName);
		
		mapFile = new Entities();
		Entity world = new Entity("worldspawn");
		mapFile.Add(world);
		
		string[] lowerWallTextures = new string[doomMap.Sidedefs.Count];
		string[] midWallTextures = new string[doomMap.Sidedefs.Count];
		string[] higherWallTextures = new string[doomMap.Sidedefs.Count];
		
		short[] sectorTag = new short[doomMap.Sectors.Count];
		string playerStartOrigin = "";
		
		// Since Doom relied on sectors to define a cieling and floor height, and nothing else,
		// need to find the minimum and maximum used Z values. This is because the Doom engine
		// is only a pseudo-3D engine. For all it cares, the cieling and floor extend to their
		// respective infinities. For a GC/Hammer map, however, this cannot be the case.
		int ZMin = 32767; // Even though the values in the map will never exceed these, use ints here to avoid
		int ZMax = - 32768; // overflows, in case the map DOES go within 32 units of these values.
		for (int i = 0; i < doomMap.Sectors.Count; i++)
		{
			DSector currentSector = doomMap.Sectors[i];
			sectorTag[i] = currentSector.Tag;
			if (currentSector.FloorHeight < ZMin + 32)
			{
				ZMin = currentSector.FloorHeight - 32; // Can't use the actual value, because that IS the floor
			}
			else
			{
				if (currentSector.CielingHeight > ZMax - 32)
				{
					ZMax = currentSector.CielingHeight + 32; // or the cieling. Subtract or add a sane value to it.
				}
			}
		}
		
		// I need to analyze the binary tree and get more information, particularly the
		// parent nodes of each subsector and node, as well as whether it's the right or
		// left child of that node. These are extremely important, as the parent defines
		// boundaries for the children, as well as inheriting further boundaries from its
		// parents. These boundaries are invaluable for forming brushes.
		int[] nodeparents = new int[doomMap.Nodes.Count];
		bool[] nodeIsLeft = new bool[doomMap.Nodes.Count];
		
		for (int i = 0; i < doomMap.Nodes.Count; i++)
		{
			nodeparents[i] = - 1; // There should only be one node left with -1 as a parent. This SHOULD be the root.
			for (int j = 0; j < doomMap.Nodes.Count; j++)
			{
				if (doomMap.Nodes[j].Child1 == i)
				{
					nodeparents[i] = j;
					break;
				}
				else
				{
					if (doomMap.Nodes[j].Child2 == i)
					{
						nodeparents[i] = j;
						nodeIsLeft[i] = true;
						break;
					}
				}
			}
		}
		
		// Keep a list of what subsectors belong to which sector
		int[] subsectorSectors = new int[doomMap.SubSectors.Count];
		// Keep a list of what sidedefs belong to what subsector as well
		int[][] subsectorSidedefs = new int[doomMap.SubSectors.Count][];
		
		short[][] sideDefShifts = new short[2][];
		for (int i2 = 0; i2 < 2; i2++)
		{
			sideDefShifts[i2] = new short[doomMap.Sidedefs.Count];
		}
		
		// Figure out what sector each subsector belongs to, and what node is its parent.
		// Depending on sector "tags" this will help greatly in creation of brushbased entities,
		// and also helps in finding subsector floor and cieling heights.
		int[] ssparents = new int[doomMap.SubSectors.Count];
		bool[] ssIsLeft = new bool[doomMap.SubSectors.Count];
		for (int i = 0; i < doomMap.SubSectors.Count; i++)
		{
			//DecompilerThread.OnMessage(this, "Populating texture lists for subsector " + i);
			// First, find the subsector's parent and whether it is the left or right child.
			ssparents[i] = - 1; // No subsector should have a -1 in here
			for (int j = 0; j < doomMap.Nodes.Count; j++)
			{
				// When a node references a subsector, it is not referenced by negative
				// index, as future BSP versions do. The bits 0-14 ARE the index, and
//.........这里部分代码省略.........
开发者ID:Avatarchik,项目名称:bsp-decompiler-1,代码行数:101,代码来源:WADDecompiler.cs


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