-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,392 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
using HarmonyLib; | ||
using Microsoft.Xna.Framework.Graphics; | ||
using StardewModdingAPI; | ||
using StardewValley; | ||
using StardewValley.ItemTypeDefinitions; | ||
using StardewValley.Objects; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection.Emit; | ||
|
||
namespace SinZational_Science_Showcase | ||
{ | ||
public class ModEntry : Mod | ||
{ | ||
public override void Entry(IModHelper helper) | ||
{ | ||
//helper.Events.Input.ButtonReleased += Input_ButtonReleased; | ||
var harmony = new Harmony(ModManifest.UniqueID); | ||
harmony.Patch(AccessTools.Method(typeof(Hat), nameof(Hat.draw)), transpiler: new HarmonyMethod(typeof(HarmonyPatches).GetMethod(nameof(HarmonyPatches.Hat__Draw__Transpiler)))); | ||
} | ||
|
||
/* | ||
private void Input_ButtonReleased(object sender, StardewModdingAPI.Events.ButtonReleasedEventArgs e) | ||
{ | ||
if (!Context.IsWorldReady) return; | ||
if (Game1.activeClickableMenu != null) return; | ||
if (e.Button != SButton.F5) return; | ||
var coop = Game1.getFarm().buildings.Where(b => b.buildingType.Value == "Deluxe Coop").First(); | ||
var coopInterior = coop.indoors.Value as AnimalHouse; | ||
var autoGrabber = coopInterior.objects.Values.Where(o => o.QualifiedItemId == "(BC)165").First(); | ||
var autoGrabberStorage = autoGrabber.heldObject.Value as Chest; | ||
var dayCounter = 0; | ||
var season = Game1.season; | ||
do | ||
{ | ||
Monitor.Log($"Day: {Game1.stats.DaysPlayed} ({season} {Game1.dayOfMonth}), Duck Feather count: {autoGrabberStorage.Items.CountId("(O)444")}, Rabbits Feet count: {autoGrabberStorage.Items.CountId("(O)446")}", LogLevel.Info); | ||
Game1.stats.DaysPlayed++; | ||
Game1.dayOfMonth++; | ||
if (Game1.dayOfMonth > 28) | ||
{ | ||
Game1.dayOfMonth = 1; | ||
season++; | ||
if (season > Season.Winter) | ||
{ | ||
season = Season.Spring; | ||
} | ||
} | ||
Game1.getFarm().tryToAddHay(20); | ||
foreach (var animal in coopInterior.animals.Values) | ||
{ | ||
animal.wasPet.Value = true; | ||
// Eating outside | ||
if (season != Season.Winter) | ||
{ | ||
animal.friendshipTowardFarmer.Value += 8; | ||
} | ||
} | ||
coopInterior.DayUpdate((int)((Game1.stats.DaysPlayed % 28) + 1)); | ||
if (dayCounter++ > 1000) | ||
{ | ||
Monitor.Log("After 1000 simulations, did not show??", LogLevel.Warn); | ||
autoGrabber.checkForAction(Game1.player); | ||
break; | ||
} | ||
} | ||
while (autoGrabberStorage.Items.CountId("(O)444") == 0); | ||
} | ||
*/ | ||
|
||
} | ||
|
||
public static class HarmonyPatches | ||
{ | ||
public static IEnumerable<CodeInstruction> Hat__Draw__Transpiler(ILGenerator generator, IEnumerable<CodeInstruction> instructions) | ||
{ | ||
var output = new List<CodeInstruction>(); | ||
var skipCount = 0; | ||
foreach (var instruction in instructions) | ||
{ | ||
if (skipCount-- > 0) continue; | ||
/* | ||
* Replace the following | ||
* IL_001f: ldsfld class StardewValley.LocalizedContentManager StardewValley.Game1::content | ||
* IL_0024: ldstr "Characters\\Farmer\\hats_animals" | ||
* IL_0029: callvirt instance !!0 StardewValley.LocalizedContentManager::Load<class [MonoGame.Framework]Microsoft.Xna.Framework.Graphics.Texture2D>(string) | ||
* with | ||
* ldloc_0 | ||
* call HarmonyPatches::Hat__Draw__GetAnimalHat | ||
*/ | ||
if (instruction.opcode == OpCodes.Ldsfld) | ||
{ | ||
var load = new CodeInstruction(OpCodes.Ldloc_0) | ||
{ | ||
labels = instruction.labels | ||
}; | ||
output.Add(load); | ||
output.Add(new CodeInstruction(OpCodes.Call, typeof(HarmonyPatches).GetMethod(nameof(Hat__Draw__GetAnimalHat)))); | ||
skipCount = 2; | ||
continue; | ||
} | ||
output.Add(instruction); | ||
} | ||
return output; | ||
} | ||
|
||
public static Texture2D Hat__Draw__GetAnimalHat(ParsedItemData itemData) | ||
{ | ||
var rawData = itemData.RawData as string[]; | ||
ArgUtility.TryGetOptional(rawData, 8, out var textureName, out _, itemData.TextureName); | ||
if (textureName == "Characters\\Farmer\\hats") | ||
{ | ||
textureName = "Characters\\Farmer\\hats_animals"; | ||
} | ||
return Game1.content.Load<Texture2D>(textureName); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
SinZational Science Showcase/SinZational Science Showcase.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>SinZational_Science_Showcase</RootNamespace> | ||
<EnableHarmony>true</EnableHarmony> | ||
<GamePath>C:\Users\acerP\Downloads\depotdownloader-2.4.7\stardew1.6-beta</GamePath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="cp\*"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.1.1" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Format": "1.28.0", | ||
"Changes": [ | ||
{ | ||
"Action": "EditData", | ||
"Target": "Data/Achievements", | ||
"Fields": { | ||
"1": { | ||
"0": "Achievement name" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"Name": "SinZational Science Showcase", | ||
"Author": "SinZ", | ||
"Version": "0.1.0-alpha", | ||
"Description": "Visualizes Schedule information on the map to assist NPC creators", | ||
"UniqueID": "SinZ.Science", | ||
"EntryDll": "SinZational Science Showcase.dll", | ||
"MinimumApiVersion": "3.0.0", | ||
"UpdateKeys": [ "Nexus:-1" ], | ||
"Dependencies": [ | ||
{ | ||
"UniqueID": "Pathoschild.ContentPatcher", | ||
"IsRequired": false | ||
} | ||
] | ||
} |
Oops, something went wrong.