/// <summary>
 /// Sets current value for the provided resource to the current 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 refill</param>
 public void ApplyRefillResource(SuperMetroidModel model, RechargeableResourceEnum resource)
 {
     // Don't bother with current resource count if resource tracking is disabled
     if (model.LogicalOptions.ResourceTrackingEnabled)
     {
         Resources.ApplyAmount(resource, Inventory.GetMaxAmount(resource));
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Returns the consumable resource that drains this rechargeable resource.
 /// </summary>
 /// <param name="resource">This rechargeable resource</param>
 /// <returns></returns>
 public static ConsumableResourceEnum ToConsumableResource(this RechargeableResourceEnum resource)
 {
     return(resource switch
     {
         RechargeableResourceEnum.RegularEnergy => ConsumableResourceEnum.ENERGY,
         RechargeableResourceEnum.ReserveEnergy => ConsumableResourceEnum.ENERGY,
         RechargeableResourceEnum.Missile => ConsumableResourceEnum.MISSILE,
         RechargeableResourceEnum.Super => ConsumableResourceEnum.SUPER,
         RechargeableResourceEnum.PowerBomb => ConsumableResourceEnum.POWER_BOMB,
         _ => throw new Exception($"Unrecognized rechargeable resource {resource}")
     });
        /// <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));
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Returns the enemy drops that can recharge this resource.
 /// </summary>
 /// <param name="resource">This resource</param>
 /// <returns>The enemy drops that can refill this</returns>
 public static IEnumerable <EnemyDropEnum> GetRelatedDrops(this RechargeableResourceEnum resource)
 {
     return(resource.ToConsumableResource().GetRelatedDrops());
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the amount associated to this container for the provided rechargeable resource.
 /// </summary>
 /// <param name="resource">Resource to get the amount of.</param>
 /// <returns></returns>
 public int GetAmount(RechargeableResourceEnum resource)
 {
     return(Amounts[resource]);
 }
Esempio n. 6
0
 /// <summary>
 /// Sets in this container the provided amount for the provided resource.
 /// </summary>
 /// <param name="resource">The resource to apply an amount for.</param>
 /// <param name="newAmount">The new amount to set.</param>
 public void ApplyAmount(RechargeableResourceEnum resource, int newAmount)
 {
     Amounts[resource] = newAmount;
 }
Esempio n. 7
0
 /// <summary>
 /// Sets in this container the resource amount found in the provided other container for the provided resource.
 /// </summary>
 /// <param name="resource">The resource to apply an amount for</param>
 /// <param name="other">The ResourceCount to use the amount from</param>
 public void ApplyAmount(RechargeableResourceEnum resource, ResourceCount other)
 {
     Amounts[resource] = other.Amounts[resource];
 }
Esempio n. 8
0
 /// <summary>
 /// Increases the provided quantity of the provided rechargeable resource.
 /// </summary>
 /// <param name="resource">The resource to reduce</param>
 /// <param name="quantity">The amount to reduce</param>
 public void ApplyAmountIncrease(RechargeableResourceEnum resource, int increase)
 {
     Amounts[resource] += increase;
 }
 /// <summary>
 /// Returns the current amount of the provided rechargeable resource.
 /// </summary>
 /// <param name="resource">Resource to get the amount of.</param>
 /// <returns></returns>
 public int GetCurrentAmount(RechargeableResourceEnum resource)
 {
     return(Resources.GetAmount(resource));
 }
 /// <summary>
 /// Returns the maximum possible amount of the provided resource in this InGameState.
 /// </summary>
 /// <param name="resource">The resource to get the max amount of.</param>
 /// <returns></returns>
 public int GetMaxAmount(RechargeableResourceEnum resource)
 {
     return(Inventory.GetMaxAmount(resource));
 }