From cafdfa1d42dd7c42ea7e7673cab3c361eb6068cb Mon Sep 17 00:00:00 2001 From: Terkoiz Date: Fri, 19 Apr 2024 18:13:14 +0300 Subject: [PATCH] Initial commit - version 1.0.0 --- .gitignore | 376 ++++++++++++++++++ LICENSE | 31 ++ README.md | 14 + project/NuGet.Config | 14 + project/References/EFT_Managed/.keep | 0 project/Terkoiz.Skipper.sln | 25 ++ .../QuestObjectiveViewPatch.cs | 84 ++++ project/Terkoiz.Skipper/SkipperPlugin.cs | 34 ++ .../Terkoiz.Skipper/Terkoiz.Skipper.csproj | 58 +++ 9 files changed, 636 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 project/NuGet.Config create mode 100644 project/References/EFT_Managed/.keep create mode 100644 project/Terkoiz.Skipper.sln create mode 100644 project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs create mode 100644 project/Terkoiz.Skipper/SkipperPlugin.cs create mode 100644 project/Terkoiz.Skipper/Terkoiz.Skipper.csproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c6a0c3b --- /dev/null +++ b/.gitignore @@ -0,0 +1,376 @@ +# Custom ignores +project/References/EFT_Managed/* + +# Allow these files, despite the rules above +!project/References/EFT_Managed/.keep + +# ---> VisualStudio +## 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 + +project/Terkoiz.Freecam/key.snk + +# 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 +.idea +Freecam.sln.DotSettings.user +Project/.idea/ +Project/Shared/* + +# 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 + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..987f06d --- /dev/null +++ b/LICENSE @@ -0,0 +1,31 @@ +# NCSA Open Source License + +Copyright (c) 2024 Terkoiz. All rights reserved. + +Developed by: Terkoiz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +with the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimers. + +* Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimers in the documentation +and/or other materials provided with the distribution. + +* Neither the names of Terkoiz, nor the names of +its contributors may be used to endorse or promote products derived from +this Software without specific prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS WITH THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..61b314f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Skipper + +A BepInEx plugin for SPT-AKI that allows you to skip quests in-game. + +### How to install + +1. Download the latest release here: [link](https://dev.sp-tarkov.com/Terkoiz/Skipper/releases) -OR- build from source (instructions below) +2. Simply extract the zip file contents into your root SPT-AKI folder (where EscapeFromTarkov.exe is) +3. Your `BepInEx/plugins` folder should now contain a `Terkoiz.Skipper.dll` file inside + +1. Download/clone this repository +2. Open your current SPT directory and copy all files from `\EscapeFromTarkov_Data\Managed` into this solution's `\References\EFT_Managed` folder. +3. Rebuild the project in the Release configuration. +4. Grab the `Terkoiz.Skipper.dll` file from the `bin/Release` folder and use it wherever. Refer to the "How to install" section if you need help here. \ No newline at end of file diff --git a/project/NuGet.Config b/project/NuGet.Config new file mode 100644 index 0000000..da1fd08 --- /dev/null +++ b/project/NuGet.Config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/project/References/EFT_Managed/.keep b/project/References/EFT_Managed/.keep new file mode 100644 index 0000000..e69de29 diff --git a/project/Terkoiz.Skipper.sln b/project/Terkoiz.Skipper.sln new file mode 100644 index 0000000..5f1e513 --- /dev/null +++ b/project/Terkoiz.Skipper.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terkoiz.Skipper", "Terkoiz.Skipper\Terkoiz.Skipper.csproj", "{9C38A2B1-5F09-49FE-AC57-9FBEF7717582}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {26F91A8D-3767-457A-821C-F66AFD620885} + EndGlobalSection +EndGlobal diff --git a/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs b/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs new file mode 100644 index 0000000..d4a3895 --- /dev/null +++ b/project/Terkoiz.Skipper/QuestObjectiveViewPatch.cs @@ -0,0 +1,84 @@ +using System.Linq; +using System.Reflection; +using Aki.Reflection.Patching; +using EFT; +using EFT.Quests; +using EFT.UI; +using HarmonyLib; +using JetBrains.Annotations; +using UnityEngine; + +namespace Terkoiz.Skipper +{ + public class QuestObjectiveViewPatch : ModulePatch + { + private static string UnderlyingQuestControllerClassName; + + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(QuestObjectiveView), nameof(QuestObjectiveView.Show)); + } + + [PatchPostfix] + private static void PatchPostfix([CanBeNull]DefaultUIButton ____handoverButton, AbstractQuestControllerClass questController, Condition condition, IConditionCounter quest) + { + if (!SkipperPlugin.ModEnabled.Value) + { + return; + } + + // The handover button is usually only missing in the non-trader task view screens, where we don't want to allow skipping either way + if (____handoverButton == null) + { + return; + } + + if (UnderlyingQuestControllerClassName == null) + { + var type = AccessTools.GetTypesFromAssembly(typeof(AbstractGame).Assembly) + .SingleOrDefault(t => t.GetEvent("OnConditionQuestTimeExpired", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance) != null); + + if (type == null) + { + SkipperPlugin.Logger.LogError("Failed to locate a specific quest controller type"); + return; + } + + UnderlyingQuestControllerClassName = type.Name.Split('`')[0]; + SkipperPlugin.Logger.LogDebug($"Resolved {nameof(UnderlyingQuestControllerClassName)} to be {UnderlyingQuestControllerClassName}"); + } + + var skipButton = Object.Instantiate(____handoverButton, ____handoverButton.transform.parent.transform); + + skipButton.SetRawText("SKIP", 22); + skipButton.gameObject.name = "SkipButton"; + skipButton.gameObject.GetComponent().minWidth = 100f; + skipButton.gameObject.SetActive(!quest.IsConditionDone(condition)); + + skipButton.OnClick.RemoveAllListeners(); + skipButton.OnClick.AddListener(() => ItemUiContext.Instance.ShowMessageWindow( + description: "Are you sure you want to autocomplete this quest objective?", + acceptAction: () => + { + if (quest.IsConditionDone(condition)) + { + skipButton.gameObject.SetActive(false); + return; + } + + SkipperPlugin.Logger.LogDebug($"Setting condition {condition.id} value to {condition.value}"); + + // This line will force any condition checker to pass, as the 'condition.value' field contains the "goal" of any quest condition + quest.ProgressCheckers[condition].SetCurrentValueGetter(_ => condition.value); + + // We call 'SetConditionCurrentValue' to trigger all the code needed to make the condition completion appear visually in-game + var conditionController = AccessTools.Field(questController.GetType(), $"{UnderlyingQuestControllerClassName.ToLowerInvariant()}_0").GetValue(questController); + AccessTools.DeclaredMethod(conditionController.GetType().BaseType, "SetConditionCurrentValue").Invoke(conditionController, new object[] { quest, EQuestStatus.AvailableForFinish, condition, condition.value, true }); + + skipButton.gameObject.SetActive(false); + }, + cancelAction: () => {}, + caption: "Confirmation")); + } + } +} \ No newline at end of file diff --git a/project/Terkoiz.Skipper/SkipperPlugin.cs b/project/Terkoiz.Skipper/SkipperPlugin.cs new file mode 100644 index 0000000..ba57b12 --- /dev/null +++ b/project/Terkoiz.Skipper/SkipperPlugin.cs @@ -0,0 +1,34 @@ +using BepInEx; +using BepInEx.Configuration; +using BepInEx.Logging; +using JetBrains.Annotations; + +namespace Terkoiz.Skipper +{ + [BepInPlugin("com.terkoiz.skipper", "Terkoiz.Skipper", "1.0.0")] + public class SkipperPlugin : BaseUnityPlugin + { + internal new static ManualLogSource Logger { get; private set; } + + private const string MainSectionName = "Main"; + internal static ConfigEntry ModEnabled; + + [UsedImplicitly] + internal void Start() + { + Logger = base.Logger; + InitConfiguration(); + + new QuestObjectiveViewPatch().Enable(); + } + + private void InitConfiguration() + { + ModEnabled = Config.Bind( + MainSectionName, + "Enabled", + true, + "Global mod toggle. Will need to re-open the quest window for the setting change to take effect."); + } + } +} diff --git a/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj b/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj new file mode 100644 index 0000000..07c3c56 --- /dev/null +++ b/project/Terkoiz.Skipper/Terkoiz.Skipper.csproj @@ -0,0 +1,58 @@ + + + + net471 + 1.0.0 + Terkoiz + + + + + runtime + + + + + + ..\References\EFT_Managed\Aki.Reflection.dll + False + + + ..\References\EFT_Managed\Assembly-CSharp.dll + False + + + ..\References\EFT_Managed\Comfort.dll + False + + + ..\References\EFT_Managed\Comfort.Unity.dll + False + + + ..\References\EFT_Managed\Sirenix.Serialization.dll + False + + + ..\References\EFT_Managed\Unity.TextMeshPro.dll + False + + + ..\References\EFT_Managed\UnityEngine.dll + False + + + ..\References\EFT_Managed\UnityEngine.CoreModule.dll + False + + + ..\References\EFT_Managed\UnityEngine.InputLegacyModule.dll + False + + + ..\References\EFT_Managed\UnityEngine.UI.dll + False + + + +