Class ProvinceSelector
- Namespace
- Map.Interaction
- Assembly
- MapAssembly.dll
Handles province selection and world position to province ID conversion Extracted from MapGenerator to follow single responsibility principle Provides fast mouse-to-province lookup for interaction systems
Uses hit.textureCoord from MeshCollider for accurate UV-to-province mapping
public class ProvinceSelector : MonoBehaviour
- Inheritance
-
objectProvinceSelector
Properties
SelectionEnabled
Enable or disable province selection.
public bool SelectionEnabled { get; set; }
Property Value
- bool
Methods
GetHoveredProvince()
Get the currently hovered province ID
public ushort GetHoveredProvince()
Returns
- ushort
GetProvinceAtMousePosition(Camera)
Get province ID at mouse position (convenience method)
public ushort GetProvinceAtMousePosition(Camera camera)
Parameters
cameraCamera
Returns
- ushort
GetProvinceAtScreenPosition(Vector2, Camera)
Get province ID at screen position using raycast Works with both orthographic and perspective cameras
public ushort GetProvinceAtScreenPosition(Vector2 screenPosition, Camera camera)
Parameters
Returns
- ushort
GetProvinceAtWorldPosition(Vector3)
Get province ID at world position using local-space UV lookup. Converts world position to mesh-local UV without raycasting. For direct world-position queries (e.g. unit placement), not mouse input.
public ushort GetProvinceAtWorldPosition(Vector3 worldPosition)
Parameters
worldPositionVector3
Returns
- ushort
GetSelectedProvince()
Get the currently selected province ID
public ushort GetSelectedProvince()
Returns
- ushort
Initialize(MapTextureManager, Transform)
public void Initialize(MapTextureManager textures, Transform quadTransform)
Parameters
texturesMapTextureManagerquadTransformTransform
Events
OnProvinceClicked
public event Action<ushort> OnProvinceClicked
Event Type
- Action<ushort>
OnProvinceHovered
public event Action<ushort> OnProvinceHovered
Event Type
- Action<ushort>
OnProvinceRightClicked
public event Action<ushort> OnProvinceRightClicked
Event Type
- Action<ushort>
OnSelectionCleared
public event Action OnSelectionCleared
Event Type
- Action