Resource
Key Features
Manages Player Resources: Tracks, updates, and modifies resource quantities for player-controlled entities.
Supports Multiple Resource Types: Works with
ResourceSOto define different resources like food, wood, gold, etc.Resource Calculation: Uses
ResourceQuantityto compute costs and manage transactions efficiently.Automatic or Manual Resource Updates: Can handle real-time updates or allow manual adjustments for turn-based systems.
Integration with Other Modules: Works alongside
ProductionModuleto ensure resource availability for unit production.
Structure
Resource Module β Manages resources, including adding, removing, and checking availability.
ResourceSO β Defines resource types as ScriptableObjects, allowing flexible creation of new resources.
ResourceQuantity β Represents specific amounts of resources and handles cost calculations.
Resource Events β Provides global events for UI updates and resource-related triggers.
Usage Examples
Adding Resources Manually
ResourceModule resourceModule = player.GetModule<ResourceModule>();
ResourceSO goldResource = ... // Reference to the gold resource scriptable object
resourceModule.AddResource(goldResource, 500); // Adds 500 gold to the playerChecking Resource Availability
Deducting Resources for Production
Last updated