Example #1
0
        public static Composite CreateShamanElementalHeal()
        {
            Composite healBT =
                new Decorator(
                    ret => !StyxWoW.Me.Combat || (Group.Healers.Any() && !Group.Healers.Any(h => h.IsAlive)),
                    Common.CreateShamanNonHealBehavior()
                    );

            // only include group healing logic if we are configured for group heal and in an Instance
            if (SingularRoutine.CurrentWoWContext == WoWContext.Instances && SingularSettings.Instance.Shaman.ElementalHeal )
            {
                healBT =new Decorator(
                            ret => !StyxWoW.Me.GroupInfo.IsInRaid,
                            new PrioritySelector(
                                // Heal the party in dungeons if the healer is dead
                                new Decorator(
                                    ret => StyxWoW.Me.CurrentMap.IsDungeon && Group.Healers.Count(h => h.IsAlive) == 0,
                                    Restoration.CreateRestoShamanHealingOnlyBehavior()),

                                healBT
                                )
                            );
            }

            return healBT;
        }
Example #2
0
        public static Composite CreateShamanEnhancementHeal()
        {
            Composite healBT =
                    new Decorator(
                        ret => !Group.Healers.Any(h => h.IsAlive && h.Distance < 40),
                        Spell.Heal("Healing Surge", ret => StyxWoW.Me, ret => StyxWoW.Me.GetPredictedHealthPercent() <= 60)
                    );

            // group healing logic ONLY if we are configured for it and in an Instance
            if (SingularRoutine.CurrentWoWContext == WoWContext.Instances && SingularSettings.Instance.Shaman.EnhancementHeal)
            {
                healBT =new Decorator(
                            ret => !StyxWoW.Me.GroupInfo.IsInRaid,
                            new PrioritySelector(
                                // Off Heal the party in dungeons if the healer is dead
                                new Decorator(
                                    ret => StyxWoW.Me.CurrentMap.IsDungeon && !Group.Healers.Any(h => h.IsAlive),
                                    Restoration.CreateRestoShamanHealingOnlyBehavior()),

                                healBT
                                )
                            );
            }

            return healBT;
        }
Example #3
0
 /// <summary>
 /// Constructor for the <c>ElementLabel</c> object. This is
 /// used to create a label that can convert a XML node into a
 /// composite object or a primitive type from an XML element.
 /// </summary>
 /// <param name="contact">
 /// this is the field that this label represents
 /// </param>
 /// <param name="label">
 /// this is the annotation for the contact
 /// </param>
 public ElementLabel(Contact contact, Element label) {
    this.detail = new Signature(contact, this);
    this.decorator = new Qualifier(contact);
    this.type = contact.Type;
    this.name = label.name();
    this.label = label;
 }
Example #4
0
        static DecoratorTests()
        {
            QUnit.module("Decorator tests");

            QUnit.test("Set Decorator.Child succeeds with null", delegate
            {
                Decorator d = new Decorator();
                d.Child = null;
            });

            QUnit.test("Set Decorator.Child succeeds with Control", delegate
            {
                Decorator d = new Decorator();
                UiElement c = new UiElement();
                d.Child = c;

                QUnit.ok(d.Child == c, "child should be the control");
                QUnit.ok(c.Parent == d, "parent should be the decorator");
            });

            QUnit.test("Reset Decorator.Child clears child's parent", delegate
            {
                Decorator d = new Decorator();
                UiElement c = new UiElement();
                d.Child = c;

                d.Child = null;

                QUnit.ok(d.Child == null, "child should be null");
                QUnit.ok(c.Parent == null, "parent should be null");
            });
        }
Example #5
0
        static RegionTests()
        {
            QUnit.module("Region tests");

            QUnit.test("Region.GetRegion succeeds with null", delegate
            {
                QUnit.equals(Region.GetRegion(null), null, "should return null");
            });

            QUnit.test("Region.GetRegion succeeds with unparented control", delegate
            {
                UiElement c = new UiElement();
                QUnit.equals(Region.GetRegion(c), null, "should return null");
            });

            QUnit.test("Region.GetRegion succeeds with parented control", delegate
            {
                Region r = new Region();
                UiElement c = new UiElement();
                r.Child = c;

                QUnit.ok(Region.GetRegion(c) == r, "should return the region");
            });

            QUnit.test("Region.GetRegion succeeds with parented control chain", delegate
            {
                Region r = new Region();
                Decorator d = new Decorator();
                UiElement c = new UiElement();
                d.Child = c;
                r.Child = d;

                QUnit.ok(Region.GetRegion(c) == r, "should return the region");
            });
        }
Example #6
0
 public RuntimeDecorator(Node parent, Decorator decorator, int oaType, float tick, bool inversed, bool activeSelf)
 {
     this.parent = parent;
     this.decorator = decorator;
     this.observerAbortsType = oaType;
     this.tick = tick;
     this.inversed = inversed;
     this.activeSelf = activeSelf;
 }
Example #7
0
        public void LogicalParent_Should_Be_Set_To_Parent()
        {
            var parent = new Decorator();
            var target = new TestControl();

            parent.Child = target;

            Assert.Equal(parent, target.InheritanceParent);
        }
