本文整理汇总了C#中Set.AddWithCheckAlreadyContained方法的典型用法代码示例。如果您正苦于以下问题:C# Set.AddWithCheckAlreadyContained方法的具体用法?C# Set.AddWithCheckAlreadyContained怎么用?C# Set.AddWithCheckAlreadyContained使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.AddWithCheckAlreadyContained方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonExport_Click
private void buttonExport_Click( object sender, EventArgs e )
{
lastOutputMapName = textBoxOutputFileName.Text;
string fileName = textBoxOutputFileName.Text.Trim();
bool rooted;
try
{
rooted = Path.IsPathRooted( fileName );
}
catch
{
rooted = false;
}
if( !rooted )
{
Log.Warning( Translate( "Invalid file name." ) );
return;
}
string caption = Translate( "Export To 3D Model Add-on" );
if( File.Exists( fileName ) )
{
string template = Translate( "The file with the name \"{0}\" is already exists. Overwrite?" );
string text = string.Format( template, fileName );
if( MessageBox.Show( text, caption, MessageBoxButtons.OKCancel,
MessageBoxIcon.Question ) != DialogResult.OK )
return;
}
try
{
using( new CursorKeeper( Cursors.WaitCursor ) )
{
//get selected entities
List<Entity> selectedEntities;
if( checkBoxExportSelectedObjectsOnly.Checked )
selectedEntities = MapEditorInterface.Instance.GetSelectedEntities();
else
selectedEntities = new List<Entity>();
Set<Entity> selectedEntitiesSet = new Set<Entity>();
foreach( Entity entity in selectedEntities )
selectedEntitiesSet.AddWithCheckAlreadyContained( entity );
string extension = Path.GetExtension( fileName );
ModelImportLoader loader = MeshManager.Instance.GetModeImportLoaderByExtension( extension );
if( loader == null )
{
Log.Warning( Translate( "File extension \"{0}\" is not supported." ), extension );
return;
}
List<ModelImportLoader.SaveGeometryItem> geometry =
new List<ModelImportLoader.SaveGeometryItem>();
List<VertexData> vertexDatasToDispose = new List<VertexData>();
List<IndexData> indexDatasToDispose = new List<IndexData>();
Set<string> names = new Set<string>();
//SceneNodes
foreach( SceneNode sceneNode in SceneManager.Instance.SceneNodes )
{
Entity entity = sceneNode._InternalUserData as Entity;
if( entity != null )
{
if( selectedEntities.Count == 0 || selectedEntitiesSet.Contains( entity ) )
{
foreach( MovableObject movableObject in sceneNode.MovableObjects )
{
MeshObject meshObject = movableObject as MeshObject;
if( meshObject != null )
{
foreach( SubMesh subMesh in meshObject.Mesh.SubMeshes )
{
string uniqueName = GetUniqueName( names, entity );
VertexData vertexData = subMesh.UseSharedVertices ?
subMesh.Parent.SharedVertexData : subMesh.VertexData;
IndexData indexData = subMesh.IndexData;
ModelImportLoader.SaveGeometryItem item =
new ModelImportLoader.SaveGeometryItem(
vertexData, indexData, sceneNode.Position, sceneNode.Rotation,
sceneNode.Scale, uniqueName );
geometry.Add( item );
names.Add( uniqueName );
}
}
}
}
}
}
foreach( Entity entity in Map.Instance.Children )
{
if( selectedEntities.Count == 0 || selectedEntitiesSet.Contains( entity ) )
{
//.........这里部分代码省略.........
示例2: GetObjectsInActiveArea
private Set<MapObject> GetObjectsInActiveArea()
{
Set<MapObject> result = new Set<MapObject>();
float height = Type.ActiveAreaHeight;
float radius = Type.ActiveAreaRadius;
Bounds bounds = new Bounds(
Position - new Vec3(radius, radius, 0),
Position + new Vec3(radius, radius, height));
Body[] bodies = PhysicsWorld.Instance.VolumeCast(bounds, (int)ContactGroup.CastOnlyDynamic);
foreach (Body body in bodies)
{
if (!body.Static)
{
MapObject obj = MapSystemWorld.GetMapObjectByBody(body);
if (obj != null && obj != this && IsAllowToTeleport(obj) &&
CheckPositionInActiveArea(obj.Position))
{
result.AddWithCheckAlreadyContained(obj);
}
}
}
return result;
}
示例3: GetObjectsInActiveArea
private Set<MapObject> GetObjectsInActiveArea()
{
Set<MapObject> result = new Set<MapObject>();
Bounds areabounds = new Bounds(Position - box.Extents, Position + box.Extents);
Body[] bodies = PhysicsWorld.Instance.VolumeCast(areabounds, (int)ContactGroup.CastOnlyDynamic);
foreach (Body body in bodies)
{
if (!body.Static)
{
MapObject obj = MapSystemWorld.GetMapObjectByBody(body);
if (obj != null && obj != this && IsAllowToTeleport(obj) &&
CheckPositionInActiveArea(areabounds, obj.Position))
{
result.AddWithCheckAlreadyContained(obj);
}
}
}
return result;
}