Exemplo n.º 1
0
        private void AddScripts(List <ScriptType> items)
        {
            var actions = new List <IUndoAction>(4);

            for (int i = 0; i < items.Count; i++)
            {
                var scriptType = items[i];
                var actors     = ScriptsEditor.ParentEditor.Values;
                for (int j = 0; j < actors.Count; j++)
                {
                    var actor = (Actor)actors[j];
                    actions.Add(AddRemoveScript.Add(actor, scriptType));
                }
            }

            if (actions.Count == 0)
            {
                Editor.LogWarning("Failed to spawn scripts");
                return;
            }

            var multiAction = new MultiUndoAction(actions);

            multiAction.Do();
            ScriptsEditor.Presenter?.Undo.AddAction(multiAction);
        }
Exemplo n.º 2
0
        private void AddScripts(List <ScriptItem> items)
        {
            var actions = new List <IUndoAction>(4);

            for (int i = 0; i < items.Count; i++)
            {
                var item       = items[i];
                var scriptName = item.ScriptName;
                var scriptType = ScriptsBuilder.FindScript(scriptName);
                if (scriptType == null)
                {
                    Editor.LogError("Invalid script type " + scriptName);
                    return;
                }

                var actors = ScriptsEditor.ParentEditor.Values;
                for (int j = 0; j < actors.Count; j++)
                {
                    var actor = (Actor)actors[j];
                    actions.Add(AddRemoveScript.Add(actor, scriptType));
                }
            }

            if (actions.Count == 0)
            {
                Editor.LogWarning("Failed to spawn scripts");
                return;
            }

            var multiAction = new MultiUndoAction(actions);

            multiAction.Do();
            Editor.Instance.Undo.AddAction(multiAction);
        }
Exemplo n.º 3
0
            /// <inheritdoc />
            public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data)
            {
                var result = base.OnDragDrop(ref location, data);

                if (_dragScripts.HasValidDrag)
                {
                    result = _dragScripts.Effect;

                    var actions = new List <IUndoAction>(4);

                    for (int i = 0; i < _dragScripts.Objects.Count; i++)
                    {
                        var item       = _dragScripts.Objects[i];
                        var scriptName = item.ScriptName;
                        var scriptType = ScriptsBuilder.FindScript(scriptName);

                        var actors = ScriptsEditor.ParentEditor.Values;
                        for (int j = 0; j < actors.Count; j++)
                        {
                            var actor = (Actor)actors[j];
                            actions.Add(AddRemoveScript.Add(actor, scriptType));
                        }
                    }

                    var multiAction = new MultiUndoAction(actions);
                    multiAction.Do();
                    Editor.Instance.Undo.AddAction(multiAction);
                }

                _dragScripts.OnDragDrop();

                return(result);
            }