diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..86a2b20 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..65beab1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,78 @@ +name: Build + +permissions: + contents: write + +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + inputs: + should_release: + description: "Create release?" + required: true + default: false + type: boolean + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup MAPI + uses: BadMagic100/setup-hk@v2 + with: + apiPath: API + #dependencyFilePath: ouchyGrass/ModDependencies.txt + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build -c Release + + - name: Prepare artifacts for release + uses: actions/upload-artifact@v4 + with: + name: Publish + path: ouchyGrass/bin/Publish + release: + needs: + - build + runs-on: windows-latest + # only make a release if we manually request the build - other builds will be handled automatically with a push + if: github.event_name == 'workflow_dispatch' && github.event.inputs.should_release == 'true' + steps: + - name: Download Artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + - name: Get build details + id: details + # this assumes that an MSBuild task that writes the SHA256 of the zip file to SHA.txt, and the mod version (usually + # the same as the assembly version) to version.txt. The contents of these files are read to step outputs for use in release + run: | + $sha = Get-Content artifacts/Publish/SHA.txt + $ver = Get-Content artifacts/Publish/VERSION.txt + echo "archiveHash=$sha" >> $env:GITHUB_OUTPUT + echo "buildVersion=$ver" >> $env:GITHUB_OUTPUT + - name: Release + uses: softprops/action-gh-release@v2 + with: + draft: false + generate_release_notes: true + fail_on_unmatched_files: true + tag_name: v${{ steps.details.outputs.buildVersion }} + body: | + SHA256: ${{ steps.details.outputs.archiveHash }} + files: | + artifacts/Publish/ouchyGrass.zip diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21b2a13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,364 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +LocalOverrides.targets \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..433e462 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# ouchyGrass + +A Hollow Knight mod that makes grass deadly. +Inspired by various grass themed playthroughs diff --git a/ouchyGrass.cs b/ouchyGrass.cs new file mode 100644 index 0000000..74dcc7c --- /dev/null +++ b/ouchyGrass.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using Modding; +using UnityEngine; + +namespace ouchyGrass +{ + public class ouchyGrassMod : Mod, IMenuMod + { + private static ouchyGrassMod? _instance; + new public string GetName() => "OuchyGrass"; + + public bool damagePlayer => true; // boolean that determines wether to damage or kill player when touching grass + private FieldInfo isCutField; + + + private bool instakill = false ; + private bool invincibleGrass = false; // variable that determines wether grass can be destroyed or not. + public List GetMenuData(IMenuMod.MenuEntry? toggleButtonEntry) + { + return new List + { + new IMenuMod.MenuEntry { + Name = "Damage / instakill", + Description = "Touching grass will deal damage or kill instantly.", + Values = new string[] { + "Damage", + "Instakill" + }, + // opt will be the index of the option that has been chosen + Saver = opt => this.instakill = opt switch { + 0 => false, + 1 => true, + // This should never be called + _ => throw new InvalidOperationException() + }, + Loader = () => this.instakill switch { + false => 0, + true => 1, + } + }, + new IMenuMod.MenuEntry { + Name = "Invincible grass", + Description ="Determines wether grass can be cut" , + Values = new string[] { + "Off", + "On" + }, + Saver = opt => this.invincibleGrass = opt switch { + 0 => false, + 1 => true, + // This should never be called + _ => throw new InvalidOperationException() + }, + Loader = () => this.invincibleGrass switch { + false => 0, + true => 1, + } + } + }; + } + + + internal static ouchyGrassMod Instance + { + get + { + if (_instance == null) + { + throw new InvalidOperationException($"An instance of {nameof(ouchyGrassMod)} was never constructed"); + } + return _instance; + } + } + + public bool ToggleButtonInsideMenu => throw new NotImplementedException(); + + public override string GetVersion() => GetType().Assembly.GetName().Version.ToString(); + + public ouchyGrassMod() : base("ouchyGrass") + { + _instance = this; + } + + public override void Initialize() + { + On.GrassBehaviour.OnTriggerEnter2D += GrassReact_OnTriggerEnter2D; + On.GrassCut.ShouldCut += GrassCut_ShouldCut; + isCutField = typeof(GrassBehaviour).GetField("isCut", BindingFlags.NonPublic | BindingFlags.Instance); + } + public void Unload() + { + On.GrassCut.ShouldCut -= GrassCut_ShouldCut; + On.GrassBehaviour.OnTriggerEnter2D -= GrassReact_OnTriggerEnter2D; + } + + // hook to determine grass indestructability + private bool GrassCut_ShouldCut(On.GrassCut.orig_ShouldCut orig, Collider2D collision) + { + // Only allow grass cutting if this is true + if (this.invincibleGrass) + { + return false; + } + + // Otherwise use original logic + return orig(collision); + } + + private void GrassReact_OnTriggerEnter2D(On.GrassBehaviour.orig_OnTriggerEnter2D orig, GrassBehaviour self, Collider2D collision) + { + // Call original method first + orig(self, collision); + bool isCut = (bool)isCutField.GetValue(self); + + + if (collision.tag == "Player" && !PlayerData.instance.isInvincible &&!isCut) + { + if (!this.instakill) + { + HeroController.instance.TakeDamage(HeroController.instance.gameObject, GlobalEnums.CollisionSide.other, 1, 2); + } + if (this.instakill) // kills player + { + HeroController.instance.TakeDamage(HeroController.instance.gameObject, GlobalEnums.CollisionSide.other, 100, 2); + } + } + + + + } + } + } + diff --git a/ouchyGrass.csproj b/ouchyGrass.csproj new file mode 100644 index 0000000..eeb8bec --- /dev/null +++ b/ouchyGrass.csproj @@ -0,0 +1,334 @@ + + + + ouchyGrass + ouchyGrass + net472 + ouchyGrass + ouchyGrass + A Hollow Knight mod that... + Copyright © RedRonin 2024 + RedRonin + 7035 + 0.1.* + false + bin\$(Configuration)\ + latest + enable + ..\API + bin\Publish + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(HollowKnightRefs)/Assembly-CSharp.dll + + + $(HollowKnightRefs)/Assembly-CSharp-firstpass.dll + + + $(HollowKnightRefs)/GalaxyCSharp.dll + + + $(HollowKnightRefs)/MMHOOK_Assembly-CSharp.dll + + + $(HollowKnightRefs)/MMHOOK_PlayMaker.dll + + + $(HollowKnightRefs)/Mono.Cecil.dll + + + $(HollowKnightRefs)/Mono.Security.dll + + + $(HollowKnightRefs)/MonoMod.RuntimeDetour.dll + + + $(HollowKnightRefs)/MonoMod.Utils.dll + + + $(HollowKnightRefs)/netstandard.dll + + + $(HollowKnightRefs)/Newtonsoft.Json.dll + + + $(HollowKnightRefs)/PlayMaker.dll + + + $(HollowKnightRefs)/System.ComponentModel.Composition.dll + + + $(HollowKnightRefs)/System.Configuration.dll + + + $(HollowKnightRefs)/System.Diagnostics.StackTrace.dll + + + $(HollowKnightRefs)/System.EnterpriseServices.dll + + + $(HollowKnightRefs)/System.Globalization.Extensions.dll + + + $(HollowKnightRefs)/System.IO.Compression.dll + + + $(HollowKnightRefs)/System.Net.Http.dll + + + $(HollowKnightRefs)/System.Runtime.Serialization.Xml.dll + + + $(HollowKnightRefs)/System.ServiceModel.Internals.dll + + + $(HollowKnightRefs)/System.Transactions.dll + + + $(HollowKnightRefs)/System.Xml.XPath.XDocument.dll + + + $(HollowKnightRefs)/Unity.Timeline.dll + + + $(HollowKnightRefs)/UnityEngine.dll + + + $(HollowKnightRefs)/UnityEngine.AccessibilityModule.dll + + + $(HollowKnightRefs)/UnityEngine.AIModule.dll + + + $(HollowKnightRefs)/UnityEngine.AndroidJNIModule.dll + + + $(HollowKnightRefs)/UnityEngine.AnimationModule.dll + + + $(HollowKnightRefs)/UnityEngine.ARModule.dll + + + $(HollowKnightRefs)/UnityEngine.AssetBundleModule.dll + + + $(HollowKnightRefs)/UnityEngine.AudioModule.dll + + + $(HollowKnightRefs)/UnityEngine.ClothModule.dll + + + $(HollowKnightRefs)/UnityEngine.ClusterInputModule.dll + + + $(HollowKnightRefs)/UnityEngine.ClusterRendererModule.dll + + + $(HollowKnightRefs)/UnityEngine.CoreModule.dll + + + $(HollowKnightRefs)/UnityEngine.CrashReportingModule.dll + + + $(HollowKnightRefs)/UnityEngine.DirectorModule.dll + + + $(HollowKnightRefs)/UnityEngine.DSPGraphModule.dll + + + $(HollowKnightRefs)/UnityEngine.GameCenterModule.dll + + + $(HollowKnightRefs)/UnityEngine.GIModule.dll + + + $(HollowKnightRefs)/UnityEngine.GridModule.dll + + + $(HollowKnightRefs)/UnityEngine.HotReloadModule.dll + + + $(HollowKnightRefs)/UnityEngine.ImageConversionModule.dll + + + $(HollowKnightRefs)/UnityEngine.IMGUIModule.dll + + + $(HollowKnightRefs)/UnityEngine.InputLegacyModule.dll + + + $(HollowKnightRefs)/UnityEngine.InputModule.dll + + + $(HollowKnightRefs)/UnityEngine.JSONSerializeModule.dll + + + $(HollowKnightRefs)/UnityEngine.LocalizationModule.dll + + + $(HollowKnightRefs)/UnityEngine.ParticleSystemModule.dll + + + $(HollowKnightRefs)/UnityEngine.PerformanceReportingModule.dll + + + $(HollowKnightRefs)/UnityEngine.Physics2DModule.dll + + + $(HollowKnightRefs)/UnityEngine.PhysicsModule.dll + + + $(HollowKnightRefs)/UnityEngine.ProfilerModule.dll + + + $(HollowKnightRefs)/UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + + + $(HollowKnightRefs)/UnityEngine.ScreenCaptureModule.dll + + + $(HollowKnightRefs)/UnityEngine.SharedInternalsModule.dll + + + $(HollowKnightRefs)/UnityEngine.SpriteMaskModule.dll + + + $(HollowKnightRefs)/UnityEngine.SpriteShapeModule.dll + + + $(HollowKnightRefs)/UnityEngine.StreamingModule.dll + + + $(HollowKnightRefs)/UnityEngine.SubstanceModule.dll + + + $(HollowKnightRefs)/UnityEngine.SubsystemsModule.dll + + + $(HollowKnightRefs)/UnityEngine.TerrainModule.dll + + + $(HollowKnightRefs)/UnityEngine.TerrainPhysicsModule.dll + + + $(HollowKnightRefs)/UnityEngine.TextCoreModule.dll + + + $(HollowKnightRefs)/UnityEngine.TextRenderingModule.dll + + + $(HollowKnightRefs)/UnityEngine.TilemapModule.dll + + + $(HollowKnightRefs)/UnityEngine.TLSModule.dll + + + $(HollowKnightRefs)/UnityEngine.UI.dll + + + $(HollowKnightRefs)/UnityEngine.UIElementsModule.dll + + + $(HollowKnightRefs)/UnityEngine.UIElementsNativeModule.dll + + + $(HollowKnightRefs)/UnityEngine.UIModule.dll + + + $(HollowKnightRefs)/UnityEngine.UmbraModule.dll + + + $(HollowKnightRefs)/UnityEngine.UNETModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityAnalyticsModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityConnectModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityCurlModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityTestProtocolModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityWebRequestAssetBundleModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityWebRequestAudioModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityWebRequestModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityWebRequestTextureModule.dll + + + $(HollowKnightRefs)/UnityEngine.UnityWebRequestWWWModule.dll + + + $(HollowKnightRefs)/UnityEngine.VehiclesModule.dll + + + $(HollowKnightRefs)/UnityEngine.VFXModule.dll + + + $(HollowKnightRefs)/UnityEngine.VideoModule.dll + + + $(HollowKnightRefs)/UnityEngine.VirtualTexturingModule.dll + + + $(HollowKnightRefs)/UnityEngine.VRModule.dll + + + $(HollowKnightRefs)/UnityEngine.WindModule.dll + + + $(HollowKnightRefs)/UnityEngine.XRModule.dll + + + + + + + + + + diff --git a/ouchyGrass.sln b/ouchyGrass.sln new file mode 100644 index 0000000..ad7e5cc --- /dev/null +++ b/ouchyGrass.sln @@ -0,0 +1,29 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35527.113 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ouchyGrass", "ouchyGrass.csproj", "{F0B4C26D-0F4C-411B-8945-FB97BD088EC6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{2FFBDBAB-0C19-4FD7-A551-7175E167655A}" + ProjectSection(SolutionItems) = preProject + .github\workflows\build.yml = .github\workflows\build.yml + .github\dependabot.yml = .github\dependabot.yml + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F0B4C26D-0F4C-411B-8945-FB97BD088EC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F0B4C26D-0F4C-411B-8945-FB97BD088EC6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0B4C26D-0F4C-411B-8945-FB97BD088EC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F0B4C26D-0F4C-411B-8945-FB97BD088EC6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal