Events & Interaction
advanced scriptingWorld Map Strategy Kit · Scripting Support (C#)
WMSK (namespace WorldMapStrategyKit)
Events
WMSK provides comprehensive event coverage for all interactive elements.
Properties
enum UNIT_SELECTION_MODEGets or sets the u n i t_ s e l e c t i o n_ m o d e.
float navigationTimeGets or sets the navigation time.
bool isFlyingReturns whether a navigation is taking place at this moment.
bool allowInteractionWhileFlyingGets / sets flag to allow user interaction with map during a FlyTo operation
float staticInteractionVelocityThresholdGets / sets the maximum velocity for the map or camera to consider it static
bool fitWindowWidthEnsure the map is always visible and occupy the entire Window.
bool fitWindowHeightEnsure the map is always visible and occupy the entire Window.
Vector2 flyToScreenCenterSets the position of the screen used by the FlyTo() operations
bool wrapHorizontallyAllows to scroll around horizontal edges.
Rect windowRectThe playable area. By default it's a Rect(-0.5, -0.5, 1f, 1f) where x,y are the -0.5, -0.5 is the left/bottom corner, and 1,1 is the width/height. Use renderViewportRect to get the current map viewable area in the window.
bool allowUserKeysIf user can use WASD keys to drag the map.
float dragKeySpeedMultiplierGets or sets the drag key speed multiplier.
string keyUpNameKeyboard mapping for up shift.
string keyDownNameKeyboard mapping for down shift.
string keyLeftNameKeyboard mapping for left shift.
string keyRightNameKeyboard mapping for right shift.
bool dragFlipDirectionWhether the direction of the drag should be inverted.
bool dragConstantSpeedWhether the drag should follow a constant movement, withouth acceleration.
float dragDampingDurationGets or sets the drag damping duration.
bool allowUserDragGets or sets the allow user drag.
bool allowScrollOnScreenEdgesGets or sets the allow scroll on screen edges.
int screenEdgeThicknessGets or sets the screen edge thickness.
bool centerOnRightClickGets or sets the center on right click.
LayerMask blockingMaskLayer mask to determine which UI elements can block the interaction
bool allowUserZoomGets or sets the allow user zoom.
float zoomMaxDistanceGets or sets the zoom max distance.
float zoomMinDistanceGets or sets the zoom min distance.
bool invertZoomDirectionGets or sets the invert zoom direction.
float zoomDampingDurationGets or sets the zoom damping duration.
bool respectOtherUIWhen enabled, will prevent interaction with the map if pointer is over an UI element
bool enableFreeCameraAllow camera to be freely moved/rotated when in terrain mode
float mouseWheelSensitivityGets or sets the mouse wheel sensitivity.
float mouseDragSensitivityGets or sets the mouse drag sensitivity.
float mouseDragThresholdGets or sets the mouse drag threshold.
bool enableCameraTiltTilts camera depending on zoom
float cameraNearTiltAngleMinimum tilt for camera
float cameraFarTiltAngleMinimum tilt for camera
float cameraTiltSmoothingSmoothing for camera tilt movement
bool fitViewportToScreenEnsures viewport fills the screen
float minCameraDistanceToViewportThe minimum distance of the camera to the viewport
bool enableCameraOrbitAllow rotation of camera around target point when in tilted mode
float orbitMaxZoomLevelMaximum zoom level allowed for orbiting
float orbitYawAngleDefault yaw angle
string orbitLeftKeyNameKey used to orbit counter-clockwise
string orbitRightKeyNameKey used to orbit clockwise
float orbitRotationSpeedGets or sets the orbit rotation speed.
float orbitRotationDampingGets or sets the orbit rotation damping.
bool orbitKeepZoomDistanceKeeps current distance when rotating around target when fit viewport to screen is enabled. This prevents camera distance changes during rotation but can show borders of viewport at certain angles.
Country Events
event OnCountryEvent OnCountryEnter(int countryIndex, int regionIndex)Fired when the pointer enters a country. Delegate signature: void(int countryIndex, int regionIndex).
event OnCountryEvent OnCountryExit(int countryIndex, int regionIndex)Fired when the pointer exits a country. Delegate signature: void(int countryIndex, int regionIndex).
event OnCountryEvent OnCountryClick(int countryIndex, int regionIndex)Fired when a country is clicked. Delegate signature: void(int countryIndex, int regionIndex).
event OnCountryHighlightEvent OnCountryHighlight(int countryIndex, int regionIndex, ref bool allowHighlight)Fires before highlighting a country. Set allowHighlight = false in the delegate to cancel highlighting.
Province Events
event OnProvinceEvent OnProvinceEnter(int provinceIndex, int regionIndex)Fired when the pointer enters a province. Delegate signature: void(int provinceIndex, int regionIndex).
event OnProvinceEvent OnProvinceExit(int provinceIndex, int regionIndex)Fired when the pointer exits a province. Delegate signature: void(int provinceIndex, int regionIndex).
event OnProvinceEvent OnProvinceClick(int provinceIndex, int regionIndex)Fired when a province is clicked. Delegate signature: void(int provinceIndex, int regionIndex).
event OnProvinceHighlightEvent OnProvinceHighlight(int provinceIndex, int regionIndex, ref bool allowHighlight)Fires before highlighting a province. Set allowHighlight = false to cancel.
City Events
event OnCityEnter OnCityEnter(int cityIndex)Fired when the pointer enters a city. Delegate signature: void(int cityIndex).
event OnCityExit OnCityExit(int cityIndex)Fired when the pointer exits a city. Delegate signature: void(int cityIndex).
event OnCityClick OnCityClick(int cityIndex, int buttonIndex)Fired when a city is clicked. Delegate signature: void(int cityIndex).
Cell Events
event OnCellEvent OnCellEnter(int cellIndex)Fired when the pointer enters a grid cell. Delegate signature: void(int cellIndex).
event OnCellEvent OnCellExit(int cellIndex)Fired when the pointer exits a grid cell. Delegate signature: void(int cellIndex).
event OnCellEvent OnCellClick(int cellIndex)Fired when a cell is clicked. Delegate signature: void(int cellIndex).
HexProportion hexProportionCalled during grid generation. Return a value to control individual cell proportions.
Pathfinding Events
event OnPathFindingCrossPosition OnPathFindingCrossPosition(Vector2 position)Fired when the pathfinder crosses a position during route calculation.
event OnPathFindingCrossAdminEntity OnPathFindingCrossCountry(int entityIndex)Fired when the pathfinder crosses into a different country.
event OnPathFindingCrossAdminEntity OnPathFindingCrossProvince(int entityIndex)Fired when the pathfinder crosses into a different province.
event OnPathFindingCrossCell OnPathFindingCrossCell(int cellIndex)Fired when the pathfinder crosses a grid cell.
General Map Events
event OnMouseClick OnClick(float x, float y, int buttonIndex)Triggered when the map is clicked.
event OnMouseClick OnMouseDown(float x, float y, int buttonIndex)Triggered when the mouse button is pressed on the map.
event OnMouseClick OnMouseRelease(float x, float y, int buttonIndex)Triggered when the mouse button is released.
event OnMouseEvent OnMouseMove(float x, float y)Triggered when the mouse moves over the map.
event OnSimpleMapEvent OnDragStart()Triggered when a drag operation starts on the map.
event OnSimpleMapEvent OnDragEnd()Triggered when a drag operation ends.
event OnSimpleMapEvent OnFlyStart()Triggered when a fly-to animation starts.
event OnSimpleMapEvent OnFlyEnd()Triggered when a fly-to animation completes.
event OnRegionEvent OnRegionEnter(Region region)Triggered when the pointer enters a region (country or province).
event OnRegionEvent OnRegionExit(Region region)Triggered when the pointer exits a region.
event OnRegionClickEvent OnRegionClick(Region region, int buttonIndex)Triggered when a region is clicked.
Game Object Events
event GOEvent OnPointerEnter(GameObjectAnimator anim)Triggered when the pointer enters a game object (unit, marker, etc.).
event GOEvent OnPointerExit(GameObjectAnimator anim)Triggered when the pointer exits a game object.
event GOEvent OnPointerDown(GameObjectAnimator anim)Triggered when the pointer is pressed on a game object.
event GOEvent OnPointerUp(GameObjectAnimator anim)Triggered when the pointer is released on a game object.
event GOEvent OnPointerRightDown(GameObjectAnimator anim)Triggered when the right mouse button is pressed on a game object.
event GOEvent OnPointerRightUp(GameObjectAnimator anim)Triggered when the right mouse button is released on a game object.
event GOEvent OnMoveStart(GameObjectAnimator anim)Triggered when a game object starts moving along a path.
event GOEvent OnMove(GameObjectAnimator anim)Triggered each frame while a game object is moving.
event GOEvent OnMoveEnd(GameObjectAnimator anim)Triggered when a game object finishes moving along a path.
event GOEvent OnKilled(GameObjectAnimator anim)Triggered when a game object is destroyed or killed.
event GOEvent OnVisibleChange(GameObjectAnimator anim)Triggered when a game object's visibility changes.
Additional Methods
void CenterMap()Moves the map in front of the camera so it fits the viewport.
bool GetCurrentMapLocation(out Vector3 location, bool worldSpace)Returns the coordinates of the center of the map as it's shown on the screen
void SetZoomLevel(float zoomLevel, float duration)Sets the zoom level progressively Value from 0 to 1 (close zoom, fit to window zoom) Duratin of the transition
void SetZoomLevel(float zoomLevel)Sets the zoom level Value from 0 to 1
float GetZoomLevel()Gets the current zoom level (0..1)
void FlyToLocation(Vector2 destination)Starts navigation to target location in local 2D coordinates.
void FlyToLocation(Vector2 destination, float duration)Starts navigation to target location in local 2D coordinates.
void FlyToLocation(float x, float y)Starts navigation to target location in local 2D coordinates.
void FlyToLocation(float x, float y, float duration)Starts navigation to target location in local 2D coordinates.
void FlyToLocation(Vector2 destination, float duration, float zoomLevel)Starts navigation to target location in local 2D coordinates with target zoom level.
void FlyToLatLon(Vector2 latlon, float duration, float zoomLevel)Starts navigation to target lat/lon. Latitude (x) and Longitude (y).
void FlyToLatLon(float latitude, float longitude, float duration, float zoomLevel)Starts navigation to target lat/lon. Latitude. Longitude.
void FlyToCancel()Stops any navigation in progress
GameObject RectangleSelectionInitiate(OnRectangleSelection rectangleSelectionCallback, Color rectangleFillColor, Color rectangleColor, float lineWidth)Initiates a rectangle selection operation. The rectangle selection.
void RectangleSelectionCancel()Cancel any rectangle selection operation in progress
void IgnoreClickEvents(int numberOfFrames)Makes WMSK ignore any click event for a number of given frames (default = 1)
void PanMap(Vector2 direction)Pans the map in a given direction. A vector with direction and magnitude of the panning. Such as Vector3.up, Vector3.down, Vector3.left or Vector3.right.
void PanMap(Vector2 direction, float multiplier)Pans the map in a given direction. A vector with direction and magnitude of the panning. Such as Vector3.up, Vector3.down, Vector3.left or Vector3.right. A value to multiply the default pan speed. You can use the dragKeySpeedMultiplier property which is used by keyboard panning.
Suggest an improvement
Help us improve this documentation page.