Game.Prefabs.ResourceConsumptionItem
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: System.Object
Summary:
A small serializable data container used by prefabs/editors to describe a resource consumption entry for a building or object. It pairs a ResourceStackInEditor (the resource type and amount) with a flag that controls whether the value should be scaled by the building's current usage/throughput. This class contains no runtime logic — it is intended for data storage and (de)serialization in prefab definitions and editor tools.
Fields
-
public ResourceStackInEditor m_Consumption
Holds the resource type and the base amount consumed. ResourceStackInEditor is an editor-side structure representing a single resource entry (for example: resource id/type and quantity). This field is the primary data for what resource is consumed and how much. -
public bool m_ScaleWithUsage
When true, the consumption amount described by m_Consumption should be scaled by the building's current usage/throughput (for example, partial occupancy or production rate). When false, the consumption is treated as a fixed value regardless of usage.
Properties
- This class declares no properties. It exposes plain public fields for simple serialization and editor manipulation.
Constructors
public ResourceConsumptionItem()
The default parameterless constructor is compiler-provided. As a simple data container marked [Serializable], instances are typically created and populated by the editor or prefab serialization system.
Methods
- This class defines no methods. It is a pure data holder.
Usage Example
// Example: create and populate a ResourceConsumptionItem for prefab/editor code.
// Note: ResourceStackInEditor shape is project-specific — set its fields as appropriate.
var stack = new ResourceStackInEditor();
// set resource identifier and amount on ResourceStackInEditor:
// e.g. stack.resourceId = "Electricity"; stack.amount = 10f;
var consumptionItem = new ResourceConsumptionItem
{
m_Consumption = stack,
m_ScaleWithUsage = true // consumption scales with building usage
};
// consumptionItem can now be assigned into a prefab/resource-consumption list and serialized by the editor.