Example #8
0
        public void Content_Control_Should_Appear_In_LogicalChildren()
        {
            var decorator = new Decorator();
            var child = new Control();

            decorator.Child = child;

            Assert.Equal(new[] { child }, ((ILogical)decorator).LogicalChildren.ToList());
        }
Example #9
0
    public void DrawBehaviorTree(BehaviorTree behaviorTree)
    {
        if(behaviorTree == null || BehaviorTreeEditor.BTEditorWindow == null)
        {
            return;
        }

        if(behaviorTree != _behaviorTree)
        {
            BehaviorTreeEditorHelper.GenerateQueue(_drawingQueue, behaviorTree);
            BehaviorTreeEditor.BTEditorWindow.Repaint();
        }

        _behaviorTree = behaviorTree;

        if (_behaviorTree.Child == null)
        {
            int i = EditorGUI.Popup(_addRootRect, "Add root: ", 0, _addChildOptions, BehaviorTreeEditorSettings.Instance.AddButtonStyle);
            switch (i)
            {
                case 1:
                    Sequence newSequence = new Sequence();
                    behaviorTree.AddChild(newSequence);
                    break;
                case 2:
                    Selector newSelector = new Selector();
                    behaviorTree.AddChild(newSelector);
                    break;
                case 3:
                    Decorator newDecorator = new Decorator();
                    behaviorTree.AddChild(newDecorator);
                    break;
                case 4:
                    Task t = new Task();
                    behaviorTree.AddChild(t);
                    break;
                default:
                    break;
            }

            BehaviorTreeEditorHelper.GenerateQueue(_drawingQueue, _behaviorTree);
        }

        _scrollPos = GUI.BeginScrollView(new Rect(0, 100, BehaviorTreeEditor.BTEditorWindow.position.width - BehaviorTreeEditorSettings.Instance.SideMenuRect.width - 10, BehaviorTreeEditor.BTEditorWindow.position.height - _addRootRect.height - 100),
                                        _scrollPos,
                                        new Rect(0, 100, BehaviorTreeEditorHelper.GetWidth() * (BehaviorTreeEditorSettings.Instance.ElementWidth + BehaviorTreeEditorSettings.Instance.HorizontalSpaceBetweenElements) + 110 + _infoRect.x,
                                                        BehaviorTreeEditorHelper.GetDepth(_drawingQueue) * (BehaviorTreeEditorSettings.Instance.ElementHeight + BehaviorTreeEditorSettings.Instance.VerticalSpaceBetweenElements) + 100));

        BehaviorTreeEditor.BTEditorWindow.BeginWindows();

        GUILayout.Window(-1, _infoRect, DrawInfo, "Behavior Tree Info");
        DrawStack();

        BehaviorTreeEditor.BTEditorWindow.EndWindows();
        GUI.EndScrollView();
    }
Example #10
0
        public void LogicalParent_Should_Be_Cleared_When_Removed_From_Parent()
        {
            var parent = new Decorator();
            var target = new TestControl();

            parent.Child = target;
            parent.Child = null;

            Assert.Null(target.InheritanceParent);
        }
Example #11
0
        public void Setting_Content_Should_Set_Child_Controls_Parent()
        {
            var decorator = new Decorator();
            var child = new Control();

            decorator.Child = child;

            Assert.Equal(child.Parent, decorator);
            Assert.Equal(((ILogical)child).LogicalParent, decorator);
        }
Example #12
0
        public void Setting_Parent_Should_Also_Set_InheritanceParent()
        {
            var parent = new Decorator();
            var target = new TestControl();

            parent.Child = target;

            Assert.Equal(parent, target.Parent);
            Assert.Equal(parent, target.InheritanceParent);
        }
Example #13
0
        public void Clearing_Content_Should_Remove_From_LogicalChildren()
        {
            var decorator = new Decorator();
            var child = new Control();

            decorator.Child = child;
            decorator.Child = null;

            Assert.Equal(new ILogical[0], ((ILogical)decorator).LogicalChildren.ToList());
        }
        public void Materialize_Should_Create_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null);
            var result = containers.OfType<TextBlock>().Select(x => x.Text).ToList();

            Assert.Equal(items, result);
        }
