2019-08-14 11:13:27 +08:00
|
|
|
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;
|
2019-08-23 04:43:11 +08:00
|
|
|
using StardewValley.Buildings;
|
2019-08-14 11:13:27 +08:00
|
|
|
|
|
|
|
namespace Revitalize.Framework.Utilities
|
|
|
|
{
|
2019-08-17 03:26:50 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Deals with helping with locational logic.
|
|
|
|
/// </summary>
|
2019-08-14 11:13:27 +08:00
|
|
|
public class LocationUtilities
|
|
|
|
{
|
2019-08-17 03:26:50 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The int value used by SDV to determine if a farm is a hilltop farm.
|
|
|
|
/// </summary>
|
|
|
|
public static int Farm_HilltopFarmNumber
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-14 11:13:27 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Checks to see if the player is in the regular mine.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool IsPlayerInMine()
|
|
|
|
{
|
|
|
|
if (Game1.player.currentLocation.Name.StartsWith("UndergroundMine"))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-15 11:21:44 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Checks to see if the player is in the enterance to the mine.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool IsPlayerInMineEnterance()
|
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
if (Game1.player.currentLocation.Name.StartsWith("Mine") || Game1.player.currentLocation.Name == "Mine")
|
2019-08-15 11:21:44 +08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-14 11:13:27 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Checks to see if the player is in skull cave.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool IsPlayerInSkullCave()
|
|
|
|
{
|
|
|
|
if (Game1.player.currentLocation.Name == "SkullCave" || Game1.player.currentLocation.Name.StartsWith("SkullCave"))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the current mine level for the player. If the player is not in the mine this is -1.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static int CurrentMineLevel()
|
|
|
|
{
|
|
|
|
if (IsPlayerInMine())
|
|
|
|
{
|
|
|
|
return (Game1.player.currentLocation as StardewValley.Locations.MineShaft).mineLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the tile width and height for the map.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="location"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static Vector2 GetLocationTileDimensions(GameLocation location)
|
|
|
|
{
|
|
|
|
Vector2 dimensions = new Vector2(location.Map.GetLayer("Back").LayerWidth, location.Map.GetLayer("Back").LayerHeight);
|
2019-08-14 14:06:51 +08:00
|
|
|
//ModCore.log("Dimensions of map is: " + dimensions);
|
2019-08-14 11:13:27 +08:00
|
|
|
return dimensions;
|
|
|
|
}
|
2019-08-27 07:34:03 +08:00
|
|
|
|
2019-08-14 11:13:27 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Gets all open positions for this location for this object.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="Location"></param>
|
|
|
|
/// <param name="TestObject"></param>
|
|
|
|
/// <returns></returns>
|
2019-08-23 04:43:11 +08:00
|
|
|
public static List<Vector2> GetOpenObjectTiles(GameLocation Location, MultiTiledObject TestObject)
|
2019-08-14 11:13:27 +08:00
|
|
|
{
|
|
|
|
Vector2 dimensions = GetLocationTileDimensions(Location);
|
|
|
|
List<Vector2> openTiles = new List<Vector2>();
|
2019-08-23 04:43:11 +08:00
|
|
|
for (int i = 0; i < dimensions.X; i++)
|
2019-08-14 11:13:27 +08:00
|
|
|
{
|
2019-08-23 04:43:11 +08:00
|
|
|
for (int j = 0; j < dimensions.Y; j++)
|
2019-08-14 11:13:27 +08:00
|
|
|
{
|
|
|
|
Vector2 tile = new Vector2(i, j);
|
|
|
|
if (TestObject.canBePlacedHere(Location, tile))
|
|
|
|
{
|
|
|
|
openTiles.Add(tile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return openTiles;
|
|
|
|
}
|
2019-08-27 07:34:03 +08:00
|
|
|
|
2019-08-17 03:26:50 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Checks to see if the farm for the game is the hilltop farm.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static bool Farm_IsFarmHiltopFarm()
|
|
|
|
{
|
|
|
|
return Game1.whichFarm == Farm_HilltopFarmNumber;
|
|
|
|
}
|
2019-08-23 04:43:11 +08:00
|
|
|
|
|
|
|
public static List<GameLocation> GetAllLocations()
|
|
|
|
{
|
|
|
|
List<GameLocation> locations = new List<GameLocation>();
|
2019-08-23 07:30:22 +08:00
|
|
|
foreach (GameLocation location in Game1.locations)
|
2019-08-23 04:43:11 +08:00
|
|
|
{
|
|
|
|
locations.Add(location);
|
|
|
|
}
|
|
|
|
foreach(Building b in Game1.getFarm().buildings)
|
|
|
|
{
|
|
|
|
locations.Add(b.indoors.Value);
|
|
|
|
}
|
|
|
|
return locations;
|
|
|
|
}
|
2019-08-14 11:13:27 +08:00
|
|
|
}
|
|
|
|
}
|