Game.Prefabs.MoveableBridgeData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents component data for a movable bridge prefab. Stores the local lift offset vector(s) and the duration (in seconds) it takes for the bridge to move. This struct is an ECS component (Unity.Entities) and implements Colossal.Serialization.Interfaces to support custom serialization used by the game's save/load system. It uses Unity.Mathematics.float3 for 3D offsets.
Fields
-
public Unity.Mathematics.float3 m_LiftOffsets
Holds the lift offset (x, y, z) used by the bridge animation/positioning. Typically represents how much parts of the bridge move when raised. -
public System.Single m_MovingTime
Duration in seconds that the bridge takes to complete its movement (lift/lower). Stored as a single-precision float.
Properties
- None. This type exposes its data via public fields, not properties.
Constructors
public MoveableBridgeData()
Implicit default (parameterless) constructor provided by the C# compiler for structs. Initializes numeric fields to 0 (m_LiftOffsets = float3.zero, m_MovingTime = 0f). You can also initialize the fields directly using an object initializer.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component's data to the provided writer in the same order used for deserialization. Specifically: writes m_LiftOffsets (float3) then m_MovingTime (float). Used by the game's serialization pipeline to persist the component. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component's data from the provided reader in the same order as Serialize. Reads into the fields m_LiftOffsets and m_MovingTime via ref locals. This method reconstructs the component state when loading from saved data.
Usage Example
// Create and add the component to an entity (requires Unity.Entities EntityManager)
var bridgeData = new MoveableBridgeData {
m_LiftOffsets = new float3(0f, 6.5f, 0f),
m_MovingTime = 3.2f
};
entityManager.AddComponentData(bridgeEntity, bridgeData);
// Or serialize the component using the game's IWriter implementation
IWriter writer = /* obtain writer from serialization context */;
bridgeData.Serialize(writer);
// During load, deserialization would be performed by the engine, but manually:
IReader reader = /* obtain reader from serialization context */;
var loaded = new MoveableBridgeData();
loaded.Deserialize(reader);
entityManager.AddComponentData(bridgeEntity, loaded);