Game.Prefabs.WaterwayData
Assembly:
Part of the game's codebase (defined in the game's assemblies / mod DLLs where this file is compiled)
Namespace:
Game.Prefabs
Type:
struct WaterwayData
Base:
Implements:
- Unity.Entities.IComponentData
- Unity.Entities.IQueryTypeParameter
- Colossal.Serialization.Entities.ISerializable
Summary:
WaterwayData is a plain ECS component that stores a single floating value representing the speed limit for a waterway element (for example for boat traffic on a water segment). It is serializable via the game's Colossal.Serialization system so the value can be persisted and restored with the game's save/load or prefab serialization systems.
Fields
public float m_SpeedLimit
Holds the speed limit value for the waterway. Units follow the game's internal speed units (use the same units other traffic-related components use in the game). This field is serialized/deserialized by the Serialize/Deserialize implementations below.
Properties
- (none)
This struct exposes only a public field; there are no C# properties defined.
Constructors
public WaterwayData()
Default parameterless constructor (struct default). No custom constructor is defined in the source; instantiate using an object initializer, e.g.new WaterwayData { m_SpeedLimit = 5f }
.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component's data into the provided writer. The implementation writes the single float field: writer.Write(m_SpeedLimit);
This method integrates with the Colossal.Serialization system so the component can be saved as part of entity/prefab serialization.
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component's data from the provided reader and assigns it to m_SpeedLimit: reader.Read(out m_SpeedLimit);
This restores the component value when an entity/prefab is loaded.
Usage Example
using Unity.Entities;
using Game.Prefabs;
// Create or get EntityManager (example in a system or mod initialization)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
// Create an archetype that includes WaterwayData (or add to an existing entity)
var archetype = entityManager.CreateArchetype(typeof(WaterwayData));
var entity = entityManager.CreateEntity(archetype);
// Set the speed limit (game speed units)
entityManager.SetComponentData(entity, new WaterwayData { m_SpeedLimit = 5.0f });
// Serialization example (the writer instance is provided by the game's serialization pipeline):
// var writer = ObtainWriterFromGameSerializationSystem();
// var data = new WaterwayData { m_SpeedLimit = 5.0f };
// data.Serialize(writer);
Notes: - As an IComponentData, WaterwayData is intended to be used in DOTS systems (Unity.Entities) to drive water traffic logic. - The ISerializable implementation integrates with the game's custom serialization; avoid manually duplicating serialization behavior unless you are interacting with the same writer/reader interfaces used by the game.