/// <summary>
        /// Give the given amount to the given Destination.
        /// </summary>
        /// <param name="property">Destination Property</param>
        /// <param name="amount">Requested Amount</param>
        /// <returns>Actual Amount</returns>
        public int Give(CollectableProperty property, int amount)
        {
            // Check for Right Collectable Type
            if (property.GetType() != AcceptedCollectableType)
                throw new NotSupportedException("Not supported Collectable Property");

            // Ensure both Items are Part of the same Engine
            if (Item.Engine == null)
                throw new NotSupportedException("Collector is not part of the Engine");
            if (property.Item.Engine == null)
                throw new NotSupportedException("Collectable is not part of the Engine");
            if (Item.Engine != property.Item.Engine)
                throw new NotSupportedException("Collector and Collectable are not part of the same Engine");

            // Distanz überprüfen
            if (Item.GetDistance(Item, property.Item) > CollectorRange + property.CollectableRadius)
                return 0;

            // Check for available Amount
            amount = Math.Min(amount, Amount);

            // Request
            int result = property.Give(this, amount);

            // Finalize transfer
            Amount -= result;

            return result;
        }
        public DebugCollectableItem(ITypeResolver resolver, Vector2 pos)
            : base(resolver, pos, Angle.Right)
        {
            collectable = new CollectableProperty(this);

            AddProperty(collectable);
        }
 /// <summary>
 /// Default Constructor for the Type Mapper.
 /// </summary>
 /// <param name="item">Related Engine Item</param>
 /// <param name="property">Related Engine Property</param>
 public CollectableState(Item item, CollectableProperty property)
     : base(item, property)
 {
     // Bind Radius
     CollectableRadius = property.CollectableRadius;
     property.OnCollectableRadiusChanged += (i,v) => { CollectableRadius = v; };
 }
 private void InitCollectableItem(Vector2 pos)
 {
     CollectableItem = new DebugCollectableItem(pos);
     Collectable = CollectableItem.GetProperty<CollectableProperty>();
     Engine.InsertItem(CollectableItem);
 }
 public void CleanupEngine()
 {
     AttackerItem = null;
     AttackableItem = null;
     CollectorItem = null;
     CollectableItem = null;
     Attacker = null;
     Attackable = null;
     Collector = null;
     Collectable = null;
     Map = null;
     Engine = null;
 }
        /// <summary>
        /// Takes the requested amount from the Property.
        /// </summary>
        /// <param name="property">Source Property</param>
        /// <param name="amount">Requested Amount</param>
        /// <returns>Actual Amount</returns>
        public int Take(CollectableProperty property, int amount)
        {
            // Check for Right Collectable Type
            if (property.GetType() != AcceptedCollectableType)
                throw new NotSupportedException("Not supported Collectable Property");

            // Ensure both Items are Part of the same Engine
            if (Item.Engine == null)
                throw new NotSupportedException("Collector is not part of the Engine");
            if (property.Item.Engine == null)
                throw new NotSupportedException("Collectable is not part of the Engine");
            if (Item.Engine != property.Item.Engine)
                throw new NotSupportedException("Collector and Collectable are not part of the same Engine");

            // Check the right distance
            if (Item.GetDistance(Item, property.Item) > CollectorRange + property.CollectableRadius)
                return 0;

            // Cap to the available Capacity
            amount = Math.Min(amount, Capacity - Amount);

            // Request Good
            int result = property.Take(this, amount);

            // Finalize transfer.
            Amount += result;

            return result;
        }