コード例 #1
0
ファイル: GroupAction.cs プロジェクト: KonstantinUb/sledge
        public void Perform(Document document)
        {
            var objects = _groupedObjects
                .Select(x => document.Map.WorldSpawn.FindByID(x))
                .Where(x => x != null && x.Parent != null)
                .ToList();
            _originalChildParents = objects.ToDictionary(x => x.ID, x => x.Parent.ID);

            if (_groupId == 0) _groupId = document.Map.IDGenerator.GetNextObjectID();
            var group = new Group(_groupId);

            objects.ForEach(x => x.SetParent(group));
            group.SetParent(document.Map.WorldSpawn);
            group.UpdateBoundingBox();

            if (group.GetChildren().All(x => x.IsSelected))
            {
                document.Selection.Select(group);
                Mediator.Publish(EditorMediator.SelectionChanged);
            }

            Mediator.Publish(EditorMediator.DocumentTreeStructureChanged);
        }
コード例 #2
0
ファイル: UngroupAction.cs プロジェクト: silky/sledge
        public void Reverse(Document document)
        {
            foreach (var gp in _groupsAndParents)
            {
                var group = new Group(gp.Key) {Colour = Colour.GetRandomGroupColour()};
                var parent = document.Map.WorldSpawn.FindByID(gp.Value);
                group.SetParent(parent);
            }
            foreach (var cp in _childrenAndParents)
            {
                var child = document.Map.WorldSpawn.FindByID(cp.Key);
                var parent = document.Map.WorldSpawn.FindByID(cp.Value);
                child.SetParent(parent);
                child.UpdateBoundingBox();
                child.Colour = parent.Colour.Vary();
            }
            foreach (var gp in _groupsAndParents)
            {
                var group = document.Map.WorldSpawn.FindByID(gp.Key);
                if (group.GetChildren().All(x => x.IsSelected)) document.Selection.Select(group);
            }

            Mediator.Publish(EditorMediator.SelectionChanged);
            Mediator.Publish(EditorMediator.DocumentTreeStructureChanged);
        }