Game.Net.PedestrianLane
Assembly: Assembly-CSharp
Namespace: Game.Net
Type: public struct PedestrianLane : IComponentData, IQueryTypeParameter, ISerializable
Base: System.ValueType
Summary: Represents a pedestrian lane component used by the game's ECS. This struct stores an optional access-restriction Entity (used to control which agents can use the lane) and a set of flags describing lane properties (PedestrianLaneFlags). It implements ISerializable to allow reading/writing the component data for save/load or network transfer, and is usable as an ECS IComponentData and query parameter.
Fields
-
public Entity m_AccessRestriction
Holds an Entity reference to an access restriction object (when present). This is conditionally serialized/deserialized depending on the reader context version (see Deserialize). If the saved/network data is from a version before the access restriction feature was added, this field will remain default (Entity.Null) after deserialization. -
public PedestrianLaneFlags m_Flags
Bitflags describing lane properties (type, behavior modifiers, etc.). Serialized as a uint. Use the PedestrianLaneFlags enum to interpret these bits.
Properties
- None
This struct exposes only public fields. There are no computed properties.
Constructors
public PedestrianLane()
Implicit parameterless constructor (default struct initialization). Fields are default-initialized: m_AccessRestriction = default(Entity) and m_Flags = default(PedestrianLaneFlags). Use field assignment to initialize values.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the provided writer. The method writes m_AccessRestriction (Entity) followed by m_Flags cast to uint. This is used for saving or network serialization. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the provided reader. The method first checks reader.context.version against Version.pathfindAccessRestriction: if the version is new enough, it reads m_AccessRestriction; otherwise it leaves that field at its default value. It then reads a uint and casts it to PedestrianLaneFlags to populate m_Flags. This version check ensures compatibility with older data that lacks the access-restriction field.
Usage Example
// Add the component to an entity and initialize fields
Entity pedestrianLaneEntity = entityManager.CreateEntity();
PedestrianLane lane = default;
lane.m_AccessRestriction = someAccessRestrictionEntity; // or Entity.Null
lane.m_Flags = PedestrianLaneFlags.SomeFlag | PedestrianLaneFlags.AnotherFlag;
entityManager.AddComponentData(pedestrianLaneEntity, lane);
// Example: custom serialization usage (pseudo-code)
// writer/reader types come from the game's serialization system:
var laneComponent = entityManager.GetComponentData<PedestrianLane>(pedestrianLaneEntity);
writer.Write(laneComponent.m_AccessRestriction);
writer.Write((uint)laneComponent.m_Flags);
// During load:
// if (reader.context.version >= Version.pathfindAccessRestriction)
// reader.Read(out lane.m_AccessRestriction);
// reader.Read(out uint flags);
// lane.m_Flags = (PedestrianLaneFlags)flags;