using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Revitalize.Framework.Objects;
using StardewValley;
using StardewValley.Buildings;
namespace Revitalize.Framework.Utilities
{
///
/// Deals with helping with locational logic.
///
public class LocationUtilities
{
///
/// The int value used by SDV to determine if a farm is a hilltop farm.
///
public static int Farm_HilltopFarmNumber
{
get
{
return 3;
}
}
///
/// Checks to see if the player is in the regular mine.
///
///
public static bool IsPlayerInMine()
{
if (Game1.player.currentLocation.Name.StartsWith("UndergroundMine"))
{
return true;
}
return false;
}
///
/// Checks to see if the player is in the enterance to the mine.
///
///
public static bool IsPlayerInMineEnterance()
{
if (Game1.player.currentLocation.Name.StartsWith("Mine") || Game1.player.currentLocation.Name == "Mine")
{
return true;
}
return false;
}
///
/// Checks to see if the player is in skull cave.
///
///
public static bool IsPlayerInSkullCave()
{
if (Game1.player.currentLocation.Name == "SkullCave" || Game1.player.currentLocation.Name.StartsWith("SkullCave"))
{
return true;
}
return false;
}
///
/// Gets the current mine level for the player. If the player is not in the mine this is -1.
///
///
public static int CurrentMineLevel()
{
if (IsPlayerInMine())
{
return (Game1.player.currentLocation as StardewValley.Locations.MineShaft).mineLevel;
}
else
{
return -1;
}
}
///
/// Gets the tile width and height for the map.
///
///
///
public static Vector2 GetLocationTileDimensions(GameLocation location)
{
Vector2 dimensions = new Vector2(location.Map.GetLayer("Back").LayerWidth, location.Map.GetLayer("Back").LayerHeight);
//ModCore.log("Dimensions of map is: " + dimensions);
return dimensions;
}
///
/// Gets all open positions for this location for this object.
///
///
///
///
public static List GetOpenObjectTiles(GameLocation Location, MultiTiledObject TestObject)
{
Vector2 dimensions = GetLocationTileDimensions(Location);
List openTiles = new List();
for (int i = 0; i < dimensions.X; i++)
{
for (int j = 0; j < dimensions.Y; j++)
{
Vector2 tile = new Vector2(i, j);
if (TestObject.canBePlacedHere(Location, tile))
{
openTiles.Add(tile);
}
}
}
return openTiles;
}
///
/// Checks to see if the farm for the game is the hilltop farm.
///
///
public static bool Farm_IsFarmHiltopFarm()
{
return Game1.whichFarm == Farm_HilltopFarmNumber;
}
public static List GetAllLocations()
{
List locations = new List();
foreach (GameLocation location in Game1.locations)
{
locations.Add(location);
}
foreach(Building b in Game1.getFarm().buildings)
{
locations.Add(b.indoors.Value);
}
return locations;
}
}
}