/// <summary>
        /// Adds the provided quantity of the provided consumable resource. Will not go beyond the maximum
        /// </summary>
        /// <param name="model">A model that can be used to obtain data about the current game configuration.</param>
        /// <param name="resource">The resource to increase</param>
        /// <param name="quantity">The amount to increase by</param>
        public void ApplyAddResource(SuperMetroidModel model, RechargeableResourceEnum resource, int quantity)
        {
            // Don't bother with current resource count if resource tracking is disabled
            if (model.LogicalOptions.ResourceTrackingEnabled)
            {
                int max           = GetMaxAmount(resource);
                int currentAmount = Resources.GetAmount(resource);

                // We're already at max (or greater, somehow). Don't add anything
                if (currentAmount >= max)
                {
                    return;
                }
                int newAmount = currentAmount + quantity;

                Resources.ApplyAmount(resource, Math.Min(max, currentAmount + quantity));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates and returns a copy of this ResourceCount, with positive and negative values flipped.
        /// </summary>
        /// <returns></returns>
        public ResourceCount CloneNegative()
        {
            ResourceCount clone = Clone();

            foreach (RechargeableResourceEnum currentResource in Enum.GetValues(typeof(RechargeableResourceEnum)))
            {
                clone.ApplyAmount(currentResource, clone.GetAmount(currentResource) * -1);
            }

            return(clone);
        }
        /// <summary>
        /// Creates and returns a ResourceCount that expresses how many rechargeable resources this in-game state has,
        /// relative to the provided in-game state. Negative values mean this state has less.
        /// </summary>
        /// <param name="other">The other in-game state to compare with.</param>
        /// <returns></returns>
        public ResourceCount GetResourceVariationWith(InGameState other)
        {
            ResourceCount returnValue = new ResourceCount();

            foreach (RechargeableResourceEnum currentResource in Enum.GetValues(typeof(RechargeableResourceEnum)))
            {
                returnValue.ApplyAmount(currentResource, GetCurrentAmount(currentResource) - other.GetCurrentAmount(currentResource));
            }

            return(returnValue);
        }