Merge branch 'master' into Development

This commit is contained in:
janavarro95 2018-02-02 18:31:35 -08:00 committed by GitHub
commit 930d982972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 319 additions and 166 deletions

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -17,7 +17,7 @@ namespace Omegasis.MuseumRearranger.Framework
private bool ShowInventory = true;
/// <summary>A reference to a private <see cref="MuseumMenu"/> field for use in the overridden draw code.</summary>
private readonly IPrivateField<bool> HoldingMuseumPiece;
private readonly IReflectedField<bool> HoldingMuseumPiece;
/*********
@ -27,7 +27,7 @@ namespace Omegasis.MuseumRearranger.Framework
/// <param name="reflection">Simplifies access to private game code.</param>
public NewMuseumMenu(IReflectionHelper reflection)
{
this.HoldingMuseumPiece = reflection.GetPrivateField<bool>(this, "holdingMuseumPiece");
this.HoldingMuseumPiece = reflection.GetField<bool>(this, "holdingMuseumPiece");
}
/// <summary>Toggle the inventory box.</summary>

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -215,7 +215,7 @@ namespace Omegasis.SaveAnywhere
int endFacingDir = Convert.ToInt32(fields[4]);
schedulePathDescription = this.Helper.Reflection
.GetPrivateMethod(npc, "pathfindToNextScheduleLocation")
.GetMethod(npc, "pathfindToNextScheduleLocation")
.Invoke<SchedulePathDescription>(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<string>(npc, "nameofTodaysSchedule")
.GetField<string>(npc, "nameofTodaysSchedule")
.SetValue("marriageJob");
return "marriageJob";
}
if (!Game1.isRaining && schedule.ContainsKey("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth)))
{
this.Helper.Reflection
.GetPrivateField<string>(npc, "nameofTodaysSchedule")
.GetField<string>(npc, "nameofTodaysSchedule")
.SetValue("marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth));
return "marriage_" + Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth);
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -55,7 +55,7 @@ namespace StardustCore.ModInfo
{
// if (Game1.activeClickableMenu.allClickableComponents == null) return;
try {
List<IClickableMenu> pages = ModCore.ModHelper.Reflection.GetPrivateValue<List<IClickableMenu>>(Game1.activeClickableMenu, "pages");
List<IClickableMenu> pages = ModCore.ModHelper.Reflection.GetField<List<IClickableMenu>>(Game1.activeClickableMenu, "pages").GetValue();
if (Game1.activeClickableMenu is GameMenu)
{
StardewValley.Menus.IClickableMenu s = pages[(Game1.activeClickableMenu as GameMenu).currentTab];

View File

@ -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": []
}

View File

@ -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" ]
}

View File

@ -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;
/// <summary>
/// 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.
/// </summary>
/// <param name="objTask"></param>
/// <param name="arrayData"></param>
/// <param name="TaskMetaData"></param>
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)

View File

@ -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);
}

View File

@ -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<TaskPrerequisites.GenericPrerequisite> 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<TaskPrerequisites.GenericPrerequisite>();
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<TaskPrerequisites.GenericPrerequisite>();
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<TaskPrerequisites.GenericPrerequisite>();
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);
}

View File

@ -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
{
/// <summary>
/// This will be used to determine how much any given action, pathing distance, etc will have on the overall cost of a given task.
/// </summary>
public class TaskMetaDataHeuristics
{
/// <summary>
/// Multiplier to be used to multiply out pathCost on any given action. Higher numbers will mean more discrimination against actions with long manhattan distances.
/// </summary>
public static int pathCostMultiplier=1;
/// <summary>
/// This is a dictionary that holds the action cost for every tool when it is used.
/// </summary>
public static Dictionary<Type, int> toolCostDictionary = new Dictionary<Type, int>();
/// <summary>
/// Used to set the values at the beginning.
/// </summary>
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);
}
/// <summary>
/// Used to assign a weight to using a tool a single time.
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
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;
}
/// <summary>
/// Used to calculate the weight of using a tool to add to the overall cost of a TaskMetaData cost.
/// </summary>
/// <param name="t"></param>
/// <param name="numberOfTimesToolIsUsed"></param>
/// <returns></returns>
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);
}
}
}

View File

@ -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;
}
/// <summary>
/// The default here will give you 2 hrs which should be enough for bedTime.
/// </summary>
/// <returns></returns>
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;
}
}
}
}

View File

@ -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
{
/// <summary>
/// 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.
/// </summary>
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;
}
}
}
}

View File

@ -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()

View File

@ -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;

View File

@ -61,7 +61,7 @@ namespace StarAI.PathFindingCore
object[] objList = new object[1];
objList[0] = v;
// ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(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);
}
}

View File

@ -49,7 +49,7 @@ namespace StarAI.PathFindingCore.CropLogic
obj[0] = v;
// ExecutionCore.TaskList.taskList.Add(new Task(new Action<object>(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<object>(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);
}

View File

@ -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);

View File

@ -60,7 +60,10 @@
<Compile Include="ExecutionCore\CustomTask.cs" />
<Compile Include="ExecutionCore\TaskList.cs" />
<Compile Include="ExecutionCore\TaskMetaData.cs" />
<Compile Include="ExecutionCore\TaskMetaDataHeuristics.cs" />
<Compile Include="ExecutionCore\TaskPrerequisites\BedTimePrerequisite.cs" />
<Compile Include="ExecutionCore\TaskPrerequisites\GenericPrerequisite.cs" />
<Compile Include="ExecutionCore\TaskPrerequisites\InventoryFullPrerequisite.cs" />
<Compile Include="ExecutionCore\TaskPrerequisites\StaminaPrerequisite.cs" />
<Compile Include="ExecutionCore\TaskPrerequisites\ToolPrerequisite.cs" />
<Compile Include="ModCore.cs" />