Example #15
0
        public void Clearing_Content_Should_Clear_Child_Controls_Parent()
        {
            var decorator = new Decorator();
            var child = new Control();

            decorator.Child = child;
            decorator.Child = null;

            Assert.Null(child.Parent);
            Assert.Null(((ILogical)child).LogicalParent);
        }
        public void IndexFromContainer_Should_Return_Index()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            Assert.Equal(0, target.IndexFromContainer(containers[0]));
            Assert.Equal(1, target.IndexFromContainer(containers[1]));
            Assert.Equal(2, target.IndexFromContainer(containers[2]));
        }
        public void ContainerFromIndex_Should_Return_Materialized_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            Assert.Equal(containers[0], target.ContainerFromIndex(0));
            Assert.Equal(containers[1], target.ContainerFromIndex(1));
            Assert.Equal(containers[2], target.ContainerFromIndex(2));
        }
        public void IndexFromContainer_Should_Return_Index()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = Materialize(target, 0, items);

            Assert.Equal(0, target.IndexFromContainer(containers[0].ContainerControl));
            Assert.Equal(1, target.IndexFromContainer(containers[1].ContainerControl));
            Assert.Equal(2, target.IndexFromContainer(containers[2].ContainerControl));
        }
        public void Dematerialize_Should_Return_Removed_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = Materialize(target, 0, items);
            var expected = target.Containers.Take(2).ToList();
            var result = target.Dematerialize(0, 2);

            Assert.Equal(expected, result);
        }
        public void ContainerFromIndex_Should_Return_Materialized_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = Materialize(target, 0, items);

            Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0));
            Assert.Equal(containers[1].ContainerControl, target.ContainerFromIndex(1));
            Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2));
        }
Example #21
0
        public void Setting_Parent_Should_Not_Set_InheritanceParent_If_Already_Set()
        {
            var parent = new Decorator();
            var inheritanceParent = new Decorator();
            var target = new TestControl();

            ((ISetInheritanceParent)target).SetParent(inheritanceParent);
            parent.Child = target;

            Assert.Equal(parent, target.Parent);
            Assert.Equal(inheritanceParent, target.InheritanceParent);
        }
Example #22
0
        public void InheritanceParent_Should_Be_Cleared_When_Removed_From_Parent_When_Has_Different_InheritanceParent()
        {
            var parent = new Decorator();
            var inheritanceParent = new Decorator();
            var target = new TestControl();

            ((ISetInheritanceParent)target).SetParent(inheritanceParent);
            parent.Child = target;
            parent.Child = null;

            Assert.Null(target.InheritanceParent);
        }
Example #23
0
 protected override Composite CreateBehavior()
 {
     var children=new Composite[2];
     var compositeArray=new Composite[2];
     compositeArray[0]=new Action(new ActionSucceedDelegate(FlagTagAsCompleted));
     children[0]=new Decorator(CheckDistanceWithinPathPrecision, new Sequence(compositeArray));
     ActionDelegate actionDelegateMove=GilesMoveToLocation;
     var sequenceblank=new Sequence(
         new Action(actionDelegateMove)
         );
     children[1]=sequenceblank;
     return new PrioritySelector(children);
 }
        public void Dematerialize_Should_Remove_Container()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = Materialize(target, 0, items);

            target.Dematerialize(1, 1);

            Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0));
            Assert.Equal(null, target.ContainerFromIndex(1));
            Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(2));
        }
Example #25
0
        public void Setting_Content_Should_Fire_LogicalChildren_CollectionChanged()
        {
            var decorator = new Decorator();
            var child = new Control();
            var called = false;

            ((ILogical)decorator).LogicalChildren.CollectionChanged += (s, e) =>
                called = e.Action == NotifyCollectionChangedAction.Add;

            decorator.Child = child;

            Assert.True(called);
        }
        public void RemoveRange_Should_Alter_Successive_Container_Indexes()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = target.Materialize(0, items, null).ToList();

            var removed = target.RemoveRange(1, 1).Single();

            Assert.Equal(containers[0].ContainerControl, target.ContainerFromIndex(0));
            Assert.Equal(containers[2].ContainerControl, target.ContainerFromIndex(1));
            Assert.Equal(containers[1], removed);
        }
        public void Materialize_Should_Create_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator<ListBoxItem>(owner, ListBoxItem.ContentProperty);
            var containers = target.Materialize(0, items, null);
            var result = containers
                .Select(x => x.ContainerControl)
                .OfType<ListBoxItem>()
                .Select(x => x.Content)
                .ToList();

            Assert.Equal(items, result);
        }
        public void Materialize_Should_Create_Containers()
        {
            var items = new[] { "foo", "bar", "baz" };
            var owner = new Decorator();
            var target = new ItemContainerGenerator(owner);
            var containers = Materialize(target, 0, items);
            var result = containers
                .Select(x => x.ContainerControl)
                .OfType<ContentPresenter>()
                .Select(x => x.Content)
                .ToList();

            Assert.Equal(items, result);
        }
Example #29
0
        public void Changing_Content_Should_Fire_LogicalChildren_CollectionChanged()
        {
            var decorator = new Decorator();
            var child1 = new Control();
            var child2 = new Control();
            var called = false;

            decorator.Child = child1;

            ((ILogical)decorator).LogicalChildren.CollectionChanged += (s, e) => called = true;

            decorator.Child = child2;

            Assert.True(called);
        }
Example #30
0
        private void Initialize()
        {
            // Popup root has a decorator used for
            // applying the transforms
            _transformDecorator = new Decorator();

            AddVisualChild(_transformDecorator);

            // Clip so animations do not extend beyond its bounds
            _transformDecorator.ClipToBounds = true;

            // Under the transfrom decorator is an Adorner
            // decorator that handles rendering adorners
            // and the animated popup translations
            _adornerDecorator = new NonLogicalAdornerDecorator();
            _transformDecorator.Child = _adornerDecorator;
        }