Game.Buildings.Park
Assembly: Assembly-CSharp
Namespace: Game.Buildings
Type: struct
Base: System.ValueType
Summary: Represents a lightweight ECS component for park buildings used by the game's entity/component system. It stores the maintenance value for a park and implements ISerializable so it can be written to and read from the game's serialization streams. The struct is also an IComponentData (so it can be attached to entities) and IQueryTypeParameter (so it can be used in entity queries).
Fields
public short m_Maintenance
Stores the maintenance value for the park (16-bit signed integer). This value is written and read by the Serialize/Deserialize methods and typically represents the maintenance cost/level associated with the park entity. Default value (when not set) is 0.
Properties
- None
This struct exposes its data as public fields and does not declare any C# properties.
Constructors
public Park()
The default parameterless constructor is the implicit struct constructor provided by .NET. It initializes m_Maintenance to 0. You can initialize a value via an object initializer:new Park { m_Maintenance = 10 }
.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the m_Maintenance field to the provided writer. The writer is expected to implement the game's IWriter interface. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads a short value from the provided reader into m_Maintenance. The reader is expected to implement the game's IReader interface.
Notes: - Both methods are generic with constraints to the game's IWriter/IReader interfaces, matching the serialization system used by the engine/mod API. - Implementing ISerializable allows this component to be persisted as part of saved game data or other serialization flows.
Usage Example
// Create and set a Park component value
var parkComponent = new Game.Buildings.Park { m_Maintenance = 15 };
// Adding the component to an entity (EntityManager usage)
Entity someEntity = /* obtain or create entity */;
EntityManager entityManager = /* obtain EntityManager */;
entityManager.AddComponentData(someEntity, parkComponent);
// Example of serialization usage (pseudocode)
// Assume writer implements IWriter
// writer.Write is called internally by Serialize
parkComponent.Serialize(writer);
// Deserialization example (pseudocode)
// Game.Buildings.Park loadedPark;
// loadedPark.Deserialize(reader);