예제 #1
0
        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);
            }
        }
예제 #2
0
파일: Map.cs 프로젝트: NCC-Lykos/Chisel
        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));
        }