public static ConditionalLine HookLineOut2(ConditionalAutomation auto)
        {
            if (Globals.TempFieldLine != null)
            {
                Globals.TempFieldLine.Remove();
                Globals.TempFieldLine = null;
            }

            if (Globals.TempAutomationLine == null)
            {
                var f = new ConditionalLine();
                f.Left = auto;
                Globals.TempAutomationLine = f;
                return(f);
            }
            else
            {
                if (Globals.TempAutomationLine.Left == null && Globals.TempAutomationLine.Right != auto)
                {
                    var line = new ConditionalLine(auto, Globals.TempAutomationLine.Right);
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(line);
                }
                else
                {
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(HookLineOut2(auto));
                }
            }
        }
        protected override void OnDestroy()
        {
            base.OnDestroy();

            if (LineOut2 != null)
            {
                LineOut2.Remove();
                LineOut2 = null;
            }
        }
Пример #3
0
        public static AutomationLine HookLineIn(Automation auto)
        {
            if (Globals.TempFieldLine != null)
            {
                Globals.TempFieldLine.Remove();
                Globals.TempFieldLine = null;
            }

            if (Globals.TempAutomationLine == null)
            {
                var f = new AutomationLine();
                f.Right = auto;
                Globals.TempAutomationLine = f;
                return(f);
            }
            else
            {
                if (Globals.TempAutomationLine is ConditionalLine || Globals.TempAutomationLine is LoopableLine)
                {
                    if (Globals.TempAutomationLine.Right == null && Globals.TempAutomationLine.Left != auto)
                    {
                        AutomationLine line = null;
                        if (Globals.TempAutomationLine is ConditionalLine)
                        {
                            line = new ConditionalLine(((ConditionalLine)Globals.TempAutomationLine).Left, auto);
                        }
                        else
                        {
                            line = new LoopableLine(((LoopableLine)Globals.TempAutomationLine).Left, auto);
                        }

                        Globals.TempAutomationLine.Remove();
                        Globals.TempAutomationLine = null;
                        return(line);
                    }
                }

                if (Globals.TempAutomationLine.Right == null && Globals.TempAutomationLine.Left != auto)
                {
                    var line = new AutomationLine(Globals.TempAutomationLine.Left, auto);
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(line);
                }
                else
                {
                    Globals.TempAutomationLine.Remove();
                    Globals.TempAutomationLine = null;
                    return(HookLineIn(auto));
                }
            }
        }
        protected override void OnGUI()
        {
            base.OnGUI();

            var rect  = Rectangle;
            var arrow = new Rect(rect.x + rect.width / 2 - 7, rect.y + rect.height, 15, 15);

            GUI.DrawTexture(arrow, Assets["arrowdown"]);
            if (Input.ButtonReleased(Editor.EMouseButton.Left))
            {
                if (arrow.Contains(Input.MousePosition))
                {
                    if (LineOut2 != null)
                    {
                        LineOut2.Remove();
                        LineOut2 = null;
                    }

                    LineOut2 = ConditionalLine.HookLineOut2(this);
                    Window.AddControl(LineOut2);
                    Input.Use();
                }
            }
            else if (Input.ButtonReleased(Editor.EMouseButton.Right))
            {
                if (arrow.Contains(Input.MousePosition))
                {
                    if (LineOut2 != null)
                    {
                        LineOut2.Remove();
                        LineOut2 = null;
                    }

                    Input.Use();
                }
            }
        }
Пример #5
0
        public void LoadAutomatron(string path)
        {
            var a = AutomatronSerializer.Load(path);

            if (a == null)
            {
                return;
            }

            Globals.Camera = a.Camera;
            Name           = a.Name;
            Path           = a.Path;

            foreach (var item in a.Automations)
            {
                var type = Globals.Types.Where(t => t.FullName == item.Type).FirstOrDefault();
                if (type == null)
                {
                    type = Type.GetType(item.Type);
                }
                if (type == null)
                {
                    continue;
                }

                var pos = item.Position;

                var instance = (Automation)Activator.CreateInstance(type);
                instance.Position = pos;

                AddControl(instance);
                instance.ID = item.ID;
                instance.LoadFields();

                foreach (var f in item.Fields)
                {
                    var fid = instance.GetField(f.ID);
                    if (fid != null)
                    {
                        fid.SetValue(f.Value);
                    }
                }

                if (item.ID == a.EntryID)
                {
                    entryPoint = (InternalQueueStart)instance;
                    EntryId    = entryPoint.ID;
                }
            }

            var automations = GetControls <Automation>();

            foreach (var item in a.Lines)
            {
                if (item.LineType == ELineType.FieldLine)
                {
                    var left  = automations.Where(auto => auto.HasField(item.IdLeft)).FirstOrDefault();
                    var right = automations.Where(auto => auto.HasField(item.IdRight)).FirstOrDefault();

                    if (left == null || right == null)
                    {
                        continue;
                    }

                    var line = new FieldLine(left.GetField(item.IdLeft), right.GetField(item.IdRight));
                    AddControl(line);
                }
                else
                {
                    var left  = automations.Where(auto => auto.ID == item.IdLeft).FirstOrDefault();
                    var right = automations.Where(auto => auto.ID == item.IdRight).FirstOrDefault();

                    if (left == null || right == null)
                    {
                        continue;
                    }

                    BezierLine line = null;

                    switch (item.LineType)
                    {
                    case ELineType.AutomationLine:
                        line = new AutomationLine(left, right);
                        break;

                    case ELineType.ConditionalLine:
                        line = new ConditionalLine((ConditionalAutomation)left, right);
                        break;

                    case ELineType.LoopableLine:
                        line = new LoopableLine((LoopableAutomation)left, right);
                        break;
                    }

                    if (line != null)
                    {
                        AddControl(line);
                        line.ID = item.ID;
                    }
                }
            }

            var id = GetControlID();

            if (id < a.ControlID)
            {
                var amount = a.ControlID - id;
                for (int i = 0; i < amount; i++)
                {
                    GetControlID();
                }
            }

            if (entryPoint == null)
            {
                entryPoint = new InternalQueueStart()
                {
                    Position = WindowRect.center
                };
                AddControl(entryPoint);

                EntryId = entryPoint.ID;
            }
        }