Game.Buildings.ExtractorFacility
Assembly:
Assembly-CSharp
Namespace:
Game.Buildings
Type:
struct
Base:
IComponentData, IQueryTypeParameter, ISerializable
Summary:
Component data for an extractor facility building used by the game's ECS. Stores extractor-specific flags and a small timer byte. Implements custom binary serialization through ISerializable so instances can be written to and read from the game's entity serialization streams. Note that the m_MainBuildingFlags field is present on the struct but is not included in the Serialize/Deserialize implementation in this file.
Fields
-
public ExtractorFlags m_Flags
Holds extractor-specific flags (ExtractorFlags enum). This value is serialized as a single byte in Serialize and reconstructed in Deserialize. -
public byte m_Timer
A small timer/countdown value stored as a byte. Serialized as a single byte. Likely used to track extraction cycles, cooldowns, or tick-based behavior. -
public BuildingFlags m_MainBuildingFlags
Holds building-related flags (BuildingFlags enum). This field is declared in the struct but is not written to or read from the serialization stream in the provided Serialize/Deserialize methods.
Properties
- None.
Constructors
- implicit default constructor (public ExtractorFacility())
As a value type (struct), an implicit parameterless constructor exists and initializes fields to their default values (flags = 0, timer = 0). No explicit constructor is defined in the source.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component state to the provided writer. Implementation details:- Writes m_Flags cast to a byte.
- Writes m_Timer as a byte.
-
Note: m_MainBuildingFlags is not serialized by this method.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component state from the provided reader. Implementation details: - Reads a byte into a local value and assigns it to m_Flags after casting to ExtractorFlags.
- Reads the next byte directly into m_Timer (using a ref).
- Order of reads matches the order used in Serialize (flags then timer).
Usage Example
// Add the component to an entity using EntityManager (example)
var extractor = new ExtractorFacility
{
m_Flags = ExtractorFlags.None, // replace with appropriate flags
m_Timer = 0,
m_MainBuildingFlags = BuildingFlags.None
};
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = /* obtain or create the building entity */;
entityManager.AddComponentData(entity, extractor);
// The game serialization system calls Serialize/Deserialize via the ISerializable contract.
// If you need to manually serialize (rare), the methods are generic over IWriter/IReader:
TWriter writer = /* obtain a writer that implements IWriter */;
extractor.Serialize(writer);
// And to read back:
TReader reader = /* obtain a reader that implements IReader */;
ExtractorFacility loaded = default;
loaded.Deserialize(reader);