Events & Interaction

advanced scripting

World Map Strategy Kit · Scripting Support (C#)

Class: WMSK (namespace WorldMapStrategyKit)

Events

WMSK provides comprehensive event coverage for all interactive elements.

Properties

enum UNIT_SELECTION_MODE

Gets or sets the u n i t_ s e l e c t i o n_ m o d e.

float navigationTime

Gets or sets the navigation time.

bool isFlying

Returns whether a navigation is taking place at this moment.

bool allowInteractionWhileFlying

Gets / sets flag to allow user interaction with map during a FlyTo operation

float staticInteractionVelocityThreshold

Gets / sets the maximum velocity for the map or camera to consider it static

bool fitWindowWidth

Ensure the map is always visible and occupy the entire Window.

bool fitWindowHeight

Ensure the map is always visible and occupy the entire Window.

Vector2 flyToScreenCenter

Sets the position of the screen used by the FlyTo() operations

bool wrapHorizontally

Allows to scroll around horizontal edges.

Rect windowRect

The 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 allowUserKeys

If user can use WASD keys to drag the map.

float dragKeySpeedMultiplier

Gets or sets the drag key speed multiplier.

string keyUpName

Keyboard mapping for up shift.

string keyDownName

Keyboard mapping for down shift.

string keyLeftName

Keyboard mapping for left shift.

string keyRightName

Keyboard mapping for right shift.

bool dragFlipDirection

Whether the direction of the drag should be inverted.

bool dragConstantSpeed

Whether the drag should follow a constant movement, withouth acceleration.

float dragDampingDuration

Gets or sets the drag damping duration.

bool allowUserDrag

Gets or sets the allow user drag.

bool allowScrollOnScreenEdges

Gets or sets the allow scroll on screen edges.

int screenEdgeThickness

Gets or sets the screen edge thickness.

bool centerOnRightClick

Gets or sets the center on right click.

LayerMask blockingMask

Layer mask to determine which UI elements can block the interaction

bool allowUserZoom

Gets or sets the allow user zoom.

float zoomMaxDistance

Gets or sets the zoom max distance.

float zoomMinDistance

Gets or sets the zoom min distance.

bool invertZoomDirection

Gets or sets the invert zoom direction.

float zoomDampingDuration

Gets or sets the zoom damping duration.

bool respectOtherUI

When enabled, will prevent interaction with the map if pointer is over an UI element

bool enableFreeCamera

Allow camera to be freely moved/rotated when in terrain mode

float mouseWheelSensitivity

Gets or sets the mouse wheel sensitivity.

float mouseDragSensitivity

Gets or sets the mouse drag sensitivity.

float mouseDragThreshold

Gets or sets the mouse drag threshold.

bool enableCameraTilt

Tilts camera depending on zoom

float cameraNearTiltAngle

Minimum tilt for camera

float cameraFarTiltAngle

Minimum tilt for camera

float cameraTiltSmoothing

Smoothing for camera tilt movement

bool fitViewportToScreen

Ensures viewport fills the screen

float minCameraDistanceToViewport

The minimum distance of the camera to the viewport

bool enableCameraOrbit

Allow rotation of camera around target point when in tilted mode

float orbitMaxZoomLevel

Maximum zoom level allowed for orbiting

float orbitYawAngle

Default yaw angle

string orbitLeftKeyName

Key used to orbit counter-clockwise

string orbitRightKeyName

Key used to orbit clockwise

float orbitRotationSpeed

Gets or sets the orbit rotation speed.

float orbitRotationDamping

Gets or sets the orbit rotation damping.

bool orbitKeepZoomDistance

Keeps 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 hexProportion

Called 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.

Was this page helpful?