diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index 14cce674..5eef2d12 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -1,15 +1,10 @@ { "Name": "Auto Speed", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Got to go fast!", "UniqueID": "Omegasis.AutoSpeed", "EntryDll": "AutoSpeed.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:443" ] } diff --git a/GeneralMods/BillboardAnywhere/manifest.json b/GeneralMods/BillboardAnywhere/manifest.json index fb131f8d..3dee7105 100644 --- a/GeneralMods/BillboardAnywhere/manifest.json +++ b/GeneralMods/BillboardAnywhere/manifest.json @@ -1,15 +1,10 @@ { "Name": "Billboard Anywhere", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Lets you view the billboard from anywhere.", "UniqueID": "Omegasis.BillboardAnywhere", "EntryDll": "BillboardAnywhere.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:492" ] } diff --git a/GeneralMods/BuildEndurance/manifest.json b/GeneralMods/BuildEndurance/manifest.json index a3751db4..33897c2b 100644 --- a/GeneralMods/BuildEndurance/manifest.json +++ b/GeneralMods/BuildEndurance/manifest.json @@ -1,15 +1,10 @@ { "Name": "Build Endurance", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildEndurance", "EntryDll": "BuildEndurance.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:445" ] } diff --git a/GeneralMods/BuildHealth/manifest.json b/GeneralMods/BuildHealth/manifest.json index 1645b030..9333b38e 100644 --- a/GeneralMods/BuildHealth/manifest.json +++ b/GeneralMods/BuildHealth/manifest.json @@ -1,15 +1,10 @@ { "Name": "Build Health", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildHealth", "EntryDll": "BuildHealth.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:446" ] } diff --git a/GeneralMods/BuyBackCollectables/manifest.json b/GeneralMods/BuyBackCollectables/manifest.json index 3b36fc9a..c1b70ba2 100644 --- a/GeneralMods/BuyBackCollectables/manifest.json +++ b/GeneralMods/BuyBackCollectables/manifest.json @@ -1,15 +1,10 @@ { "Name": "Buy Back Collectables", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Lets you buy back any obtained collectable.", "UniqueID": "Omegasis.BuyBackCollectables", "EntryDll": "BuyBackCollectables.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:507" ] } diff --git a/GeneralMods/CustomShopsRedux/manifest.json b/GeneralMods/CustomShopsRedux/manifest.json index 82e22db1..deff5333 100644 --- a/GeneralMods/CustomShopsRedux/manifest.json +++ b/GeneralMods/CustomShopsRedux/manifest.json @@ -1,15 +1,10 @@ { "Name": "Custom Shop Redux GUI", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "A nice way to make custom shops.", "UniqueID": "Omegasis.CustomShopReduxGui", "EntryDll": "CustomShopsRedux.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:1378" ] } diff --git a/GeneralMods/DailyQuestAnywhere/manifest.json b/GeneralMods/DailyQuestAnywhere/manifest.json index 77853411..faaaefa9 100644 --- a/GeneralMods/DailyQuestAnywhere/manifest.json +++ b/GeneralMods/DailyQuestAnywhere/manifest.json @@ -1,15 +1,10 @@ { "Name": "Daily Quest Anywhere", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Open the daily quest board from anywhere in the game.", "UniqueID": "Omegasis.DailyQuestAnywhere", "EntryDll": "DailyQuestAnywhere.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:513" ] } diff --git a/GeneralMods/Fall28SnowDay/manifest.json b/GeneralMods/Fall28SnowDay/manifest.json index d6b5107b..cd1457ca 100644 --- a/GeneralMods/Fall28SnowDay/manifest.json +++ b/GeneralMods/Fall28SnowDay/manifest.json @@ -1,15 +1,10 @@ { "Name": "Fall 28 Snow Day", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.", "UniqueID": "Omegasis.Fall28SnowDay", "EntryDll": "Fall28SnowDay.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:486" ] } diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index a0bdcd84..2cffb970 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -11,5 +11,6 @@ "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", "EntryDll": "HappyBirthday.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:520" ] } diff --git a/GeneralMods/MoreRain/manifest.json b/GeneralMods/MoreRain/manifest.json index ad3e69fa..eaf789f3 100644 --- a/GeneralMods/MoreRain/manifest.json +++ b/GeneralMods/MoreRain/manifest.json @@ -1,15 +1,10 @@ { "Name": "More Rain", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 5, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.5.1", "Description": "Change how much it rains in the game.", "UniqueID": "Omegasis.MoreRain", "EntryDll": "MoreRain.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:441" ] } diff --git a/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs index f18c3185..dcef035a 100644 --- a/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs +++ b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs @@ -17,7 +17,7 @@ namespace Omegasis.MuseumRearranger.Framework private bool ShowInventory = true; /// A reference to a private field for use in the overridden draw code. - private readonly IPrivateField HoldingMuseumPiece; + private readonly IReflectedField HoldingMuseumPiece; /********* @@ -27,7 +27,7 @@ namespace Omegasis.MuseumRearranger.Framework /// Simplifies access to private game code. public NewMuseumMenu(IReflectionHelper reflection) { - this.HoldingMuseumPiece = reflection.GetPrivateField(this, "holdingMuseumPiece"); + this.HoldingMuseumPiece = reflection.GetField(this, "holdingMuseumPiece"); } /// Toggle the inventory box. diff --git a/GeneralMods/MuseumRearranger/manifest.json b/GeneralMods/MuseumRearranger/manifest.json index 358f4460..f6f9d609 100644 --- a/GeneralMods/MuseumRearranger/manifest.json +++ b/GeneralMods/MuseumRearranger/manifest.json @@ -1,15 +1,10 @@ { "Name": "Museum Rearranger", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Lets you rearrange the museum without needing to donate something.", "UniqueID": "Omegasis.MuseumRearranger", "EntryDll": "MuseumRearranger.dll", + "MinimumApiVersion": "2.3", "UpdateKeys": [ "Nexus:428" ] } diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index dcfb3114..37fa292e 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -1,15 +1,10 @@ { "Name": "Night Owl", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Lets you stay up all night.", "UniqueID": "Omegasis.NightOwl", "EntryDll": "NightOwl.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:433" ] } diff --git a/GeneralMods/NoMorePets/manifest.json b/GeneralMods/NoMorePets/manifest.json index b361a65a..aed0a4e9 100644 --- a/GeneralMods/NoMorePets/manifest.json +++ b/GeneralMods/NoMorePets/manifest.json @@ -1,15 +1,10 @@ { "Name": "No More Pets", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Removes all pets from the game.", "UniqueID": "Omegasis.NoMorePets", "EntryDll": "NoMorePets.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:506" ] } diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.cs b/GeneralMods/SaveAnywhere/SaveAnywhere.cs index 74e895f5..649c90d0 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.cs +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.cs @@ -215,7 +215,7 @@ namespace Omegasis.SaveAnywhere int endFacingDir = Convert.ToInt32(fields[4]); schedulePathDescription = this.Helper.Reflection - .GetPrivateMethod(npc, "pathfindToNextScheduleLocation") + .GetMethod(npc, "pathfindToNextScheduleLocation") .Invoke(npc.currentLocation.name, npc.getTileX(), npc.getTileY(), endMap, x, y, endFacingDir, null, null); index++; } @@ -274,14 +274,14 @@ namespace Omegasis.SaveAnywhere if ((npc.name.Equals("Penny") && (dayName.Equals("Tue") || dayName.Equals("Wed") || dayName.Equals("Fri"))) || (npc.name.Equals("Maru") && (dayName.Equals("Tue") || dayName.Equals("Thu"))) || (npc.name.Equals("Harvey") && (dayName.Equals("Tue") || dayName.Equals("Thu")))) { this.Helper.Reflection - .GetPrivateField(npc, "nameofTodaysSchedule") + .GetField(npc, "nameofTodaysSchedule") .SetValue("marriageJob"); return "marriageJob"; } if (!Game1.isRaining && schedule.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth))) { this.Helper.Reflection - .GetPrivateField(npc, "nameofTodaysSchedule") + .GetField(npc, "nameofTodaysSchedule") .SetValue("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)); return "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth); } diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index 0e6e3f38..6e5cd1f0 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -1,15 +1,10 @@ { "Name": "Save Anywhere", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 2, - "MinorVersion": 6, - "PatchVersion": 2, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "2.6.2", "Description": "Lets you save almost anywhere.", "UniqueID": "Omegasis.SaveAnywhere", "EntryDll": "SaveAnywhere.dll", + "MinimumApiVersion": "2.3", "UpdateKeys": [ "Nexus:444" ] } diff --git a/GeneralMods/SaveBackup/manifest.json b/GeneralMods/SaveBackup/manifest.json index 60a38c32..f4a680d1 100644 --- a/GeneralMods/SaveBackup/manifest.json +++ b/GeneralMods/SaveBackup/manifest.json @@ -1,15 +1,10 @@ { "Name": "Save Backup", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 3, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.3.1", "Description": "Backs up your save files at regular intervals.", "UniqueID": "Omegasis.SaveBackup", "EntryDll": "SaveBackup.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:435" ] } diff --git a/GeneralMods/SimpleSoundManager/manifest.json b/GeneralMods/SimpleSoundManager/manifest.json index 1040a456..d11b436a 100644 --- a/GeneralMods/SimpleSoundManager/manifest.json +++ b/GeneralMods/SimpleSoundManager/manifest.json @@ -1,15 +1,10 @@ { "Name": "Simple Sound Manager", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 0, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.0.1", "Description": "A simple framework to play sounds from wave banks.", "UniqueID": "Omegasis.SimpleSoundManager", "EntryDll": "SimpleSoundManager.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:1410" ] } diff --git a/GeneralMods/StardewSymphony/manifest.json b/GeneralMods/StardewSymphony/manifest.json index 44af2454..af9642e0 100644 --- a/GeneralMods/StardewSymphony/manifest.json +++ b/GeneralMods/StardewSymphony/manifest.json @@ -1,15 +1,10 @@ { "Name": "Stardew Symphony", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.4.1", "Description": "Adding more music to the game one beep at a time.", "UniqueID": "Omegasis.StardewSymphony", "EntryDll": "StardewSymphony.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:425" ] } diff --git a/GeneralMods/StardustCore/ModInfo/MetaData.cs b/GeneralMods/StardustCore/ModInfo/MetaData.cs index c903d436..81fc6ec4 100644 --- a/GeneralMods/StardustCore/ModInfo/MetaData.cs +++ b/GeneralMods/StardustCore/ModInfo/MetaData.cs @@ -55,7 +55,7 @@ namespace StardustCore.ModInfo { // if (Game1.activeClickableMenu.allClickableComponents == null) return; try { - List pages = ModCore.ModHelper.Reflection.GetPrivateValue>(Game1.activeClickableMenu, "pages"); + List pages = ModCore.ModHelper.Reflection.GetField>(Game1.activeClickableMenu, "pages").GetValue(); if (Game1.activeClickableMenu is GameMenu) { StardewValley.Menus.IClickableMenu s = pages[(Game1.activeClickableMenu as GameMenu).currentTab]; diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index f1d7482d..7337f01c 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -1,15 +1,10 @@ { "Name": "StardustCore", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 2, - "MinorVersion": 0, - "PatchVersion": 0, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "2.0.0", "Description": "A core mod that allows for other mods to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll", - "UpdateKeys": [""] + "MinimumApiVersion": "2.3", + "UpdateKeys": [] } diff --git a/GeneralMods/TimeFreeze/manifest.json b/GeneralMods/TimeFreeze/manifest.json index 18d9099d..341cfbd7 100644 --- a/GeneralMods/TimeFreeze/manifest.json +++ b/GeneralMods/TimeFreeze/manifest.json @@ -1,15 +1,10 @@ { "Name": "Time Freeze", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 2, - "PatchVersion": 1, - "Build": null - }, - "MinimumApiVersion": "1.15", + "Version": "1.2.1", "Description": "Emulates old Harvest Moon-style games where time is frozen inside.", "UniqueID": "Omegasis.TimeFreeze", "EntryDll": "TimeFreeze.dll", + "MinimumApiVersion": "2.0", "UpdateKeys": [ "Nexus:973" ] } diff --git a/StarAI/StarAI/StarAI/ExecutionCore/CustomTask.cs b/StarAI/StarAI/StarAI/ExecutionCore/CustomTask.cs index 1a76a7a9..68c2c5b7 100644 --- a/StarAI/StarAI/StarAI/ExecutionCore/CustomTask.cs +++ b/StarAI/StarAI/StarAI/ExecutionCore/CustomTask.cs @@ -1,4 +1,5 @@ -using System; +using StarAI.PathFindingCore; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,11 +18,19 @@ namespace StarAI.ExecutionCore public VoidTask voidTask; public TaskMetaData taskMetaData; + + /// + /// Create a custom task and calculate cost of the action automatically without having to pass cost to the meta data. Saves a lot of code space and memory. + /// + /// + /// + /// public CustomTask(ObjectTask objTask,object[] arrayData, TaskMetaData TaskMetaData) { objectTask = objTask; objectParameterDataArray = arrayData; this.taskMetaData = TaskMetaData; + this.taskMetaData.calculateTaskCost((TileNode)arrayData[0]); } public CustomTask(VoidTask vTask, TaskMetaData TaskMetaData) diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskList.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskList.cs index 3dba0aec..a6976d1a 100644 --- a/StarAI/StarAI/StarAI/ExecutionCore/TaskList.cs +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskList.cs @@ -1,4 +1,5 @@ -using StardewModdingAPI; +using StarAI.PathFindingCore; +using StardewModdingAPI; using System; using System.Collections.Generic; using System.Linq; @@ -28,7 +29,9 @@ namespace StarAI.ExecutionCore foreach(var task2 in taskList) { if (removalList.Contains(task2)) continue; - task2.taskMetaData.cost = PathFindingCore.Utilities.calculatePathCost(task2.objectParameterDataArray); + object[] oArray = (object[])task2.objectParameterDataArray; + TileNode t =(TileNode) oArray[0]; + task2.taskMetaData.calculateTaskCost((t)); //task.taskMetaData = new TaskMetaData(task.taskMetaData.name, PathFindingCore.Utilities.calculatePathCost(task.objectParameterDataArray), task.taskMetaData.staminaPrerequisite, task.taskMetaData.toolPrerequisite); } diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaData.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaData.cs index 65d0d5ed..e26a5ad7 100644 --- a/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaData.cs +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaData.cs @@ -1,4 +1,5 @@ -using System; +using StarAI.PathFindingCore; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -15,10 +16,13 @@ namespace StarAI.ExecutionCore public float frequency; public StarAI.ExecutionCore.TaskPrerequisites.StaminaPrerequisite staminaPrerequisite; public StarAI.ExecutionCore.TaskPrerequisites.ToolPrerequisite toolPrerequisite; + public TaskPrerequisites.InventoryFullPrerequisite inventoryPrerequisite; + + public TaskPrerequisites.BedTimePrerequisite bedTimePrerequisite; public List prerequisitesList; - public TaskMetaData(string Name, float Priority, float Cost, float Utility, float Frequency, TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite=null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite=null) + public TaskMetaData(string Name, float Priority, float Cost, float Utility, float Frequency, TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite=null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite=null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull = null, TaskPrerequisites.BedTimePrerequisite BedTimePrereq=null) { this.name = Name; this.priority = Priority; @@ -27,35 +31,72 @@ namespace StarAI.ExecutionCore this.frequency = Frequency; this.staminaPrerequisite = StaminaPrerequisite; this.toolPrerequisite = ToolPrerequisite; - + this.inventoryPrerequisite = InventoryFull; + this.bedTimePrerequisite = BedTimePrereq; //Make sure to set values correctly incase of null setUpStaminaPrerequisiteIfNull(); setUpToolPrerequisiteIfNull(); + setUpInventoryPrerequisiteIfNull(); + setUpBedTimeIfNull(); this.prerequisitesList = new List(); this.prerequisitesList.Add(this.staminaPrerequisite); this.prerequisitesList.Add(this.toolPrerequisite); + this.prerequisitesList.Add(this.inventoryPrerequisite); + + this.prerequisitesList.Add(this.bedTimePrerequisite); } - public TaskMetaData(string Name,float Cost,TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite = null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite = null) + public TaskMetaData(string Name,float Cost,TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite = null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite = null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull = null,TaskPrerequisites.BedTimePrerequisite BedTimePrereq=null) { this.name = Name; this.cost = Cost; this.staminaPrerequisite = StaminaPrerequisite; this.toolPrerequisite = ToolPrerequisite; + this.inventoryPrerequisite = InventoryFull; + this.bedTimePrerequisite = BedTimePrereq; //Make sure to set values correctly incase of null setUpStaminaPrerequisiteIfNull(); setUpToolPrerequisiteIfNull(); + setUpInventoryPrerequisiteIfNull(); + setUpBedTimeIfNull(); this.prerequisitesList = new List(); this.prerequisitesList.Add(this.staminaPrerequisite); this.prerequisitesList.Add(this.toolPrerequisite); + this.prerequisitesList.Add(this.inventoryPrerequisite); + this.prerequisitesList.Add(this.bedTimePrerequisite); + } + + public TaskMetaData(string Name, TaskPrerequisites.StaminaPrerequisite StaminaPrerequisite = null, TaskPrerequisites.ToolPrerequisite ToolPrerequisite = null, TaskPrerequisites.InventoryFullPrerequisite InventoryFull=null,TaskPrerequisites.BedTimePrerequisite bedTimePrereq=null) + { + this.name = Name; + this.staminaPrerequisite = StaminaPrerequisite; + this.toolPrerequisite = ToolPrerequisite; + this.inventoryPrerequisite = InventoryFull; + + this.bedTimePrerequisite = bedTimePrereq; + //Make sure to set values correctly incase of null + setUpStaminaPrerequisiteIfNull(); + setUpToolPrerequisiteIfNull(); + setUpInventoryPrerequisiteIfNull(); + setUpBedTimeIfNull(); + this.prerequisitesList = new List(); + this.prerequisitesList.Add(this.staminaPrerequisite); + this.prerequisitesList.Add(this.toolPrerequisite); + this.prerequisitesList.Add(this.inventoryPrerequisite); + this.prerequisitesList.Add(this.bedTimePrerequisite); + } + + public void calculateTaskCost(TileNode source) + { + this.cost=TaskMetaDataHeuristics.calculateTaskCost(source, this.toolPrerequisite); } private void setUpToolPrerequisiteIfNull() { if (this.toolPrerequisite == null) { - this.toolPrerequisite = new TaskPrerequisites.ToolPrerequisite(false, null); + this.toolPrerequisite = new TaskPrerequisites.ToolPrerequisite(false, null,0); } } private void setUpStaminaPrerequisiteIfNull() @@ -66,6 +107,16 @@ namespace StarAI.ExecutionCore } } + private void setUpInventoryPrerequisiteIfNull() + { + if (this.inventoryPrerequisite == null) this.inventoryPrerequisite = new TaskPrerequisites.InventoryFullPrerequisite(false); + } + + private void setUpBedTimeIfNull() + { + if (this.bedTimePrerequisite == null) this.bedTimePrerequisite = new TaskPrerequisites.BedTimePrerequisite(true); + } + public bool verifyAllPrerequisitesHit() { @@ -87,7 +138,8 @@ namespace StarAI.ExecutionCore if(this.staminaPrerequisite.requiresStamina==true) s += " Requires : " + this.staminaPrerequisite.staminaCost + "Stamina.\n"; s += " Task Requires Tool: " + this.toolPrerequisite.requiresTool + "\n"; if (this.toolPrerequisite.requiresTool == true) s += " Requires a : " + this.toolPrerequisite.requiredTool + "\n"; - + s += " Task Requires Tool: " + this.toolPrerequisite.requiresTool + "\n"; + s += " Checks if inventory full: "+this.inventoryPrerequisite.doesTaskRequireInventorySpace.ToString() + "\n"; ModCore.CoreMonitor.Log(s); } diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaDataHeuristics.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaDataHeuristics.cs new file mode 100644 index 00000000..3253e34d --- /dev/null +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskMetaDataHeuristics.cs @@ -0,0 +1,74 @@ +using StarAI.ExecutionCore.TaskPrerequisites; +using StarAI.PathFindingCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StarAI.ExecutionCore +{ + /// + /// This will be used to determine how much any given action, pathing distance, etc will have on the overall cost of a given task. + /// + public class TaskMetaDataHeuristics + { + + /// + /// Multiplier to be used to multiply out pathCost on any given action. Higher numbers will mean more discrimination against actions with long manhattan distances. + /// + public static int pathCostMultiplier=1; + /// + /// This is a dictionary that holds the action cost for every tool when it is used. + /// + public static Dictionary toolCostDictionary = new Dictionary(); + + /// + /// Used to set the values at the beginning. + /// + public static void initializeToolCostDictionary() + { + toolCostDictionary.Add(typeof(StardewValley.Tools.WateringCan), 2); + toolCostDictionary.Add(typeof(StardewValley.Tools.Axe), 4); + toolCostDictionary.Add(typeof(StardewValley.Tools.Pickaxe), 3); + toolCostDictionary.Add(typeof(StardewValley.Tools.FishingRod), 5); + toolCostDictionary.Add(typeof(StardewValley.Tools.Hoe), 2); + toolCostDictionary.Add(typeof(StardewValley.Tools.MeleeWeapon), 1); + toolCostDictionary.Add(typeof(StardewValley.Tools.Sword), 1); + } + + /// + /// Used to assign a weight to using a tool a single time. + /// + /// + /// + public static int parseToolCostMultiplier(TaskPrerequisites.ToolPrerequisite t) + { + Type tool = t.requiredTool; + int value=2; + bool f = toolCostDictionary.TryGetValue(tool,out value); + if (f == true) return value; + else return 2; + } + + /// + /// Used to calculate the weight of using a tool to add to the overall cost of a TaskMetaData cost. + /// + /// + /// + /// + public static int calculateToolCostMultiplier(TaskPrerequisites.ToolPrerequisite t) + { + if (t.requiresTool == false || t.requiredTool==null) return 0; //Default tool not used. + return (parseToolCostMultiplier(t) * t.estimatedNumberOfUses); + } + + public static float calculateTaskCost(TileNode v,ToolPrerequisite t) + { + float pathCost= StarAI.PathFindingCore.Utilities.calculatePathCost(v) * pathCostMultiplier; + float toolCost = calculateToolCostMultiplier(t); + return (pathCost + toolCost); + } + + } +} diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/BedTimePrerequisite.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/BedTimePrerequisite.cs new file mode 100644 index 00000000..200a8672 --- /dev/null +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/BedTimePrerequisite.cs @@ -0,0 +1,56 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StarAI.ExecutionCore.TaskPrerequisites +{ + public class BedTimePrerequisite : GenericPrerequisite + { + + public bool checkIfEnoughTimeRemaining; + public BedTimePrerequisite(bool CheckForBedtime) + { + this.checkIfEnoughTimeRemaining = CheckForBedtime; + } + + public int timeRemainingInDay() + { + int passOutTime = 2600; + return passOutTime - Game1.timeOfDay; + } + + /// + /// The default here will give you 2 hrs which should be enough for bedTime. + /// + /// + public bool enoughTimeToDoTask() + { + int timeRemaining = timeRemainingInDay(); + if (timeRemaining > 200) return true; + else return false; + } + + public bool enoughTimeToDoTask(int timeToDoTask) + { + int timeRemaining = timeRemainingInDay(); + if (timeRemaining > timeToDoTask) return true; + else return false; + } + + public override bool checkAllPrerequisites() + { + if (this.checkIfEnoughTimeRemaining == false) return true; + if (enoughTimeToDoTask()) return true; + else + { + ModCore.CoreMonitor.Log("Not enough time remaining in the day. You should go home."); + //Add functionality here to return home. + return false; + } + } + + } +} diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/InventoryFullPrerequisite.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/InventoryFullPrerequisite.cs new file mode 100644 index 00000000..e9118f37 --- /dev/null +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/InventoryFullPrerequisite.cs @@ -0,0 +1,39 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StarAI.ExecutionCore.TaskPrerequisites +{ + /// + /// Weirdly enough this will be empty because it's just a placeholder prerequisite. Doesn't need to hold any more data since the player will always have an updated inventory. + /// + public class InventoryFullPrerequisite:GenericPrerequisite + { + public bool doesTaskRequireInventorySpace; + public InventoryFullPrerequisite(bool RequiresInventorySpace) + { + this.doesTaskRequireInventorySpace = RequiresInventorySpace; + } + + public bool isPlayerInventoryFull() + { + + return Game1.player.isInventoryFull(); + } + + public override bool checkAllPrerequisites() + { + if (this.doesTaskRequireInventorySpace == false) return true; + if (isPlayerInventoryFull() == false) return true; + else//player inventory is full + { + ModCore.CoreMonitor.Log("Player inventory is full failed the task prerequisite"); + return false; + } + } + + } +} diff --git a/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ToolPrerequisite.cs b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ToolPrerequisite.cs index 570c0388..45a5480e 100644 --- a/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ToolPrerequisite.cs +++ b/StarAI/StarAI/StarAI/ExecutionCore/TaskPrerequisites/ToolPrerequisite.cs @@ -11,17 +11,23 @@ namespace StarAI.ExecutionCore.TaskPrerequisites { public bool requiresTool; public Type requiredTool; + public int estimatedNumberOfUses; - public ToolPrerequisite(bool TaskNeedsTool, Type RequiredTool) + public ToolPrerequisite(bool TaskNeedsTool, Type RequiredTool, int EstimatedNumberOfUses) { requiresTool = TaskNeedsTool; requiredTool = RequiredTool; + this.estimatedNumberOfUses = EstimatedNumberOfUses; verifyToolSetUp(); } public void verifyToolSetUp() { - if (requiresTool == false) requiredTool = null; + if (requiresTool == false) + { + requiredTool = null; + estimatedNumberOfUses = 0; + } } public bool isToolInInventory() diff --git a/StarAI/StarAI/StarAI/ModCore.cs b/StarAI/StarAI/StarAI/ModCore.cs index 691cbfe0..18514c91 100644 --- a/StarAI/StarAI/StarAI/ModCore.cs +++ b/StarAI/StarAI/StarAI/ModCore.cs @@ -37,6 +37,7 @@ namespace StarAI CoreMonitor.Log("Hello AI WORLD!", LogLevel.Info); Commands.initializeCommands(); PathFindingCore.Utilities.initializeTileExceptionList(); + ExecutionCore.TaskMetaDataHeuristics.initializeToolCostDictionary(); //throw new NotImplementedException(); StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; diff --git a/StarAI/StarAI/StarAI/PathFindingCore/ChestLogic.cs b/StarAI/StarAI/StarAI/PathFindingCore/ChestLogic.cs index 533054a2..a0d953bf 100644 --- a/StarAI/StarAI/StarAI/PathFindingCore/ChestLogic.cs +++ b/StarAI/StarAI/StarAI/PathFindingCore/ChestLogic.cs @@ -61,7 +61,7 @@ namespace StarAI.PathFindingCore object[] objList = new object[1]; objList[0] = v; // ExecutionCore.TaskList.taskList.Add(new Task(new Action(waterSingleCrop), obj)); - ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(pathToSingleChest, objList,new ExecutionCore.TaskMetaData("Path to chest for seeds",PathFindingCore.Utilities.calculatePathCost(v)))); + ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(pathToSingleChest, objList,new ExecutionCore.TaskMetaData("Path to chest for seeds",null,null,new ExecutionCore.TaskPrerequisites.InventoryFullPrerequisite(true)))); // waterSingleCrop(v); } } diff --git a/StarAI/StarAI/StarAI/PathFindingCore/CropLogic/CropLogic.cs b/StarAI/StarAI/StarAI/PathFindingCore/CropLogic/CropLogic.cs index 2dc18702..b7da991d 100644 --- a/StarAI/StarAI/StarAI/PathFindingCore/CropLogic/CropLogic.cs +++ b/StarAI/StarAI/StarAI/PathFindingCore/CropLogic/CropLogic.cs @@ -49,7 +49,7 @@ namespace StarAI.PathFindingCore.CropLogic obj[0] = v; // ExecutionCore.TaskList.taskList.Add(new Task(new Action(waterSingleCrop), obj)); StardewValley.Tools.WateringCan w = new StardewValley.Tools.WateringCan(); - ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(waterSingleCrop, obj,new ExecutionCore.TaskMetaData("Water Crop",PathFindingCore.Utilities.calculatePathCost(v),new StaminaPrerequisite(true,3),new ToolPrerequisite(true,w.GetType())))); + ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(waterSingleCrop, obj,new ExecutionCore.TaskMetaData("Water Crop", new StaminaPrerequisite(true,3),new ToolPrerequisite(true,w.GetType(),1)))); // waterSingleCrop(v); } } @@ -271,7 +271,7 @@ namespace StarAI.PathFindingCore.CropLogic object[] obj = new object[1]; obj[0] = v; //ExecutionCore.TaskList.taskList.Add(new Task(new Action(harvestSingleCrop), obj)); - ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(harvestSingleCrop, obj,new ExecutionCore.TaskMetaData("HarvestSingleCrop",StarAI.PathFindingCore.Utilities.calculatePathCost(v)))); + ExecutionCore.TaskList.taskList.Add(new ExecutionCore.CustomTask(harvestSingleCrop, obj,new ExecutionCore.TaskMetaData("HarvestSingleCrop",null,null,new ExecutionCore.TaskPrerequisites.InventoryFullPrerequisite(true)))); // waterSingleCrop(v); } diff --git a/StarAI/StarAI/StarAI/PathFindingCore/TileNodeObject.cs b/StarAI/StarAI/StarAI/PathFindingCore/TileNodeObject.cs index c3d30f74..6e633445 100644 --- a/StarAI/StarAI/StarAI/PathFindingCore/TileNodeObject.cs +++ b/StarAI/StarAI/StarAI/PathFindingCore/TileNodeObject.cs @@ -7,6 +7,7 @@ using StardewValley; using StardewValley.Locations; using StardewValley.Menus; using StardewValley.Objects; +using StardewValley.TerrainFeatures; using StardustCore; using StardustCore.Animations; using System; @@ -65,7 +66,7 @@ namespace StarAI.PathFindingCore public TileNode parent; - public static bool checkIfICanPlaceHere(TileNode t, Vector2 pos, GameLocation loc = null, bool checkForCrops=false) + public static bool checkIfICanPlaceHere(TileNode t, Vector2 pos, GameLocation loc = null, bool checkForPassableTerrainFeatures = true) { bool cry = false; if (t.thisLocation == null) @@ -74,23 +75,7 @@ namespace StarAI.PathFindingCore cry = true; } - if (checkForCrops == true) - { - if (t.thisLocation.isTerrainFeatureAt((int)pos.X, (int)pos.Y)) - { - StardewValley.TerrainFeatures.TerrainFeature terrain = t.thisLocation.terrainFeatures[t.tileLocation]; - if (terrain != null) - { - if (terrain is StardewValley.TerrainFeatures.HoeDirt) - { - if ((terrain as StardewValley.TerrainFeatures.HoeDirt).crop != null) - { - return true; - } - } - } - } - } + if (t == null) { Console.WriteLine("OK T IS NULL"); @@ -99,12 +84,26 @@ namespace StarAI.PathFindingCore { Console.WriteLine("OK T LOCATION IS NULL"); } + + if (t.thisLocation.isObjectAt((int)pos.X, (int)pos.Y)) { - //ModCore.CoreMonitor.Log("Object at this tile position!: " + t.thisLocation.name, LogLevel.Warn); + //ModCore.CoreMonitor.Log("Object at this tile position!: " + t.thisLocation.objects[new Vector2(pos.X/Game1.tileSize,pos.Y/Game1.tileSize)].name, LogLevel.Warn); if (cry == true) t.thisLocation = null; return false; } + + + + if (checkForPassableTerrainFeatures) + { + bool terrainFeature = t.thisLocation.terrainFeatures.ContainsKey(pos / Game1.tileSize); + if (terrainFeature) + { + TerrainFeature terrain = t.thisLocation.terrainFeatures[pos / Game1.tileSize]; + if (terrain.isPassable()) return true; + } + } if (t.thisLocation.isTileOccupied(pos / Game1.tileSize)) { // ModCore.CoreMonitor.Log("Tile occupied!: " + t.thisLocation.name, LogLevel.Error); diff --git a/StarAI/StarAI/StarAI/StarAI.csproj b/StarAI/StarAI/StarAI/StarAI.csproj index f220b72d..288d364b 100644 --- a/StarAI/StarAI/StarAI/StarAI.csproj +++ b/StarAI/StarAI/StarAI/StarAI.csproj @@ -60,7 +60,10 @@ + + +