Esempio n. 1
0
        /// <summary>
        /// Creates a new element on this attribute system with the specified power up value.
        /// </summary>
        /// <param name="attributeSystem">The attribute system.</param>
        /// <param name="value">The value.</param>
        /// <returns>The added element.</returns>
        public static IElement CreateElement(this IAttributeSystem attributeSystem, PowerUpDefinitionValue value)
        {
            var      relations = value.RelatedValues;
            IElement result    = value.ConstantValue;

            if (relations?.Any() ?? false)
            {
                var elements = relations
                               .Select(r => new AttributeRelationshipElement(
                                           new[] { attributeSystem.GetOrCreateAttribute(r.InputAttribute) },
                                           r.InputOperand,
                                           r.InputOperator))
                               .Cast <IElement>();
                if (value.ConstantValue != null)
                {
                    elements = elements.Concat(value.ConstantValue.GetAsEnumerable());
                }

                result = new AttributeRelationshipElement(elements.ToList(), 1.0F, InputOperator.Multiply);
            }

            if (result == null)
            {
                throw new ArgumentException($"The passed {nameof(PowerUpDefinitionValue)} doesn't have a constant value or related values.", nameof(value));
            }

            return(result);
        }
        /// <summary>
        /// Creates a new element on this attribute system with the specified power up value.
        /// </summary>
        /// <param name="attributeSystem">The attribute system.</param>
        /// <param name="value">The value.</param>
        /// <returns>The added element.</returns>
        public static IElement CreateElement(this IAttributeSystem attributeSystem, PowerUpDefinitionValue value)
        {
            var relations = value.RelatedValues;
            var result    = value.ConstantValue;

            if (relations?.Any() ?? false)
            {
                var elements = relations
                               .Select(r => new AttributeRelationshipElement(
                                           new[] { attributeSystem.GetOrCreateAttribute(r.InputAttribute ?? throw new InvalidOperationException($"InputAttribute value not set for AttributeRelationship {r.GetId()}.")) },
Esempio n. 3
0
 /// <inheritdoc/>
 public void AddAttributeRelationship(AttributeRelationship combination, IAttributeSystem sourceAttributeHolder)
 {
     throw new NotImplementedException();
 }