Skip to content

Game.Tools.LoanInfo

Assembly: Assembly-CSharp (game runtime assembly)
Namespace: Game.Tools

Type: public struct LoanInfo : System.IEquatable

Base: System.ValueType

Summary:
LoanInfo is a simple value-type container used by the game's finance/loan systems to hold basic loan parameters: total amount, per-day interest rate, and the daily payment amount. It implements IEquatable with a field-by-field equality check. The struct is mutable (public fields) and has only the implicit default constructor.


Fields

  • public int m_Amount
    Total loan principal expressed in the game's integer currency units. This value is compared directly in the Equals implementation.

  • public float m_DailyInterestRate
    Daily interest rate applied to the loan as a single-precision float (e.g., 0.01f for 1% per day). Equality is tested using float.Equals, so be aware of floating-point precision issues when comparing rates.

  • public int m_DailyPayment
    Scheduled daily payment amount expressed in the game's integer currency units. Compared directly in Equals.

Properties

  • This struct does not declare any properties.

Constructors

  • public LoanInfo()
    The implicit default parameterless constructor provided for value types. All fields default to 0 (m_Amount = 0, m_DailyInterestRate = 0f, m_DailyPayment = 0). You can also create instances by initializing fields directly.

Methods

  • public bool Equals(LoanInfo other)
    Implements IEquatable. Returns true when m_Amount equals other.m_Amount, m_DailyInterestRate.Equals(other.m_DailyInterestRate) is true, and m_DailyPayment equals other.m_DailyPayment. Note that only this strongly-typed Equals is implemented; Equals(object) and GetHashCode are not overridden in this struct. If instances will be used as keys in hash-based collections (Dictionary, HashSet), implement GetHashCode and/or Equals(object) to ensure correct behavior.

Additional notes: - Because m_DailyInterestRate is a float and compared via float.Equals, consider potential precision issues. If logical equality requires tolerance, use an epsilon-style comparison or store rates in an integer/fixed-point form. - The fields are public and mutable; modify with care if instances are shared.

Usage Example

// Create two loan infos
LoanInfo loanA = new LoanInfo
{
    m_Amount = 100000,             // e.g., 100,000 currency units
    m_DailyInterestRate = 0.005f,  // 0.5% per day
    m_DailyPayment = 2000
};

LoanInfo loanB = new LoanInfo
{
    m_Amount = 100000,
    m_DailyInterestRate = 0.005f,
    m_DailyPayment = 2000
};

// Compare using IEquatable implementation
bool equal = loanA.Equals(loanB); // true

// If floating-point tolerance is needed:
bool rateEqual = Math.Abs(loanA.m_DailyInterestRate - loanB.m_DailyInterestRate) < 1e-6f;
bool logicallyEqual = loanA.m_Amount == loanB.m_Amount && rateEqual && loanA.m_DailyPayment == loanB.m_DailyPayment;