WorldSyncedToChangedEventArgs Class

public sealed class WorldSyncedToChangedEventArgs : EventArgs

Event Args for a WorldSyncedToChanged event (an event of the Active Grid class).

This is fired when the Active Grid is first initialized and syncs to a World, or when you manually change the World via the API. In addition to containing references to the old and new World, it also contains the starting world cells for the player, for each layer on the new world. Using this in conjuction with the CellPlayerIsInChanged event will allow you to fully track which cell the player is in for one or all layers.

Please note, any reference values stored in this event are immedidately nulled out after all listeners have been notified of the event, therefore, if you wish to reference the objects after your listener method has been called, you will need to save a reference to the object(s) yourself.

Properties

Name Type Description
GridLayersOnNewWorld int

Gets the number of World Groupings on the new world that is being synced to.

NewWorld World

Gets the new World that the Active Grid is now synced to. If this is null, you should not try to use the GetWorldCellPlayerIsStartingIn and GetEndlessGridCellPlayerIsStartingIn methods, as they will not be set.

OldWorld World

Gets the old World that the Active Grid was synced to.

Methods

GetEndlessGridCellPlayerIsStartingIn(int)

public Cell GetEndlessGridCellPlayerIsStartingIn(int grouping)

Gets the Endless Grid Cell within the specified World Grouping that the player is starting in on the new world being synced to. Note, the method will throw an exception if you input an invalid World Grouping (less than or equal to 0 or a value greater than the number of World Groupings present on the new world).

You might be wondering why this method is here, when the World Cell contains this information. The reason is, in some instances the World Cell may be null (for instance, if the cell the player is in is a cell that is not present in the Streamable Grid). In these cases, you can use the Endless Grid Cell to query the World in order to find out pertinent information, such as the bounds of the cell.

Only use this method when NewWorld is not null, as otherwise the values will either be invalid or the method will throw an exception.

Parameters

Name Type Description
grouping int

The World Grouping you care about. Note, the base world layer is layer 1 always, and is usually what you'll care about.

Returns

Cell
The Endless Grid Cell cell that the player is in. From this, you can query the World to find out more information about the cell.


GetWorldCellPlayerIsStartingIn(int)

public WorldCell GetWorldCellPlayerIsStartingIn(int grouping)

Gets the World Cell within the specified World Grouping that the player is starting in on the new world being synced to. Note, the method will throw an exception if you input an invalid World Grouping (less than or equal to 0 or a value greater than the number of World Groupings present on the new world).

Only use this method when NewWorld is not null, as otherwise the values will either be invalid or the method will throw an exception.

Parameters

Name Type Description
grouping int

The World Grouping you care about. Note, the base world layer is layer 1 always, and is usually what you'll care about.

Returns

WorldCell
The World Cell that the player is in. From this, you can retrieve a lot of useful information, however note that in some instances, the World Cell may not be available when this event fires, for instance at the start of the game when first loading your World. Therefore, you should always check to make sure the returned WorldCell object is not null before accessing it. If it is null, you will need to retrieve the information you care about using the Endless Grid Cell the player is in and the NewWorld object.