Buying fuel
FuelBought tells your mod when the player has paid for fuel at a station.
FuelStations fuel purchase event
FuelBought is the event on this class. FuelStations.All() lists the stations, and it is covered on the gas stations page.
public static class FuelStations
{
public static event Action<FuelBoughtArgs> FuelBought;
}
| Event | Gives you | When it fires |
|---|---|---|
FuelBought | FuelBoughtArgs | The player has paid for fuel. |
FuelBoughtArgs what FuelBought tells you
FuelBought gives you this. The framework builds it from a hook on the game’s GasStation.PayFuelOc payment, so it is the framework’s own type.
public sealed class FuelBoughtArgs
{
public string StationId { get; }
public float Amount { get; }
public int Cost { get; }
public MoneyCurrency Currency { get; }
}
| Property | Type | What it means |
|---|---|---|
StationId | string | The station, the same as FuelStationInfo.Id. |
Amount | float | How many units of fuel were paid for, over all pumps. |
Cost | int | The money paid. |
Currency | MoneyCurrency | The money the cost is in. OC for now. |
Things to know
FuelBoughtfires when a payment goes through. If the player cannot afford the bill, nothing is paid and the event does not fire. (It fires afterGasStation.PayFuelOcwhen the game’spriceToPayOcwent from above zero back to zero.)Currencyis always OC for now. The game only pays this kind of bill in OC (Open Sewer Coins, see the glossary).Amountis the fuel the payment covers. The framework reads it before the game empties the pumps. (It isFuelPump.filledAmount, added up over the station’s pumps.)- The money side of the same payment is
Cash.MoneyChanged. See Economy.FuelBoughttells you what the money was spent on. - The event fires for every way the game starts a payment. The game calls the payment method from scene or dialogue wiring, not from its code, and the framework changes the method itself so every caller is covered. (
PayFuelOchas no C# caller in the game code.)
Limits
CostandAmountcan disagree when the player filled more than one pump.Costis the bill the game holds, and the game overwrites that bill each time it changes instead of adding to it. SoCostis the last pump’s bill, whileAmountadds up every pump. This is how the game counts, and the framework does not fix it. (CostispriceToPayOc, andGasStation.UpdatePriceToPayOcoverwrites it.)- The framework does not hold the event back while a save loads. A handler that should ignore events raised then can check
SaveData.Busy, which istruewhile a save is loading or being written.