Game.Prefabs.ExtractorAreaData
Assembly:
Assembly-CSharp (typical for Cities: Skylines 2 mods)
Namespace:
Game.Prefabs
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
ExtractorAreaData is a lightweight ECS component/serializable struct used to describe configuration for an "extractor" area prefab (resource extraction areas) in the game. It records which MapFeature the extractor uses and a number of tuning parameters (spawn factors, area limits, work amount factor). Note: only a subset of fields (m_MapFeature and m_RequireNaturalResource) are persisted by the provided Serialize/Deserialize implementations; the other floats appear to be runtime/config values not written to the writer.
Fields
-
public MapFeature m_MapFeature
MapFeature enum (from Game.Areas) indicating the type of map feature/resource this extractor targets (e.g., ore, oil, etc.). When serialized this value is cast to an sbyte. -
public float m_ObjectSpawnFactor
Multiplier controlling how many objects (visuals or resources) are spawned in the extractor area. Not serialized by the provided Serialize method. -
public float m_MaxObjectArea
Maximum area used for spawning objects in the extractor area. Not serialized. -
public bool m_RequireNaturalResource
If true, the extractor requires a natural resource present on the map to be placed/activated. This boolean is serialized and deserialized. -
public float m_WorkAmountFactor
Multiplier affecting the work/production amount of the extractor. Not serialized.
Properties
public Unity.Jobs.JobHandle producerHandle { get; private set }
No such property exists on this struct. (Template property omitted — there are no properties defined in ExtractorAreaData.)
Constructors
public ExtractorAreaData()
No explicit constructor is defined in the source; the default parameterless struct constructor is used. Initialize fields directly with object initializer syntax or assign after creation.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the serialized representation to the provided writer. Implementation details:- Casts m_MapFeature to sbyte and writes that value.
- Writes m_RequireNaturalResource as a boolean.
-
NOTE: m_ObjectSpawnFactor, m_MaxObjectArea, and m_WorkAmountFactor are not written.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads data from the provided reader to populate the struct. Implementation details: - Reads an sbyte and assigns it to m_MapFeature (cast back to MapFeature).
- Reads a boolean directly into m_RequireNaturalResource.
- The non-serialized float fields remain unchanged (default or previously assigned values).
Usage Example
// Prepare the data instance (set all runtime/config values as needed)
var extractor = new ExtractorAreaData
{
m_MapFeature = MapFeature.Ore,
m_ObjectSpawnFactor = 1.25f,
m_MaxObjectArea = 120f,
m_RequireNaturalResource = true,
m_WorkAmountFactor = 0.9f
};
// Serialize to some writer (IWriter implementation provided by the engine)
// Only m_MapFeature and m_RequireNaturalResource will be written.
extractor.Serialize(writer);
// Later / elsewhere: deserialize from a reader
var loadedExtractor = new ExtractorAreaData();
loadedExtractor.Deserialize(reader);
// loadedExtractor.m_MapFeature and loadedExtractor.m_RequireNaturalResource are restored.
// Other floats will need to be set by code or left at their defaults.
Additional notes: - MapFeature enum lives in the Game.Areas namespace; ensure you use the same enum values when creating/reading data. - The code uses an explicit cast to sbyte for compact storage of the enum; if MapFeature gains values outside the sbyte range you must update serialization accordingly. - The Deserialize implementation reads the MapFeature first, then the boolean — matching the Serialize ordering is required for correct round-trip.