Added Illumination framework to stardust for different colors, and made BFS path finding work for StarAI!

This commit is contained in:
2017-11-16 23:07:30 -08:00
parent a12250b8cc
commit fa3c4389ae
11 changed files with 1204 additions and 104 deletions

View File

@ -61,6 +61,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuneFactoryCropsMod", "Rune
{C5F88D48-EA20-40CD-91E2-C8725DC11795} = {C5F88D48-EA20-40CD-91E2-C8725DC11795}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarAI", "..\StarAI\StarAI\StarAI\StarAI.csproj", "{93632675-991D-425B-96F9-9C2B6BFC4EFE}"
ProjectSection(ProjectDependencies) = postProject
{0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -151,6 +156,10 @@ Global
{8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Release|Any CPU.Build.0 = Release|Any CPU
{93632675-991D-425B-96F9-9C2B6BFC4EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93632675-991D-425B-96F9-9C2B6BFC4EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93632675-991D-425B-96F9-9C2B6BFC4EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93632675-991D-425B-96F9-9C2B6BFC4EFE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,654 @@
using Microsoft.Xna.Framework;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardustCore.IlluminateFramework
{
/// <summary>
/// Make sure all colors are inverted.
/// </summary>
public class ColorsList
{
public static Color AliceBlue = new Color(15, 7, 0, 255);
public static Color AntiqueWhite = new Color(5, 20, 40, 255);
public static Color Aqua = new Color(255, 0, 0, 255);
public static Color Aquamarine = new Color(128, 0, 43, 255);
/// <summary>
/// A whiteish sort of color witha hint of blue
/// </summary>
public static Color Azure = new Color(15, 0, 0, 255);
public static Color Beige = new Color(10, 10, 35, 255);
public static Color Bisque = new Color(0, 27, 59, 255);
public static Color Black = new Color(255, 255, 255, 255);
public static Color BlanchedAlmond = new Color(0, 20, 40, 255);
public static Color Blue = new Color(255, 255, 0, 255);
public static Color BlueViolet = new Color(117, 212, 29, 255);
public static Color Brown = new Color(90, 213, 213, 255);
public static Color BurlyWood = new Color(33, 71, 120, 255);
public static Color CadetBlue = new Color(160, 97, 95, 255);
public static Color Chartreuse = new Color(128, 0, 255, 255);
public static Color Chocolate = new Color(45, 150, 225, 255);
public static Color Coral = new Color(0, 128, 175, 255);
public static Color CornflowerBlue = new Color(155, 106, 18, 255);
/// <summary>
/// A yellowish color.
/// </summary>
public static Color Cornsilk = new Color(0, 7, 35, 255);
public static Color Crimson = new Color(35, 235, 195, 255);
public static Color Cyan = new Color(255, 0, 0, 255);
public static Color DarkBlue = new Color(255, 255, 116, 255);
public static Color DarkCyan = new Color(255, 114, 114, 255);
public static Color DarkGoldenRod = new Color(71, 121, 244, 255);
public static Color DarkGray = new Color(86, 86, 86, 255);
public static Color DarkGreen = new Color(255, 155, 255, 255);
public static Color DarkKhaki = new Color(66, 72, 148, 255);
public static Color DarkMagenta = new Color(116, 255, 116, 255);
public static Color DarkOliveGreen = new Color(170, 148, 208, 255);
public static Color DarkOrange = new Color(0, 115, 255, 255);
public static Color DarkOrchid = new Color(102, 105, 51, 255);
public static Color DarkRed = new Color(116, 255, 255, 255);
public static Color DarkSalmon = new Color(22, 105, 133, 255);
public static Color DarkSeaGreen = new Color(112, 67, 112, 255);
public static Color DarkSlateBlue = new Color(183, 194, 116, 255);
public static Color DarkSlateGray = new Color(208, 176, 176, 255);
public static Color DarkTurquoise = new Color(255, 49, 46, 255);
public static Color DarkViolet = new Color(107, 255, 44, 255);
public static Color DeepPink = new Color(0, 235, 108, 255);
public static Color DeepSkyBlue = new Color(255, 64, 0, 255);
public static Color DimGray = new Color(150, 150, 150, 255);
public static Color DodgerBlue = new Color(225, 111, 0, 255);
public static Color FireBrick = new Color(77, 221, 221, 255);
public static Color FloralWhite = new Color(0, 5, 15, 255);
public static Color ForestGreen = new Color(221, 116, 221, 255);
public static Color Fuchsia = new Color(0, 255, 0, 255);
/// <summary>
/// More of a white-ish color
/// </summary>
public static Color Gainsboro = new Color(35, 35, 35, 255);
public static Color GhostWhite = new Color(7, 7, 0);
public static Color Gold = new Color(0, 40, 255, 255);
public static Color GoldenRod = new Color(37, 90, 223, 255);
public static Color Gray = new Color(127, 127, 127, 255);
public static Color Green = new Color(255, 127, 255, 255);
public static Color GreenYellow = new Color(82, 0, 208, 255);
public static Color HoneyDew = new Color(15, 0, 15, 255);
public static Color HotPink = new Color(0, 140, 75, 255);
public static Color IndianRed = new Color(40, 163, 163, 255);
public static Color Indigo = new Color(180, 255, 125, 255);
public static Color Ivory = new Color(0, 0, 15, 255);
public static Color Khaki = new Color(15, 25, 115, 255);
public static Color Lavender = new Color(25, 25, 5, 255);
public static Color LavenderBlush = new Color(0, 15, 10, 255);
public static Color LawnGreen = new Color(131, 3, 255, 255);
public static Color LemonChiffron = new Color(0, 5, 50, 255);
public static Color LightBlue = new Color(82, 39, 25, 255);
public static Color LightCoral = new Color(15, 127, 127, 255);
public static Color LightCyan = new Color(31, 0, 0, 255);
public static Color LightGoldenRodYellow = new Color(5, 5, 45, 255);
public static Color LightGray = new Color(44, 44, 44, 255);
public static Color LightGreen = new Color(111, 17, 111, 255);
public static Color LightPink = new Color(0, 73, 62, 255);
public static Color LightSalmon = new Color(0, 95, 133, 255);
public static Color LightSeaGreen = new Color(223, 77, 85, 255);
public static Color LightSkyBlue = new Color(120, 49, 5, 255);
public static Color LightSlateGray = new Color(146, 119, 102, 255);
public static Color LightSteelBlue = new Color(79, 59, 33, 255);
public static Color LightYellow = new Color(0, 0, 31, 255);
public static Color Lime = new Color(255, 0, 255, 255);
public static Color LimeGreen = new Color(105, 50, 105, 255);
public static Color Linen = new Color(5, 15, 25, 255);
public static Color Magenta = new Color(0, 255, 0, 255);
public static Color Maroon = new Color(127, 255, 255, 0);
public static Color MediumAquaMarine = new Color(153, 50, 85, 255);
public static Color MediumBlue = new Color(255, 255, 50, 255);
public static Color MediumOrchid = new Color(69, 170, 44, 255);
public static Color MediumPurple = new Color(108, 143, 36, 255);
public static Color MediumSeaGreen = new Color(195, 78, 142, 255);
public static Color MediumSlateBlue = new Color(132, 151, 17, 255);
public static Color MediumSpringGreen = new Color(255, 5, 101, 255);
public static Color MediumTurquoise = new Color(183, 46, 51, 255);
public static Color MediumVioletRed = new Color(46, 234, 122, 255);
public static Color MidnightBlue = new Color(230, 230, 143, 255);
public static Color MintCream = new Color(10, 0, 5, 255);
public static Color MistyRose = new Color(0, 27, 30, 255);
public static Color Moccasin = new Color(0, 33, 82, 255);
public static Color NavajoWhite = new Color(0, 33, 82, 255);
public static Color Navy = new Color(255, 255, 127, 255);
public static Color OldLace = new Color(2, 10, 25, 255);
public static Color Olive = new Color(127, 127, 255, 255);
public static Color OliveDrab = new Color(148, 113, 220, 255);
public static Color Orange = new Color(0, 90, 255, 255);
public static Color OrangeRed = new Color(0, 186, 255, 255);
public static Color Orchid = new Color(37, 143, 41, 255);
public static Color PaleGoldenRod = new Color(17, 23, 85, 255);
public static Color PaleGreen = new Color(103, 4, 103, 255);
public static Color PaleTurquoise = new Color(80, 17, 17, 255);
public static Color PaleVioletRed = new Color(36, 143, 108, 255);
public static Color PapayaWhip = new Color(0, 16, 42, 255);
public static Color PeachPuff = new Color(0, 37, 70, 255);
public static Color Peru = new Color(50, 122, 192, 255);
public static Color Pink = new Color(0, 63, 52, 255);
public static Color Plum = new Color(34, 95, 34, 255);
public static Color PowderBlue = new Color(79, 31, 25, 255);
public static Color Purple = new Color(127, 255, 127, 255);
public static Color RebeccaPurple = new Color(153, 104, 102, 255);
public static Color Red = new Color(0, 255, 255, 255);
public static Color RosyBrown = new Color(67, 112, 112, 255);
public static Color RoyalBlue = new Color(190, 150, 30, 255);
public static Color SaddleBrown = new Color(115, 186, 231, 255);
public static Color Salmon = new Color(5, 127, 141, 255);
public static Color SandyBrown = new Color(11, 91, 159, 255);
public static Color SeaGreen = new Color(209, 116, 168, 255);
public static Color SeaShell = new Color(0, 10, 17, 255);
public static Color Sienna = new Color(95, 173, 210, 255);
public static Color Silver = new Color(63, 63, 63, 255);
public static Color SkyBlue = new Color(120, 49, 20, 255);
public static Color SlateBlue = new Color(149, 165, 50, 255);
public static Color SlateGray = new Color(143, 127, 111, 255);
public static Color Snow = new Color(0, 5, 5, 255);
public static Color SpringGreen = new Color(255, 0, 128, 255);
public static Color SteelBlue = new Color(185, 125, 75, 255);
public static Color Tan = new Color(45, 75, 115, 255);
public static Color Teal = new Color(255, 127, 127, 255);
public static Color Thistle = new Color(39, 64, 39, 255);
public static Color Tomato = new Color(0, 156, 184, 255);
public static Color Turquoise = new Color(191, 31, 47, 255);
public static Color Violet = new Color(17, 125, 17, 255);
public static Color Wheat = new Color(10, 33, 76, 255);
public static Color White = new Color(0, 0, 0, 255);
public static Color WhiteSmoke = new Color(10, 10, 10, 255);
public static Color Yellow = new Color(0, 0, 255);
public static Color YellowGreen = new Color(101, 50, 205, 255);
}
/// <summary>
/// Make sure all colors are inverted.
/// </summary>
public class Colors
{
public static Dictionary<string, Color> ColorDictionary;
public static void initializeColors()
{
ColorDictionary = new Dictionary<string, Color>();
ColorDictionary.Add("AliceBlue",new Color(15, 7, 0, 255));
ColorDictionary.Add("AntiqueWhite",new Color(5, 20, 40, 255));
ColorDictionary.Add("Aqua",new Color(255, 0, 0, 255));
ColorDictionary.Add("Aquamarine",new Color(128, 0, 43, 255));
/// <summary>
/// A whiteish sort of color witha hint of blue
/// </summary>
ColorDictionary.Add("Azure", new Color(15, 0, 0, 255));
ColorDictionary.Add("Beige", new Color(10, 10, 35, 255));
ColorDictionary.Add("Bisque", new Color(0, 27, 59, 255));
ColorDictionary.Add("Black", new Color(255, 255, 255, 255));
ColorDictionary.Add("BlanchedAlmond", new Color(0, 20, 40, 255));
ColorDictionary.Add("Blue", new Color(255, 255, 0, 255));
ColorDictionary.Add("BlueViolet", new Color(117, 212, 29, 255));
ColorDictionary.Add("Brown", new Color(90, 213, 213, 255));
ColorDictionary.Add("BurlyWood", new Color(33, 71, 120, 255));
ColorDictionary.Add("CadetBlue", new Color(160, 97, 95, 255));
ColorDictionary.Add("Chartreuse", new Color(128, 0, 255, 255));
ColorDictionary.Add("Chocolate", new Color(45, 150, 225, 255));
ColorDictionary.Add("Coral", new Color(0, 128, 175, 255));
ColorDictionary.Add("CornflowerBlue", new Color(155, 106, 18, 255));
/// <summary>
/// A yellowish color.
/// </summary>
ColorDictionary.Add("Cornsilk", new Color(0, 7, 35, 255));
ColorDictionary.Add("Crimson", new Color(35, 235, 195, 255));
ColorDictionary.Add("Cyan", new Color(255, 0, 0, 255));
ColorDictionary.Add("DarkBlue", new Color(255, 255, 116, 255));
ColorDictionary.Add("DarkCyan", new Color(255, 114, 114, 255));
ColorDictionary.Add("DarkGoldenRod", new Color(71, 121, 244, 255));
ColorDictionary.Add("DarkGray", new Color(86, 86, 86, 255));
ColorDictionary.Add("DarkGreen", new Color(255, 155, 255, 255));
ColorDictionary.Add("DarkKhaki", new Color(66, 72, 148, 255));
ColorDictionary.Add("DarkMagenta", new Color(116, 255, 116, 255));
ColorDictionary.Add("DarkOliveGreen", new Color(170, 148, 208, 255));
ColorDictionary.Add("DarkOrange", new Color(0, 115, 255, 255));
ColorDictionary.Add("DarkOrchid", new Color(102, 105, 51, 255));
ColorDictionary.Add("DarkRed", new Color(116, 255, 255, 255));
ColorDictionary.Add("DarkSalmon", new Color(22, 105, 133, 255));
ColorDictionary.Add("DarkSeaGreen", new Color(112, 67, 112, 255));
ColorDictionary.Add("DarkSlateBlue", new Color(183, 194, 116, 255));
ColorDictionary.Add("DarkSlateGray", new Color(208, 176, 176, 255));
ColorDictionary.Add("DarkTurquoise", new Color(255, 49, 46, 255));
ColorDictionary.Add("DarkViolet", new Color(107, 255, 44, 255));
ColorDictionary.Add("DeepPink", new Color(0, 235, 108, 255));
ColorDictionary.Add("DeepSkyBlue", new Color(255, 64, 0, 255));
ColorDictionary.Add("DimGray", new Color(150, 150, 150, 255));
ColorDictionary.Add("DodgerBlue", new Color(225, 111, 0, 255));
ColorDictionary.Add("FireBrick", new Color(77, 221, 221, 255));
ColorDictionary.Add("FloralWhite", new Color(0, 5, 15, 255));
ColorDictionary.Add("ForestGreen", new Color(221, 116, 221, 255));
ColorDictionary.Add("Fuchsia", new Color(0, 255, 0, 255));
/// <summary>
/// More of a white-ish color
/// </summary>
ColorDictionary.Add("Gainsboro", new Color(35, 35, 35, 255));
ColorDictionary.Add("GhostWhite", new Color(7, 7, 0));
ColorDictionary.Add("Gold", new Color(0, 40, 255, 255));
ColorDictionary.Add("GoldenRod", new Color(37, 90, 223, 255));
ColorDictionary.Add("Gray", new Color(127, 127, 127, 255));
ColorDictionary.Add("Green", new Color(255, 127, 255, 255));
ColorDictionary.Add("GreenYellow", new Color(82, 0, 208, 255));
ColorDictionary.Add("HoneyDew", new Color(15, 0, 15, 255));
ColorDictionary.Add("HotPink", new Color(0, 140, 75, 255));
ColorDictionary.Add("IndianRed", new Color(40, 163, 163, 255));
ColorDictionary.Add("Indigo", new Color(180, 255, 125, 255));
ColorDictionary.Add("Ivory", new Color(0, 0, 15, 255));
ColorDictionary.Add("Khaki", new Color(15, 25, 115, 255));
ColorDictionary.Add("Lavender", new Color(25, 25, 5, 255));
ColorDictionary.Add("LavenderBlush", new Color(0, 15, 10, 255));
ColorDictionary.Add("LawnGreen", new Color(131, 3, 255, 255));
ColorDictionary.Add("LemonChiffron", new Color(0, 5, 50, 255));
ColorDictionary.Add("LightBlue", new Color(82, 39, 25, 255));
ColorDictionary.Add("LightCoral", new Color(15, 127, 127, 255));
ColorDictionary.Add("LightCyan", new Color(31, 0, 0, 255));
ColorDictionary.Add("LightGoldenRodYellow", new Color(5, 5, 45, 255));
ColorDictionary.Add("LightGray", new Color(44, 44, 44, 255));
ColorDictionary.Add("LightGreen", new Color(111, 17, 111, 255));
ColorDictionary.Add("LightPink", new Color(0, 73, 62, 255));
ColorDictionary.Add("LightSalmon", new Color(0, 95, 133, 255));
ColorDictionary.Add("LightSeaGreen", new Color(223, 77, 85, 255));
ColorDictionary.Add("LightSkyBlue", new Color(120, 49, 5, 255));
ColorDictionary.Add("LightSlateGray", new Color(146, 119, 102, 255));
ColorDictionary.Add("LightSteelBlue", new Color(79, 59, 33, 255));
ColorDictionary.Add("LightYellow", new Color(0, 0, 31, 255));
ColorDictionary.Add("Lime", new Color(255, 0, 255, 255));
ColorDictionary.Add("LimeGreen", new Color(105, 50, 105, 255));
ColorDictionary.Add("Linen", new Color(5, 15, 25, 255));
ColorDictionary.Add("Magenta", new Color(0, 255, 0, 255));
ColorDictionary.Add("Maroon", new Color(127, 255, 255, 0));
ColorDictionary.Add("MediumAquaMarine", new Color(153, 50, 85, 255));
ColorDictionary.Add("MediumBlue", new Color(255, 255, 50, 255));
ColorDictionary.Add("MediumOrchid", new Color(69, 170, 44, 255));
ColorDictionary.Add("MediumPurple", new Color(108, 143, 36, 255));
ColorDictionary.Add("MediumSeaGreen", new Color(195, 78, 142, 255));
ColorDictionary.Add("MediumSlateBlue", new Color(132, 151, 17, 255));
ColorDictionary.Add("MediumSpringGreen", new Color(255, 5, 101, 255));
ColorDictionary.Add("MediumTurquoise", new Color(183, 46, 51, 255));
ColorDictionary.Add("MediumVioletRed", new Color(46, 234, 122, 255));
ColorDictionary.Add("MidnightBlue", new Color(230, 230, 143, 255));
ColorDictionary.Add("MintCream", new Color(10, 0, 5, 255));
ColorDictionary.Add("MistyRose", new Color(0, 27, 30, 255));
ColorDictionary.Add("Moccasin", new Color(0, 33, 82, 255));
ColorDictionary.Add("NavajoWhite", new Color(0, 33, 82, 255));
ColorDictionary.Add("Navy", new Color(255, 255, 127, 255));
ColorDictionary.Add("OldLace", new Color(2, 10, 25, 255));
ColorDictionary.Add("Olive", new Color(127, 127, 255, 255));
ColorDictionary.Add("OliveDrab", new Color(148, 113, 220, 255));
ColorDictionary.Add("Orange", new Color(0, 90, 255, 255));
ColorDictionary.Add("OrangeRed", new Color(0, 186, 255, 255));
ColorDictionary.Add("Orchid", new Color(37, 143, 41, 255));
ColorDictionary.Add("PaleGoldenRod", new Color(17, 23, 85, 255));
ColorDictionary.Add("PaleGreen", new Color(103, 4, 103, 255));
ColorDictionary.Add("PaleTurquoise", new Color(80, 17, 17, 255));
ColorDictionary.Add("PaleVioletRed", new Color(36, 143, 108, 255));
ColorDictionary.Add("PapayaWhip", new Color(0, 16, 42, 255));
ColorDictionary.Add("PeachPuff", new Color(0, 37, 70, 255));
ColorDictionary.Add("Peru", new Color(50, 122, 192, 255));
ColorDictionary.Add("Pink", new Color(0, 63, 52, 255));
ColorDictionary.Add("Plum", new Color(34, 95, 34, 255));
ColorDictionary.Add("PowderBlue", new Color(79, 31, 25, 255));
ColorDictionary.Add("Purple", new Color(127, 255, 127, 255));
ColorDictionary.Add("RebeccaPurple", new Color(153, 104, 102, 255));
ColorDictionary.Add("Red", new Color(0, 255, 255, 255));
ColorDictionary.Add("RosyBrown", new Color(67, 112, 112, 255));
ColorDictionary.Add("RoyalBlue", new Color(190, 150, 30, 255));
ColorDictionary.Add("SaddleBrown", new Color(115, 186, 231, 255));
ColorDictionary.Add("Salmon", new Color(5, 127, 141, 255));
ColorDictionary.Add("SandyBrown", new Color(11, 91, 159, 255));
ColorDictionary.Add("SeaGreen", new Color(209, 116, 168, 255));
ColorDictionary.Add("SeaShell", new Color(0, 10, 17, 255));
ColorDictionary.Add("Sienna", new Color(95, 173, 210, 255));
ColorDictionary.Add("Silver", new Color(63, 63, 63, 255));
ColorDictionary.Add("SkyBlue", new Color(120, 49, 20, 255));
ColorDictionary.Add("SlateBlue", new Color(149, 165, 50, 255));
ColorDictionary.Add("SlateGray", new Color(143, 127, 111, 255));
ColorDictionary.Add("Snow", new Color(0, 5, 5, 255));
ColorDictionary.Add("SpringGreen", new Color(255, 0, 128, 255));
ColorDictionary.Add("SteelBlue", new Color(185, 125, 75, 255));
ColorDictionary.Add("Tan", new Color(45, 75, 115, 255));
ColorDictionary.Add("Teal", new Color(255, 127, 127, 255));
ColorDictionary.Add("Thistle", new Color(39, 64, 39, 255));
ColorDictionary.Add("Tomato", new Color(0, 156, 184, 255));
ColorDictionary.Add("Turquoise", new Color(191, 31, 47, 255));
ColorDictionary.Add("Violet", new Color(17, 125, 17, 255));
ColorDictionary.Add("Wheat", new Color(10, 33, 76, 255));
ColorDictionary.Add("White", new Color(0, 0, 0, 255));
ColorDictionary.Add("WhiteSmoke", new Color(10, 10, 10, 255));
ColorDictionary.Add("Yellow", new Color(0, 0, 255));
ColorDictionary.Add("YellowGreen", new Color(101, 50, 205, 255));
}
public static Color randomColor()
{
Random r = new Random(Game1.player.money + Game1.tileSize + Game1.dayOfMonth+(int)Game1.stats.stepsTaken);
int R = r.Next(0, 255);
int G = r.Next(0, 255);
int B = r.Next(0, 255);
int A = 255;
return new Color(R, G, B, A);
}
public static Color invertColor(Color c, int Alpha = 255)
{
int r;
int g;
int b;
int a = Alpha;
r = 255 - c.R;
g = 255 - c.G;
b = 255 - c.B;
// a = 255 - c.A;
if (a == 0)
{
return new Color(0, 0, 0, 0);
}
return new Color(r, g, b, a);
}
public Color getColorFromList(string s)
{
Color color;
bool f = ColorDictionary.TryGetValue(s, out color);
if (f == false)
{
color = ColorDictionary["White"];
}
return color;
}
}
}

View File

@ -35,11 +35,14 @@ namespace StardustCore
StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave;
StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave;
StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad;
IlluminateFramework.Colors.initializeColors();
}
private void SaveEvents_AfterLoad(object sender, EventArgs e)
{
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
}
private void SaveEvents_AfterSave(object sender, EventArgs e)

View File

@ -44,6 +44,7 @@
<ItemGroup>
<Compile Include="Animations\Animation.cs" />
<Compile Include="Animations\AnimationManager.cs" />
<Compile Include="IlluminateFramework\Colors.cs" />
<Compile Include="ModCore.cs" />
<Compile Include="CoreObject.cs" />
<Compile Include="ModInfo\Metadata.cs" />

View File

@ -11,5 +11,5 @@
"Description": "A core mod that allows for other mods to be run.",
"UniqueID": "Omegasis.StardustCore",
"EntryDll": "StardustCore.dll",
"UpdateKeys": [ ]
"UpdateKeys": [""]
}

View File

@ -9,6 +9,7 @@ using WindowsInput;
using Microsoft.Xna.Framework;
using StarAI.PathFindingCore;
using System.IO;
using StardustCore;
namespace StarAI
{
@ -21,12 +22,17 @@ namespace StarAI
public static StardewModdingAPI.IMonitor CoreMonitor;
public static StardewModdingAPI.IModHelper CoreHelper;
public static List<Warp> warpGoals= new List<Warp>();
public static object[] obj = new object[3];
public static Task fun = new Task(new Action(calculateMovement));
public static Task fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal),obj);
public override void Entry(IModHelper helper)
{
obj[0] = PathFindingLogic.source;
obj[1] = PathFindingLogic.currentGoal;
obj[2] = PathFindingLogic.queue;
CoreHelper = helper;
helper.ConsoleCommands.Add("hello", "Ok?", new Action<string, string[]>(hello));
helper.ConsoleCommands.Add("pathfind", "pathy?", new Action<string, string[]>(pathfind));
string[] s = new string[10];
CoreMonitor = this.Monitor;
@ -37,6 +43,145 @@ namespace StarAI
StardewModdingAPI.Events.GameEvents.SecondUpdateTick += GameEvents_SecondUpdateTick;
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
StardustCore.ModCore.SerializationManager.acceptedTypes.Add("StarAI.PathFindingCore.TileNode", new StardustCore.Serialization.SerializerDataNode(new StardustCore.Serialization.SerializerDataNode.SerializingFunction(TileNode.Serialize), new StardustCore.Serialization.SerializerDataNode.ParsingFunction(TileNode.ParseIntoInventory), new StardustCore.Serialization.SerializerDataNode.WorldParsingFunction(TileNode.SerializeFromWorld), new StardustCore.Serialization.SerializerDataNode.SerializingToContainerFunction(TileNode.Serialize)));
}
public void pathfind(string s, string[] args)
{
if (args.Length < 1)
{
CoreMonitor.Log("No args passed into path finding function",LogLevel.Error);
}
if (args[0] == "addGoal")
{
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Green));
Vector2 pos=new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X,pos.Y), Game1.player.currentLocation);
if (ok == false)
{
CoreMonitor.Log("Can't place a goal point here!!!", LogLevel.Error);
return;
}
t.placementAction(Game1.currentLocation,(int) pos.X,(int) pos.Y);
PathFindingLogic.currentGoal = t;
PathFindingLogic.goals.Add(t);
}
if (args[0] == "addStart")
{
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"), StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Magenta));
Vector2 pos;
if (args[1] == "currentPosition")
{
pos = new Vector2((int)(Game1.player.getTileX() * Game1.tileSize), Game1.player.getTileY() * Game1.tileSize);
}
else
{
pos = new Vector2((int)(Convert.ToInt32(args[1]) * Game1.tileSize), Convert.ToInt32(args[2]) * Game1.tileSize);
}
bool ok = t.checkIfICanPlaceHere(t, new Vector2(pos.X, pos.Y), Game1.player.currentLocation);
if (ok == false)
{
CoreMonitor.Log("Can't place a start point here!!!", LogLevel.Error);
return;
}
t.placementAction(Game1.currentLocation, (int)pos.X, (int)pos.Y);
PathFindingLogic.source = t;
}
if (args[0] == "restart")
{
List<CoreObject> removalList = new List<CoreObject>();
foreach(var v in StardustCore.ModCore.SerializationManager.trackedObjectList)
{
removalList.Add(v);
}
foreach (var v in removalList)
{
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v);
Game1.player.currentLocation.objects.Remove(v.TileLocation);
pathfind("pathfind restart", new string[]
{
"addGoal",
PathFindingLogic.currentGoal.tileLocation.X.ToString(),
PathFindingLogic.currentGoal.tileLocation.Y.ToString(),
}
);
}
removalList.Clear();
pathfind("pathfind restart", new string[]
{
"addStart",
PathFindingLogic.source.tileLocation.X.ToString(),
PathFindingLogic.source.tileLocation.Y.ToString(),
}
);
pathfind("pathfind restart", new string[]
{
"start"
}
);
}
if (args[0] == "start")
{
if (Game1.player == null) return;
if (Game1.hasLoadedGame == false) return;
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
if (PathFindingCore.PathFindingLogic.currentGoal == null)
{
CoreMonitor.Log("NO VALID GOAL SET FOR PATH FINDING!",LogLevel.Error);
}
if (PathFindingCore.PathFindingLogic.source == null)
{
CoreMonitor.Log("NO VALID START SET FOR PATH FINDING!", LogLevel.Error);
}
if (fun.Status == TaskStatus.Running)
{
CoreMonitor.Log("TASK IS RUNNING CAN'T PATHFIND AT THE MOMENT", LogLevel.Alert);
return;
}
if (fun.Status == TaskStatus.RanToCompletion)
{
CoreMonitor.Log("TASK IS Finished PATHFINDING", LogLevel.Warn);
obj[0] = PathFindingLogic.source;
obj[1] = PathFindingLogic.currentGoal;
obj[2] = PathFindingLogic.queue;
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
return;
}
if (fun.Status == TaskStatus.Created)
{
CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
obj[0] = PathFindingLogic.source;
obj[1] = PathFindingLogic.currentGoal;
obj[2] = PathFindingLogic.queue;
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
fun.Start();
return;
}
CoreMonitor.Log(fun.Status.ToString());
if (fun.Status == TaskStatus.Faulted)
{
CoreMonitor.Log(fun.Exception.ToString());
CoreMonitor.Log("CREATE AND RUN A TASK!!! PATHFINDING!");
obj[0] = PathFindingLogic.source;
obj[1] = PathFindingLogic.currentGoal;
obj[2] = PathFindingLogic.queue;
fun = new Task(new Action<object>(PathFindingLogic.pathFindToSingleGoal), obj);
}
}
}
private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
@ -45,9 +190,7 @@ namespace StarAI
{
CoreMonitor.Log("OK THE J KEY WAS PRESSED!");
List<Item> shoppingList = new List<Item>();
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"));
CoreMonitor.Log("AAAAAAAA???????:" + t.name);
CoreMonitor.Log("BBBBBB???????:" + t.DisplayName);
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Aqua));
if (t == null)
{
CoreMonitor.Log("WTF?????");
@ -56,24 +199,47 @@ namespace StarAI
{
if (t == null)
{
CoreMonitor.Log("FUCK");
System.Threading.Thread.Sleep(5);
return;
}
shoppingList.Add((Item)t);
foreach(var v in shoppingList)
{
if (v == null) continue;
CoreMonitor.Log("FUUUUU???????:"+ (v as TileNode).name);
CoreMonitor.Log("FUUUUU???????:" + (v as TileNode).DisplayName);
}
Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(shoppingList);
}catch(Exception err)
{
CoreMonitor.Log(Convert.ToString(err));
}
}
if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K)
{
CoreMonitor.Log("OK THE K KEY WAS PRESSED!");
TileNode t = new TileNode(1, Vector2.Zero, Path.Combine("Tiles", "GenericUncoloredTile.xnb"), Path.Combine("Tiles", "TileData.xnb"),StardustCore.IlluminateFramework.Colors.randomColor());
if (t == null)
{
CoreMonitor.Log("WTF?????");
}
try
{
if (t == null)
{
return;
}
CoreMonitor.Log(new Vector2(Game1.player.getTileX()*Game1.tileSize,Game1.player.getTileY()*Game1.tileSize).ToString());
int xPos = (int)(Game1.player.getTileX()) * Game1.tileSize;
int yPos = (int)(Game1.player.getTileY()) * Game1.tileSize;
Rectangle r = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
Vector2 pos = new Vector2(r.X, r.Y);
bool ok = t.checkIfICanPlaceHere(t,pos,Game1.player.currentLocation);
if (ok == false) return;
t.placementAction(Game1.currentLocation, Game1.player.getTileX()*Game1.tileSize, Game1.player.getTileY()*Game1.tileSize);
t.setAdjacentTiles(true);
}
catch (Exception err)
{
CoreMonitor.Log(Convert.ToString(err));
}
}
}
public static Vector2 parseCenterFromTile(int tileX, int tileY)
@ -233,6 +399,9 @@ namespace StarAI
private void GameEvents_SecondUpdateTick(object sender, EventArgs e)
{
if (Game1.player == null) return;
if (Game1.hasLoadedGame == false) return;
// ModCore.CoreMonitor.Log(Game1.player.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)(Game1.player.getTileX() + 1)*Game1.tileSize, (int)(Game1.player.getTileY())*Game1.tileSize)).ToString());
//CoreMonitor.Log(Convert.ToString(warpGoals.Count));
if (warpGoals.Count == 0) return;
if (fun.Status == TaskStatus.Running)

View File

@ -0,0 +1,152 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StarAI;
using StardewModdingAPI;
using StardewValley;
namespace StarAI.PathFindingCore
{
class PathFindingLogic
{
public static TileNode source;
public static List<TileNode> goals=new List<TileNode>();
public static List<TileNode> queue=new List<TileNode>();
public static int totalPathCost;
public static TileNode currentGoal;
public static List<TileNode> path=new List<TileNode>();
public static int index = 0;
public static void pathFindToSingleGoal(object data)
{
ModCore.CoreMonitor.Log("LET'S GO!!!!", LogLevel.Error);
object[] obj = (object[])data;
foreach(var v in obj)
{
ModCore.CoreMonitor.Log(v.ToString(), LogLevel.Warn);
}
TileNode Source =(TileNode) obj[0];
TileNode Goal = (TileNode)obj[1];
List<TileNode> Queue = (List<TileNode>)obj[2];
totalPathCost = 0;
TileNode currentNode = Source;
queue.Add(currentNode);
index++;
bool goalFound = false;
while (currentNode.tileLocation != Goal.tileLocation && queue.Count != 0)
{
//Add children to current node
int xMin = -1;
int yMin = -1;
int xMax = 1;
int yMax = 1;
//try to set children to tiles where children haven't been before
for (int x = xMin; x <= xMax; x++)
{
for (int y = yMin; y <= yMax; y++)
{
if (x == 0 && y == 0) continue;
//Include these 4 checks for just left right up down movement. Remove them to enable 8 direction path finding
if (x == -1 && y == -1) continue; //upper left
if (x == -1 && y == 1) continue; //bottom left
if (x == 1 && y == -1) continue; //upper right
if (x == 1 && y == 1) continue; //bottom right
//TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);
TileNode.setSingleTileAsChild(currentNode, (int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y);
Vector2 check = new Vector2((int)currentNode.tileLocation.X + x, (int)currentNode.tileLocation.Y + y);
if(check.X==Goal.tileLocation.X && check.Y == Goal.tileLocation.Y)
{
Goal.parent = currentNode;
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange);
currentNode = Goal;
// ModCore.CoreMonitor.Log("SNAGED THE GOAL!!!!!!");
//System.Threading.Thread.Sleep(2000);
goalFound = true;
}
}
}
if (goalFound == true)
{
currentNode = Goal;
//ModCore.CoreMonitor.Log("FOUND YOU!!!");
//System.Threading.Thread.Sleep(2000);
break;
}
List<TileNode> adjList = new List<TileNode>();
foreach (var node in currentNode.children) {
//TileNode t = new TileNode(1, Vector2.Zero, Souce.texturePath,source.dataPath, source.drawColor);
//TileNode.setSingleTileAsChild(source, (int)source.tileLocation.X + x, (int)source.tileLocation.Y + y);
if (node.parent == null)
{
ModCore.CoreMonitor.Log("I DONT UNDERSTAND!");
System.Threading.Thread.Sleep(500);
}
ModCore.CoreMonitor.Log("ok checking adj:" + node.tileLocation.ToString());
if (node.seenState == 0)
{
node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightPink); //Seen
adjList.Add(node);
}
if (node.seenState == 1)
{
node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue);
}
if (node.seenState == 2)
{
node.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange);
}
}
foreach (var v in adjList)
{
if (queue.Contains(v)) continue;
else queue.Add(v);
}
currentNode.seenState = 2;
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.DarkOrange); //Finished
currentNode = queue.ElementAt(index);
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Blue); //Working
index++;
}
if (currentNode.tileLocation == currentGoal.tileLocation)
{
ModCore.CoreMonitor.Log("SWEET BEANS!!!!!!", LogLevel.Error);
queue.Clear();
index = 0;
//ModCore.CoreMonitor.Log(currentNode.parent.ToString(), LogLevel.Error);
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.LightGreen);
//currentGoal.drawColor=
}
while (currentNode.parent != null)
{
currentNode.drawColor= StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
path.Add(currentNode);
currentNode = currentNode.parent;
System.Threading.Thread.Sleep(500);
if (currentNode.parent == null)
{
currentNode.drawColor = StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Red); //Working
path.Add(currentNode);
}
}
}
}
}

