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


C# MapObject.GetChildren方法代码示例

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


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

示例1: PasteBase

        protected void PasteBase(MapObject o, IDGenerator generator, bool performUnclone = false)
        {
            Visgroups.Clear();
            AutoVisgroups.Clear();
            Children.Clear();

            if (performUnclone && o.ID != ID)
            {
                var parent = Parent;
                var setPar = Parent != null && Parent.Children.ContainsKey(ID) && Parent.Children[ID] == this;
                if (setPar) SetParent(null);
                ID = o.ID;
                if (setPar) SetParent(parent);
            }
            ClassName = o.ClassName;
            Visgroups.AddRange(o.Visgroups);
            AutoVisgroups.AddRange(o.AutoVisgroups);
            Parent = o.Parent;
            Colour = o.Colour;
            IsSelected = o.IsSelected;
            IsCodeHidden = o.IsCodeHidden;
            IsRenderHidden2D = o.IsRenderHidden2D;
            IsRenderHidden3D = o.IsRenderHidden3D;
            IsVisgroupHidden = o.IsVisgroupHidden;
            BoundingBox = o.BoundingBox.Clone();
            MetaData = o.MetaData.Clone();

            var children = o.GetChildren().Select(x => performUnclone ? x.Clone() : x.Copy(generator));
            foreach (var c in children)
            {
                c.SetParent(this);
            }
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:33,代码来源:MapObject.cs

示例2: CollectEntities

 private void CollectEntities(List<Entity> entities, MapObject parent)
 {
     entities.AddRange(parent.GetChildren().OfType<Entity>());
     parent.GetChildren().OfType<Group>().ToList().ForEach(x => CollectEntities(entities, x));
 }
开发者ID:silky,项目名称:sledge,代码行数:5,代码来源:MapFormatProvider.cs

示例3: CollectSolids

 private void CollectSolids(List<Solid> solids, MapObject parent)
 {
     solids.AddRange(parent.GetChildren().OfType<Solid>());
     parent.GetChildren().OfType<Group>().ToList().ForEach(x => CollectSolids(solids, x));
 }
开发者ID:silky,项目名称:sledge,代码行数:5,代码来源:MapFormatProvider.cs

示例4: LoadMapNode

 private void LoadMapNode(TreeNode parent, MapObject obj)
 {
     var text = GetNodeText(obj);
     var node = new TreeNode(obj.GetType().Name + text) { Tag = obj };
     if (obj is World)
     {
         var w = (World)obj;
         node.Nodes.AddRange(GetEntityNodes(w.EntityData).ToArray());
     }
     else if (obj is Entity)
     {
         var e = (Entity)obj;
         node.Nodes.AddRange(GetEntityNodes(e.EntityData).ToArray());
     }
     else if (obj is Solid)
     {
         var s = (Solid)obj;
         node.Nodes.AddRange(GetFaceNodes(s.Faces).ToArray());
     }
     foreach (var mo in obj.GetChildren())
     {
         LoadMapNode(node, mo);
     }
     if (parent == null) MapTree.Nodes.Add(node);
     else parent.Nodes.Add(node);
 }
开发者ID:silky,项目名称:sledge,代码行数:26,代码来源:MapTreeWindow.cs

示例5: UpdateDecals

        private static bool UpdateDecals(Document document, MapObject mo)
        {
            var updatedChildren = false;
            foreach (var child in mo.GetChildren()) updatedChildren |= UpdateDecals(document, child);

            var e = mo as Entity;
            if (e == null || !ShouldHaveDecal(e))
            {
                var has = e != null && HasDecal(e);
                if (has) SetDecal(e, null);
                return updatedChildren || has;
            }

            var decal = e.EntityData.Properties.FirstOrDefault(x => x.Key == "texture");
            var existingDecal = e.MetaData.Get<string>(DecalNameMetaKey);
            if (decal == null || String.Equals(decal.Value, existingDecal, StringComparison.InvariantCultureIgnoreCase)) return updatedChildren;

            e.SetDecal(document.GetTexture(decal.Value.ToLowerInvariant()));
            return true;
        }
开发者ID:silky,项目名称:sledge,代码行数:20,代码来源:DecalExtensions.cs

示例6: FlattenTree

 private static void FlattenTree(MapObject parent, List<Solid> solids, List<Entity> entities, List<Group> groups)
 {
     foreach (var mo in parent.GetChildren())
     {
         if (mo is Solid)
         {
             solids.Add((Solid) mo);
         }
         else if (mo is Entity)
         {
             entities.Add((Entity) mo);
         }
         else if (mo is Group)
         {
             groups.Add((Group) mo);
             FlattenTree(mo, solids, entities, groups);
         }
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:19,代码来源:VmfProvider.cs

示例7: GetAllTexturesRecursive

        private static IEnumerable<string> GetAllTexturesRecursive(MapObject obj)
        {
            if (obj is Entity && obj.ChildCount == 0)
            {
                var ent = (Entity) obj;
                if (ent.EntityData.Name == "infodecal")
                {
                    var tex = ent.EntityData.Properties.FirstOrDefault(x => x.Key == "texture");
                    if (tex != null) return new[] {tex.Value};
                }
            }
            else if (obj is Solid)
            {
                return ((Solid) obj).Faces.Select(f => f.Texture.Name);
            }

            return obj.GetChildren().SelectMany(GetAllTexturesRecursive);
        }
开发者ID:silky,项目名称:sledge,代码行数:18,代码来源:Map.cs

示例8: LoadMapNode

 private void LoadMapNode(TreeNode parent, MapObject obj)
 {
     var node = new TreeNode(obj.GetType().Name);
     if (obj is World)
     {
         var w = (World) obj;
         node.Nodes.Add(GetEntityNode(w.EntityData));
     }
     else if (obj is Entity)
     {
         var e = (Entity) obj;
         node.Nodes.Add(GetEntityNode(e.EntityData));
     }
     else if (obj is Solid)
     {
         var s = (Solid) obj;
         node.Nodes.Add(GetFacesNode(s.Faces));
     }
     foreach (var mo in obj.GetChildren())
     {
         LoadMapNode(node, mo);
     }
     if (parent == null) treeMap.Nodes.Add(node);
     else parent.Nodes.Add(node);
 }
开发者ID:silky,项目名称:sledge,代码行数:25,代码来源:MainForm.cs

示例9: UpdateModels

        private static bool UpdateModels(Document document, MapObject mo)
        {
            var updatedChildren = false;
            foreach (var child in mo.GetChildren()) updatedChildren |= UpdateModels(document, child);

            var e = mo as Entity;
            if (e == null || !ShouldHaveModel(e))
            {
                var has = e != null && HasModel(e);
                if (has) UnsetModel(e);
                return updatedChildren || has;
            }

            var model = GetModelName(e);
            var existingModel = e.MetaData.Get<string>(ModelNameMetaKey);
            if (String.Equals(model, existingModel, StringComparison.InvariantCultureIgnoreCase)) return updatedChildren; // Already set; No need to continue

            var file = document.Environment.Root.TraversePath(model);
            if (file == null || !ModelProvider.CanLoad(file))
            {
                // Model not valid, get rid of it
                UnsetModel(e);
                return true;
            }

            try
            {
                SetModel(e, ModelProvider.CreateModelReference(file));
                return true;
            }
            catch
            {
                // Couldn't load
                return updatedChildren;
            }
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:36,代码来源:ModelExtensions.cs

示例10: FindRecursive

 private static void FindRecursive(ICollection<MapObject> items, MapObject root, Predicate<MapObject> matcher)
 {
     if (!matcher(root)) return;
     items.Add(root);
     foreach (var mo in root.GetChildren())
     {
         FindRecursive(items, mo, matcher);
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:9,代码来源:ModernRenderer.cs

示例11: UpdateSprites

        private static bool UpdateSprites(Document document, MapObject mo)
        {
            var updatedChildren = false;
            foreach (var child in mo.GetChildren()) updatedChildren |= UpdateSprites(document, child);

            var e = mo as Entity;
            if (e == null || !ShouldHaveSprite(e))
            {
                var has = e != null && HasSprite(e);
                if (has) UnsetSprite(e);
                return updatedChildren || has;
            }

            var sprite = GetSpriteName(e);
            var existingSprite = e.MetaData.Get<string>(SpriteMetaKey);
            if (String.Equals(sprite, existingSprite, StringComparison.InvariantCultureIgnoreCase)) return updatedChildren; // Already set; No need to continue

            var tex = document.TextureCollection.GetItem(sprite);
            if (tex == null)
            {
                UnsetSprite(e);
                return true;
            }
            SetSprite(e, tex);
            return true;
        }
开发者ID:silky,项目名称:sledge,代码行数:26,代码来源:SpriteExtensions.cs

示例12: WriteMapBase

 private static void WriteMapBase(BinaryWriter bw, MapObject obj)
 {
     bw.Write(obj.Visgroups.Except(obj.AutoVisgroups).FirstOrDefault());
     bw.WriteRGBColour(obj.Colour);
     bw.Write(obj.ChildCount);
     foreach (var mo in obj.GetChildren())
     {
         WriteMapObject(bw, mo);
     }
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:10,代码来源:RmfProvider.cs


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