Example #1
0
 public AggregatePropertyVariable(PropertyAggregate aggregationType, EntityProvider entityProvider, PropertySupplier property, Direction?direction)
 {
     this.aggregationType = aggregationType;
     this.entityProvider  = entityProvider;
     this.property        = property;
     this.direction       = direction;
 }
Example #2
0
 public BlockPropertyCondition(PropertySupplier property, Direction?direction, PrimitiveComparator comparator, Variable comparisonValue)
 {
     this.property        = property;
     this.comparator      = comparator;
     this.comparisonValue = comparisonValue;
     this.direction       = direction;
 }
            float GetProducingAmount(IMyAssembler b, PropertySupplier p)
            {
                var definitions  = PROGRAM.GetItemBluePrints(CastString(p.valueAttribute.GetValue()).GetTypedValue());
                var currentItems = new List <MyProductionItem>();

                b.GetQueue(currentItems);
                MyFixedPoint value = currentItems.Where(item => definitions.Contains(item.BlueprintId)).Select(item => item.Amount).Aggregate((sum, val) => sum + val);

                return((float)value);
            }
Example #4
0
            public bool evaluate(Object block, Block blockType)
            {
                BlockHandler     handler = BlockHandlerRegistry.GetBlockHandler(blockType);
                Primitive        value   = comparisonValue.GetValue();
                PropertySupplier prop    = property ?? handler.GetDefaultProperty(value.GetPrimitiveType());

                if (direction.HasValue)
                {
                    return(comparator.compare(handler.GetPropertyValue(block, prop, direction.Value), value));
                }
                else
                {
                    return(comparator.compare(handler.GetPropertyValue(block, prop), value));
                }
            }
Example #5
0
            public Primitive GetValue()
            {
                List <Object> blocks = entityProvider.GetEntities();

                if (aggregationType == PropertyAggregate.COUNT)
                {
                    return(new NumberPrimitive(blocks.Count));
                }

                BlockHandler handler = BlockHandlerRegistry.GetBlockHandler(entityProvider.GetBlockType());

                PropertySupplier p = property ?? handler.GetDefaultProperty(Return.NUMERIC);

                List <Primitive> propertyValues = blocks.Select(b => {
                    return(direction.HasValue ? handler.GetPropertyValue(b, p, direction.Value) : handler.GetPropertyValue(b, p));
                }).ToList();

                return(Aggregate(propertyValues, aggregationType));
            }