View File

@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StardewModdingAPI;
using Microsoft.Xna.Framework;
using StardewValley;
namespace StarAI.PathFindingCore
{
public class TileNodeGraph
{
public Vector2 position;
public List<TileNodeGraph> children = new List<TileNodeGraph>();
public enum stateEnum { NotVisited,Seen,Visited };
public int seenState;
public GameLocation location;
/// <summary>
/// Constructor.
/// </summary>
/// <param name="Position"></param>
/// <param name="Location"></param>
public TileNodeGraph(Vector2 Position,GameLocation Location)
{
this.position = Position;
this.location = Location;
this.seenState = (int)stateEnum.NotVisited;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="Position"></param>
/// <param name="AdjacencyChildren"></param>
/// <param name="Location"></param>
public TileNodeGraph(Vector2 Position, List<TileNodeGraph> AdjacencyChildren, GameLocation Location)
{
this.position = Position;
this.children = AdjacencyChildren;
this.location = Location;
this.seenState = (int)stateEnum.NotVisited;
}
/// <summary>
/// When called it will get the 8 adjacent tiles around this node, and add them to the adjacency list for this tile node.
/// </summary>
public void setAdjacentTiles()
{
Vector2 startPosition = this.position;
for (int x=-1; x<=1; x++)
{
for (int y = -1; y <= 1; y++)
{
Rectangle r = new Rectangle((int)startPosition.X + x, (int)startPosition.Y + y, Game1.tileSize, Game1.tileSize);
if(Game1.currentLocation.isTilePassable(r, Game1.viewport))
{
TileNodeGraph child = new TileNodeGraph(new Vector2(startPosition.X + x, startPosition.Y + y), this.location);
this.children.Add(child);
}
}
}
}
}
}

View File

@ -21,6 +21,11 @@ namespace StarAI.PathFindingCore
/// </summary>
public class TileNode : CoreObject
{
public Vector2 position;
public List<TileNode> children = new List<TileNode>();
public enum stateEnum { NotVisited, Seen, Visited };
public int seenState;
public int Decoration_type;
@ -55,6 +60,161 @@ namespace StarAI.PathFindingCore
public bool IsSolid;
public int cost;
public int costToThisPoint;
public TileNode parent;
public bool checkIfICanPlaceHere(TileNode t, Vector2 pos, GameLocation loc = null, bool recursive = false)
{
bool cry = false;
if (t.thisLocation == null)
{
t.thisLocation = loc;
cry = true;
}
if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y))
{
ModCore.CoreMonitor.Log("F!: " + t.thisLocation.name, LogLevel.Warn);
if (cry == true) this.thisLocation = null;
return false;
}
if (t.thisLocation.isTileOccupied(pos / Game1.tileSize))
{
ModCore.CoreMonitor.Log("K!!!!: " + t.thisLocation.name, LogLevel.Error);
if (cry == true) this.thisLocation = null;
return false;
}
if (t.thisLocation.isTilePlaceable(pos) == false)
{
ModCore.CoreMonitor.Log("C!!!!: " + t.thisLocation.name, LogLevel.Error);
if (cry == true) this.thisLocation = null;
return false;
}
if (t.thisLocation.isTilePlaceable(pos / Game1.tileSize) == false)
{
ModCore.CoreMonitor.Log("J!!!!: " + t.thisLocation.name, LogLevel.Error);
if (cry == true) this.thisLocation = null;
return false;
}
if (t.thisLocation.isTilePassable(new xTile.Dimensions.Location((int)(pos.X/Game1.tileSize), (int)(pos.Y/Game1.tileSize)), Game1.viewport)==false)
{
ModCore.CoreMonitor.Log("Y!!!!: " + t.thisLocation.name, LogLevel.Error);
if (cry == true) this.thisLocation = null;
return false;
}
if (cry == true) this.thisLocation = null;
return true;
}
public static void setSingleTileAsChild(TileNode t,int x, int y)
{
Vector2 pos = new Vector2(x * Game1.tileSize, y * Game1.tileSize);
bool f= t.checkIfICanPlaceHere(t, new Vector2(pos.X,pos.Y), null);
if (f == false) return;
else
{
ModCore.CoreMonitor.Log("Adding a child!");
System.Threading.Thread.Sleep(500);
TileNode child = new TileNode(1, Vector2.Zero, t.texturePath,StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.ColorsList.Cyan));
child.seenState = (int)stateEnum.NotVisited;
child.parent = t;
child.placementAction(Game1.currentLocation, (int)pos.X, (int)pos.Y);
t.children.Add(child);
}
}
public void setAdjacentTiles(bool recursive)
{
Vector2 startPosition = this.tileLocation;
int xMin=-1;
int yMin=-1;
int xMax=1;
int yMax = 1;
for (int x = xMin; x <= xMax; x++)
{
for (int y = yMin; y <= yMax; y++)
{
if (x == 0 && y == 0) continue;
int xPos = (int)(this.tileLocation.X + x) * Game1.tileSize;
int yPos = (int)(this.tileLocation.Y + y) * Game1.tileSize;
ModCore.CoreMonitor.Log("ATTEMPTING TO PLACE ITEM AT: " + new Vector2(this.tileLocation.X + x, this.tileLocation.Y + y));
Rectangle r = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
Vector2 pos = new Vector2(r.X, r.Y);
ModCore.CoreMonitor.Log("THIS IS MY LOCATION!!!: " + this.thisLocation.name);
bool ok = checkIfICanPlaceHere(this,pos,null,recursive);
if (ok == false) continue;
if (this.thisLocation.isTileLocationOpen(new xTile.Dimensions.Location((int) (pos.X) ,(int) (pos.Y)) )==true && this.thisLocation.isObjectAt((int) (pos.X),(int) (pos.Y))==false) ; //&& Game1.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)startPosition.X+x,(int)startPosition.Y+y)))
{
TileNode child = new TileNode(1,Vector2.Zero,this.texturePath,this.drawColor);
child.placementAction(Game1.currentLocation, xPos, yPos);
this.children.Add(child);
}
}
}
}
public static void setAdjacentTiles(Vector2 position, GameLocation loc)
{
Vector2 startPosition = position;
int xMin = -1;
int yMin = -1;
int xMax = 1;
int yMax = 1;
for (int x = xMin; x <= xMax; x++)
{
for (int y = yMin; y <= yMax; y++)
{
int xPos = (int)(startPosition.X + x) * Game1.tileSize;
int yPos = (int)(startPosition.Y + y) * Game1.tileSize;
// ModCore.CoreMonitor.Log("ATTEMPTING TO PLACE ITEM AT: " + new Vector2(this.tileLocation.X + x, this.tileLocation.Y + y));
Rectangle r = new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize);
Vector2 pos = new Vector2(r.X, r.Y);
ModCore.CoreMonitor.Log("THIS IS MY LOCATION!!!: " +loc.name);
if (loc.isObjectAt((int)pos.X, (int)pos.Y))
{
ModCore.CoreMonitor.Log("F!: " + loc.name, LogLevel.Warn);
continue;
}
if (loc.isTileOccupied(pos / Game1.tileSize))
{
ModCore.CoreMonitor.Log("K!!!!: " + loc.name, LogLevel.Error);
continue;
}
if (loc.isTilePlaceable(pos) == false)
{
ModCore.CoreMonitor.Log("C!!!!: " + loc.name, LogLevel.Error);
continue;
}
if (loc.isTilePlaceable(pos / Game1.tileSize) == false)
{
ModCore.CoreMonitor.Log("J!!!!: " + loc.name, LogLevel.Error);
continue;
}
if (loc.isTilePassable(new Rectangle(xPos, yPos, Game1.tileSize, Game1.tileSize), Game1.viewport) == true && loc.isTileLocationOpen(new xTile.Dimensions.Location((int)(pos.X), (int)(pos.Y))) == true && loc.isObjectAt((int)(pos.X), (int)(pos.Y)) == false) ; //&& Game1.currentLocation.isTileLocationOpen(new xTile.Dimensions.Location((int)startPosition.X+x,(int)startPosition.Y+y)))
{
//TileNode child = new TileNode(1, Vector2.Zero, this.texturePath, this.drawColor);
//child.placementAction(Game1.currentLocation, xPos, yPos);
//this.children.Add(child);
}
}
}
}
public override string Name
@ -84,8 +244,15 @@ namespace StarAI.PathFindingCore
/// <param name="isRemovable"></param>
/// <param name="price"></param>
/// <param name="isSolid"></param>
public TileNode(int which, Vector2 tile, string ObjectTexture, bool isRemovable = true, int price = 0, bool isSolid = false)
public TileNode(int which, Vector2 tile, string ObjectTexture, Color DrawColor, bool isRemovable = true, int price = 0, bool isSolid = false,int Cost=1)
{
this.cost = Cost;
Color c=DrawColor;
if (c == null)
{
c = StardustCore.IlluminateFramework.ColorsList.White;
}
this.drawColor = c;
removable = isRemovable;
this.serializationName = Convert.ToString(GetType());
@ -133,10 +300,17 @@ namespace StarAI.PathFindingCore
}
public TileNode(int which, Vector2 tile, string ObjectTexture, string DataPath, bool isRemovable = true, bool isSolid = false)
public TileNode(int which, Vector2 tile, string ObjectTexture, string DataPath, Color DrawColor, bool isRemovable = true, bool isSolid = false,int Cost=1)
{
try
{
this.cost = Cost;
Color c = DrawColor;
if (c == null)
{
c = StardustCore.IlluminateFramework.ColorsList.White;
}
this.drawColor = c;
this.serializationName = Convert.ToString(GetType());
removable = isRemovable;
// this.thisType = GetType();
@ -617,16 +791,16 @@ namespace StarAI.PathFindingCore
{
if (animationManager == null)
{
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
spriteBatch.Draw(this.TextureSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), this.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
}
else
{
spriteBatch.Draw(this.TextureSheet, objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
spriteBatch.Draw(this.TextureSheet, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
}
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
{
spriteBatch.Draw(this.TextureSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
spriteBatch.Draw(this.TextureSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(Game1.currentLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), this.drawColor, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
{
return;
@ -644,13 +818,13 @@ namespace StarAI.PathFindingCore
{
try
{
if (animationManager == null) spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth);
if (animationManager == null) spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), this.drawColor * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth);
else
{
spriteBatch.Draw(animationManager.objectTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth);
spriteBatch.Draw(animationManager.objectTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), this.drawColor * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * (3) * scaleSize, SpriteEffects.None, layerDepth);
//this.modularCrop.drawInMenu(spriteBatch, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), Color.White, 0f,true);
//this.modularCrop.drawInMenu(spriteBatch, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.drawColor, 0f,true);
if (Game1.player.CurrentItem != this) animationManager.tickAnimation();
}
@ -670,7 +844,7 @@ namespace StarAI.PathFindingCore
{
if (x == -1)
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
}
else
@ -678,14 +852,14 @@ namespace StarAI.PathFindingCore
//The actual planter box being drawn.
if (animationManager == null)
{
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
spriteBatch.Draw(TextureSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
}
else
{
//Log.AsyncC("Animation Manager is working!");
spriteBatch.Draw(animationManager.objectTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
spriteBatch.Draw(animationManager.objectTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
try
{
this.animationManager.tickAnimation();
@ -697,7 +871,7 @@ namespace StarAI.PathFindingCore
}
}
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), this.drawColor, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
if (this.heldObject != null)
{
@ -706,8 +880,8 @@ namespace StarAI.PathFindingCore
(this.heldObject as TileNode).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject as TileNode).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
return;
}
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), this.drawColor * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.heldObject.ParentSheetIndex)), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
}
@ -725,7 +899,7 @@ namespace StarAI.PathFindingCore
{
try
{
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
spriteBatch.Draw(TextureSheet, location, new Rectangle?(this.sourceRect), this.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
}
catch(Exception err)
{
@ -739,8 +913,8 @@ namespace StarAI.PathFindingCore
{
try
{
if (this.dataPath == "") return new TileNode(this.parentSheetIndex, this.tileLocation, this.texturePath, this.removable, this.price, this.IsSolid);
else return new TileNode(this.parentSheetIndex, this.tileLocation, this.texturePath, this.dataPath, this.removable, this.IsSolid);
if (this.dataPath == "") return new TileNode(this.parentSheetIndex, this.tileLocation, this.texturePath,this.drawColor, this.removable, this.price, this.IsSolid);
else return new TileNode(this.parentSheetIndex, this.tileLocation, this.texturePath, this.dataPath,this.drawColor, this.removable, this.IsSolid);
}
catch (Exception err)
{
@ -865,7 +1039,7 @@ namespace StarAI.PathFindingCore
dynamic obj1 = q;
string name = Convert.ToString(obj1.currentAnimationName);
int frame = Convert.ToInt32(obj1.currentAnimationListIndex);
TileNode dummy = new TileNode(d.parentSheetIndex, d.tileLocation, d.texturePath, d.dataPath, d.removable, d.IsSolid);
TileNode dummy = new TileNode(d.parentSheetIndex, d.tileLocation, d.texturePath, d.dataPath,d.drawColor, d.removable, d.IsSolid);
d.animationManager = dummy.animationManager;
bool f = d.animationManager.setAnimation(name, frame);
bool f2;

View File

@ -57,7 +57,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ModCore.cs" />
<Compile Include="PathFindingCore\TileNode.cs" />
<Compile Include="PathFindingCore\PathFindingLogic.cs" />
<Compile Include="PathFindingCore\TileNodeObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -11,5 +11,11 @@
"Description": "An AI assignment but for stardew.",
"UniqueID": "Omegasis.StarAI",
"EntryDll": "StarAI.dll",
"UpdateKeys": [ "" ]
"UpdateKeys": [""],
"Dependencies": [
{
"UniqueID": "Omegasis.StardustCore",
"IsRequired": true
}
]
}