Click or drag to resize
GeneralRulesSwitchToMap Method
Sets a different map as the one to be drawn on the game display.

Namespace: (Default Namespace)
Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax
C#
public virtual void SwitchToMap(
	Type MapType,
	bool UnloadCurrent
)

Parameters

MapType
Type: SystemType
Specifies the map to switch to.
UnloadCurrent
Type: SystemBoolean
If true, the current map will be unloaded first
Remarks

MapType specifies a type of map rather than a specific instance of a map. This accomplishes two things. First, it allows the function to switch to a map that hasn't been initialized/created yet, thus allowing the map instance to only be created when necessary, and not before switching to it. This can improve performance because an instance of each map doesn't have to be created during game initialization. Secondly, it allows maps to be unloaded so that maps instances that don't need to remember their state can be released, freeing up whatever memory they were occupying. Each map defined in the IDE is compiled/generated as its own class when the project is compiled, and each map instance becomes an instance of the class. This conceivably allows multiple instances of the same map to exist, but this is not fully supported by default in the code provided with this environment.

When UnloadCurrent is true, the old map will be unloaded while switching to the new map, freeing up the memory used by the old map's sprites and tiles (if no other references to the map exist). Eliminating the map from memory also reduces the amount of data that would be written to a saved game file. Finally it causes the map to be recreated/reset when returning to it in the future. When UnloadCurrent is false, the map is retained and re-used next time the game switches to the map, which means the state of all the tiles and sprites will be remembered as they were when switching away from the map.

See Also