Update 2.2.0
- Fixed: $1 coins should now work as expected outside of the newly added coin slots. - Added: Currency symbols are now also applied to price tags where the price has never been set. - Added: Currency Value Factor is now applied to Bank Loans. - Added: Currency Value Factor is now applied to Store Sections. - Added: Currency Value Factor is now applied to Storage Sections. - Added: Currency Value Factor is now applied to Furniture Prices. - Added: Currency Value Factor is now applied to the amount of money a new save game starts with. - Added: Currency Value Factor is now applied to Restocker hiring & daily cost. - Added: Currency Value Factor is now applied to Cashier hiring & daily cost. - Added: Price Rounding, for when a currency doesn't support certain low denominations. You can now configure product prices as well as customer payments to not make you use 1 cent coins, or even coins below $1, if you wish. - The new feature above has been preconfigured to 5 cents in the config file for the canadian dollar, making that currency's penny obsolete. - Preconfigured config files have been updated to reflect changes made in this version.
This commit is contained in:
parent
0afdc1d02f
commit
6e2d2fac98
17 changed files with 324 additions and 4 deletions
30
PriceRounder.cs
Normal file
30
PriceRounder.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using BepInEx.Configuration;
|
||||
using System;
|
||||
|
||||
namespace CurrencyChanger2
|
||||
{
|
||||
public class PriceRounder
|
||||
{
|
||||
public enum RoundingModeType { ROUND_UP, ROUND_DOWN, AUTOMATIC }
|
||||
public ConfigEntry<float> RoundingPoint { get;set; }
|
||||
public ConfigEntry<RoundingModeType> RoundingMode { get;set; }
|
||||
public PriceRounder(ConfigFile Config)
|
||||
{
|
||||
RoundingPoint = Config.Bind("Price Rounding", "Rounding Point", 0.01f, "Does your currency not have denominations for some small values?\nAdjust this to define the smallest possible denomination, and have all prices adjust to that.");
|
||||
RoundingMode = Config.Bind("Price Rounding", "Rounding Mode", RoundingModeType.AUTOMATIC, "What should happen if a price does not match the indicated rounding point?");
|
||||
}
|
||||
public float Round(float price)
|
||||
{
|
||||
float value = price / RoundingPoint.Value;
|
||||
switch(RoundingMode.Value)
|
||||
{
|
||||
default:
|
||||
case RoundingModeType.AUTOMATIC: value = (float)Math.Round(value); break;
|
||||
case RoundingModeType.ROUND_UP: value = (float)Math.Ceiling(value); break;
|
||||
case RoundingModeType.ROUND_DOWN: value = (float)Math.Floor(value); break;
|
||||
}
|
||||
value *= RoundingPoint.Value;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue