Skip to main content

ChunkBasedEnvironment

A class in Root.Township, the global namespace.

Client: switches the player's environment to the EnvironmentNode of the location chunk they walk into.

Constructors​

MemberWhat it is
ChunkBasedEnvironment()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private LocationChunk chunkLocation chunk found for the latest position.
private EnvironmentHandler environmentAssesserThe EnvironmentHandler on this object.
private LocomotionController locomotionLocomotion controller whose moves are watched.
private LocationChunk oldChunkLocation chunk the player was last in.

Methods​

2 private and internal methods
MemberWhat it is
private void PositionChanged(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)On each move, finds the best location chunk for the new position and, if it changed, sets its environment without snapping.
private void Start()Gets the EnvironmentHandler and hooks the locomotion position event.