public void ImplementMitigation(IPlacementArea area, IntVector2 gridPosition, IntVector2 sizeOffset) { if (currentCourseOfAction != null) { // Withdraw cost PlayerStats.I.Worth -= currentCourseOfAction.GetValue(); // Occupy area in grid area.Occupy(gridPosition, sizeOffset, PlacementTileState.Filled); // Initialize the mitigation var mitigation = UnityHelper .Instantiate(CourseOfActionPrefab, area.GridToWorld(gridPosition, sizeOffset)) .GetComponent <MitigationBehaviour>(); mitigation.Initialize(area, gridPosition, sizeOffset, currentCourseOfAction); ExitBuildMode(); } }
/// <summary> /// Snaps a given world positionn to this grid /// </summary> public static Vector3 Snap(this IPlacementArea placementArea, Vector3 worldPosition, IntVector2 sizeOffset) { // Calculate the nearest grid location and then change that back to world space return(placementArea.GridToWorld(placementArea.WorldToGrid(worldPosition, sizeOffset), sizeOffset)); }