Game.Tools.ILoanSystem
Assembly:
(assembly not specified in the provided source)
Namespace: Game.Tools
Type: interface
Base: none (interface)
Summary:
Interface that exposes basic loan-related operations used by the game. It provides access to the currently active loan information, a creditworthiness indicator, and methods to request a loan offer and change the current loan. The concrete LoanInfo type is not included in this snippet and represents the loan details (amount, interest, term, etc.).
Fields
- None.
This is an interface and declares no fields.
Properties
-
LoanInfo CurrentLoan { get; }
Read-only property returning the current loan details. The exact structure of LoanInfo is not provided in this file; it typically contains information such as principal amount, interest rate, term, and outstanding balance. -
int Creditworthiness { get; }
Read-only integer representing the creditworthiness of the borrower (city/player). Higher values likely indicate better ability to obtain favorable loan terms; exact scale and semantics are defined by the game's finance system.
Constructors
- None.
Interfaces do not declare constructors.
Methods
-
LoanInfo RequestLoanOffer(int amount)
Request an offer for a loan of the specified amount. The method returns a LoanInfo structure describing the proposed loan terms for the requested amount. If a loan cannot be offered for the amount (e.g., amount too large or creditworthiness too low), the method's behavior is dependent on the implementation—it may return a LoanInfo indicating failure, a LoanInfo with zeroed/invalid fields, or throw/return null if the API allows it. Check the concrete implementation or broader game API for exact behavior. -
void ChangeLoan(int amount)
Change the current loan by the specified amount. The semantics (e.g., whether positive amounts take out additional debt, negative amounts repay debt, or the method sets the loan to an absolute value) are implementation-specific; consult the game's API or the implementation you are interacting with when modding.
Usage Example
// Example implementation for modding/testing purposes.
// The real game defines LoanInfo; here we provide a minimal placeholder.
public struct LoanInfo
{
public int Amount;
public float InterestRate;
public int TermMonths;
public float MonthlyPayment;
}
public class SimpleLoanSystem : Game.Tools.ILoanSystem
{
public LoanInfo CurrentLoan { get; private set; }
public int Creditworthiness { get; private set; }
public SimpleLoanSystem(int initialCreditworthiness)
{
Creditworthiness = initialCreditworthiness;
CurrentLoan = new LoanInfo { Amount = 0, InterestRate = 0f, TermMonths = 0, MonthlyPayment = 0f };
}
public LoanInfo RequestLoanOffer(int amount)
{
// Simple example logic: if creditworthiness is too low, deny by returning zeroed LoanInfo.
if (Creditworthiness < 20 || amount <= 0)
return new LoanInfo();
// Example: fixed interest and term depending on creditworthiness
float interest = Math.Max(0.05f, 0.2f - (Creditworthiness / 200f));
int term = 60; // months
float monthly = (amount * (1 + interest)) / term;
return new LoanInfo
{
Amount = amount,
InterestRate = interest,
TermMonths = term,
MonthlyPayment = monthly
};
}
public void ChangeLoan(int amount)
{
// Example: positive amount increases loan, negative repays principal
CurrentLoan.Amount += amount;
// In a real implementation you'd recalculate payments, validate limits, and update game state
}
}
Notes for modders: - The interface itself is small and intended to be implemented by the game's finance/loan subsystem. When interacting with the real game, use the game's concrete implementation rather than rolling your own unless you are intentionally replacing or mocking the system. - Validate how the game's LoanInfo type is structured and what values indicate failure or special cases. - Be careful with threading and game simulation timing when requesting or changing loans — make such calls on appropriate game/main thread callbacks or via the game's sanctioned APIs.