Example #1
0
 /// <inheritdoc/>
 public void Dispose()
 {
     if (this.parentAttribute != null)
     {
         this.parentAttribute.RemoveElement(this);
         this.ValueChanged          = null;
         this.parentAttribute       = null;
         this.element.ValueChanged -= this.OnValueChanged;
     }
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PowerUpWrapper"/> class.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="targetAttribute">The target attribute.</param>
        /// <param name="attributeHolder">The attribute holder.</param>
        public PowerUpWrapper(IElement element, AttributeDefinition targetAttribute, AttributeSystem attributeHolder)
        {
            this.parentAttribute = attributeHolder.GetComposableAttribute(targetAttribute);
            if (this.parentAttribute == null)
            {
                throw new ArgumentException($"targetAttribute [{targetAttribute}] is not composable");
            }

            this.parentAttribute.AddElement(this);
            this.element = element;
            this.element.ValueChanged += this.OnValueChanged;
        }
        /// <inheritdoc/>
        public void AddElement(IElement element, AttributeDefinition targetAttribute)
        {
            var attributeDictionary = this.GetAttributeDictionary();

            if (!attributeDictionary.TryGetValue(targetAttribute, out IComposableAttribute attribute))
            {
                attribute = new ComposableAttribute(targetAttribute);
                var attrValue = this.GetValueOfAttribute(targetAttribute);
                var nullValue = element.AggregateType == AggregateType.Multiplicate ? 1 : 0;
                attrValue = Math.Abs(attrValue) < 0.01f ? nullValue : attrValue;
                attribute.AddElement(new SimpleElement {
                    Value = attrValue
                });
            }

            attribute.AddElement(element);
        }
Example #4
0
        public void Setup()
        {
            var attributeDefinition = new AttributeDefinition(new Guid("52263EA9-F309-475D-B10B-352D3BFD7650"), "Test attribute", "Test attribute");

            this.composableAttribute = new ComposableAttribute(attributeDefinition);
        }