Interface IResourceProvider
ENGINE: Interface for resource management systems.
Allows GAME layer to provide custom implementations (e.g., modded resources, different storage strategies, or resource calculation overrides).
Default implementation: ResourceSystem
public interface IResourceProvider
Properties
IsBatchMode
Whether currently in batch mode
bool IsBatchMode { get; }
Property Value
- bool
IsInitialized
Whether the provider is initialized and ready for operations
bool IsInitialized { get; }
Property Value
- bool
MaxCountries
Maximum number of countries supported
int MaxCountries { get; }
Property Value
- int
ResourceCount
Number of registered resource types
int ResourceCount { get; }
Property Value
- int
Methods
AddResource(ushort, ushort, FixedPoint64)
Add resource to a country (clamped to max)
void AddResource(ushort countryId, ushort resourceId, FixedPoint64 amount)
Parameters
countryIdushortresourceIdushortamountFixedPoint64
AddResourceToAll(ushort, FixedPoint64)
Add resource to all countries
void AddResourceToAll(ushort resourceId, FixedPoint64 amount)
Parameters
resourceIdushortamountFixedPoint64
BeginBatch()
Begin batch mode - suppresses events until EndBatch is called. Use during loading/setup to avoid thousands of individual events.
void BeginBatch()
CanAfford(ushort, ResourceCost[])
Check if country can afford multiple costs
bool CanAfford(ushort countryId, ResourceCost[] costs)
Parameters
countryIdushortcostsResourceCost[]
Returns
- bool
CanAfford(ushort, ushort, FixedPoint64)
Check if country can afford a single cost
bool CanAfford(ushort countryId, ushort resourceId, FixedPoint64 amount)
Parameters
countryIdushortresourceIdushortamountFixedPoint64
Returns
- bool
EndBatch()
End batch mode - optionally emits a single batch event.
void EndBatch()
GetAllResourceIds()
Get all registered resource IDs
IEnumerable<ushort> GetAllResourceIds()
Returns
- IEnumerable<ushort>
GetAllResourcesForCountry(ushort)
Get all resources for a country as dictionary (for UI/debugging)
Dictionary<ushort, FixedPoint64> GetAllResourcesForCountry(ushort countryId)
Parameters
countryIdushort
Returns
- Dictionary<ushort, FixedPoint64>
GetResource(ushort, ushort)
Get current resource amount for a country
FixedPoint64 GetResource(ushort countryId, ushort resourceId)
Parameters
countryIdushortresourceIdushort
Returns
GetResourceDefinition(ushort)
Get resource definition by ID
ResourceDefinition GetResourceDefinition(ushort resourceId)
Parameters
resourceIdushort
Returns
GetTotalResourceInWorld(ushort)
Get total amount of a resource across all countries
FixedPoint64 GetTotalResourceInWorld(ushort resourceId)
Parameters
resourceIdushort
Returns
IsResourceRegistered(ushort)
Check if a resource type is registered
bool IsResourceRegistered(ushort resourceId)
Parameters
resourceIdushort
Returns
- bool
RemoveResource(ushort, ushort, FixedPoint64)
Remove resource from a country (returns false if insufficient)
bool RemoveResource(ushort countryId, ushort resourceId, FixedPoint64 amount)
Parameters
countryIdushortresourceIdushortamountFixedPoint64
Returns
- bool
SetResource(ushort, ushort, FixedPoint64)
Set resource to exact amount (clamped to valid range)
void SetResource(ushort countryId, ushort resourceId, FixedPoint64 amount)
Parameters
countryIdushortresourceIdushortamountFixedPoint64
SetResourceForAll(ushort, FixedPoint64)
Set resource for all countries
void SetResourceForAll(ushort resourceId, FixedPoint64 amount)
Parameters
resourceIdushortamountFixedPoint64
TransferResource(ushort, ushort, ushort, FixedPoint64)
Transfer resource between countries (returns false if insufficient)
bool TransferResource(ushort fromCountryId, ushort toCountryId, ushort resourceId, FixedPoint64 amount)
Parameters
fromCountryIdushorttoCountryIdushortresourceIdushortamountFixedPoint64
Returns
- bool
TrySpend(ushort, ResourceCost[])
Try to spend multiple costs atomically (all or nothing)
bool TrySpend(ushort countryId, ResourceCost[] costs)
Parameters
countryIdushortcostsResourceCost[]
Returns
- bool