예제 #1
0
 /// <summary>
 /// Default Constructor for the Type Mapper.
 /// </summary>
 /// <param name="item">Related Engine Item</param>
 /// <param name="property">Related Engine Property</param>
 public CollectorState(Item item, CollectorProperty property)
     : base(item, property)
 {
     // Bind Range
     CollectorRange = property.CollectorRange;
     property.OnCollectorRangeChanged += (i, v) => { CollectorRange = v; };
 }
예제 #2
0
        /// <summary>
        /// Internal call to give a requested amount.
        /// </summary>
        /// <param name="collector">Giving Collector Item Property</param>
        /// <param name="amount">Requested Amount</param>
        /// <returns>Actual Amount</returns>
        internal int Give(CollectorProperty collector, int amount)
        {
            // Check for available Space
            int given = Math.Min(amount, Capacity - Amount);

            // Increase requested amount
            if (given > 0)
                Amount += given;
            return given;
        }
예제 #3
0
        /// <summary>
        /// Internal call to take a requested amount.
        /// </summary>
        /// <param name="collector">Collecting Item Property</param>
        /// <param name="request">Requested Amount</param>
        /// <returns>Actual Amount</returns>
        internal int Take(CollectorProperty collector, int request)
        {
            // Be sure it's a positive Request
            request = Math.Max(0, request);

            // Check how many can be taken
            int collected = Math.Max(0, Math.Min(request, Amount));

            // Decrease requested amount
            if (collected > 0)
                Amount -= collected;
            return collected;
        }
예제 #4
0
 /// <summary>
 /// Default Constructor for the Type Mapper.
 /// </summary>
 /// <param name="item">Related Engine Item</param>
 /// <param name="property">Related Engine Property</param>
 public CollectorState(Item item, CollectorProperty property) : base(item, property)
 {
     // Bind Range
     CollectorRange = property.CollectorRange;
     property.OnCollectorRangeChanged += (i, v) => { CollectorRange = v; };
 }