initial commit - prototype
This commit is contained in:
+8
-1
@@ -51,4 +51,11 @@ CodeCoverage/
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
nunit-*.xml
|
||||
|
||||
.idea/
|
||||
|
||||
.user
|
||||
.config/
|
||||
*.DotSettings
|
||||
*.user
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.5.002.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5C123AC3-ACF6-48C8-B344-3907B42C7B69}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterBugphobia", "src\BetterBugphobia\BetterBugphobia.csproj", "{E69F6D87-9F83-4108-8E24-58FE8F482BF0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E69F6D87-9F83-4108-8E24-58FE8F482BF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E69F6D87-9F83-4108-8E24-58FE8F482BF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E69F6D87-9F83-4108-8E24-58FE8F482BF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E69F6D87-9F83-4108-8E24-58FE8F482BF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{E69F6D87-9F83-4108-8E24-58FE8F482BF0} = {5C123AC3-ACF6-48C8-B344-3907B42C7B69}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {92F6D475-68F0-44D6-A1AF-A28F5948E381}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,3 @@
|
||||
# Changelog
|
||||
|
||||
TODO: You can follow this format for your changelog: <https://keepachangelog.com/en/1.1.0/>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Set if the default steam game install directory doesn't work. -->
|
||||
<!-- <PeakGameRootDir></PeakGameRootDir> -->
|
||||
<!-- Set if your BepInEx/plugins/ directory isn't in the game files. -->
|
||||
<!-- <PeakPluginsDir></PeakPluginsDir> -->
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="DeployFiles" AfterTargets="Build">
|
||||
<Message Text="Deploy → $(PeakPluginsDir)$(AssemblyName).dll" Importance="High" />
|
||||
<Error
|
||||
Text="Plugins directory '$([MSBuild]::NormalizeDirectory($(PeakPluginsDir)))' doesn't exist! Configure PeakPluginsDir to point to a valid path in the Config.Build.user.props file."
|
||||
Condition="!Exists('$(PeakPluginsDir)')"
|
||||
/>
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PeakPluginsDir)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Set if the default steam game install directory doesn't work. -->
|
||||
<!-- <PeakGameRootDir></PeakGameRootDir> -->
|
||||
<!-- Set if your BepInEx/plugins/ directory isn't in the game files. -->
|
||||
<!-- <PeakPluginsDir></PeakPluginsDir> -->
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="DeployFiles" AfterTargets="Build">
|
||||
<Message Text="Deploy → $(PeakPluginsDir)$(AssemblyName).dll" Importance="High" />
|
||||
<Error
|
||||
Text="Plugins directory '$([MSBuild]::NormalizeDirectory($(PeakPluginsDir)))' doesn't exist! Configure PeakPluginsDir to point to a valid path in the Config.Build.user.props file."
|
||||
Condition="!Exists('$(PeakPluginsDir)')"
|
||||
/>
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(PeakPluginsDir)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
<Project>
|
||||
<!--
|
||||
This is a special file that contains shared configuration
|
||||
for all project files in subdirectories.
|
||||
-->
|
||||
|
||||
<!-- Import our shared user configuration file -->
|
||||
<Import
|
||||
Project="$(SolutionRoot)Config.Build.user.props"
|
||||
Condition="Exists('$(SolutionRoot)Config.Build.user.props')"
|
||||
/>
|
||||
|
||||
<!-- Primary configuration for the project -->
|
||||
<PropertyGroup>
|
||||
<!-- Use latest C# version. -->
|
||||
<LangVersion>latest</LangVersion>
|
||||
<!-- See: https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references -->
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- Build, and other generated files go nicely into artifacts/ directory. -->
|
||||
<UseArtifactsOutput>true</UseArtifactsOutput>
|
||||
<!-- Enable debug symbols. This will show source code line numbers in stack traces. -->
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<!-- Substitute full path to this directory with ./, hiding it from debug symbols. -->
|
||||
<PathMap>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))=./</PathMap>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Custom props -->
|
||||
<PropertyGroup>
|
||||
<!-- Define a variable that points to this directory. -->
|
||||
<SolutionRoot>$(MSBuildThisFileDirectory)</SolutionRoot>
|
||||
<!-- Default values for game files. -->
|
||||
<PathBeforeSteam Condition="'$([MSBuild]::IsOSUnixLike())' == 'true'">$(HOME)/.local/share/</PathBeforeSteam>
|
||||
<PathBeforeSteam Condition="'$([MSBuild]::IsOSUnixLike())' != 'true'">$(MSBuildProgramFiles32)/</PathBeforeSteam>
|
||||
<PeakGameRootDir Condition="$(PeakGameRootDir) == ''">$(PathBeforeSteam)Steam/steamapps/common/PEAK/</PeakGameRootDir>
|
||||
<PeakPluginsDir Condition="$(PeakPluginsDir) == ''">$(PeakGameRootDir)/BepInEx/plugins/</PeakPluginsDir>
|
||||
<ManagedDir>$(PeakGameRootDir)/PEAK_Data/Managed/</ManagedDir>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,60 @@
|
||||
<Project>
|
||||
<!--
|
||||
This is a special file that contains shared configuration
|
||||
for all project files in subdirectories.
|
||||
-->
|
||||
|
||||
<!-- Set extra NuGet sources -->
|
||||
<PropertyGroup>
|
||||
<RestoreAdditionalProjectSources>
|
||||
https://nuget.bepinex.dev/v3/index.json;
|
||||
https://nuget.windows10ce.com/nuget/v3/index.json
|
||||
</RestoreAdditionalProjectSources>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Modding dependencies -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BepInEx.Core" Version="5.4.21" />
|
||||
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
|
||||
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Hamunii.BepInEx.AutoPlugin" Version="2.0.*" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- NuGet fallback stripped game references -->
|
||||
<ItemGroup Condition="!Exists('$(ManagedDir)')">
|
||||
<PackageReference Include="UnityEngine.Modules" Version="6000.0.36" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Local game references -->
|
||||
<ItemGroup Condition="Exists('$(ManagedDir)')">
|
||||
<!--
|
||||
Reference all assemblies except ones that come
|
||||
with our target framework or would cause conflicts
|
||||
-->
|
||||
<LocalReferences
|
||||
Include="$(ManagedDir)*.dll"
|
||||
Exclude="$(ManagedDir)Mono*.dll;$(ManagedDir)netstandard.dll;$(ManagedDir)System*.dll;$(ManagedDir)mscorlib.dll"
|
||||
/>
|
||||
<Reference Include="@(LocalReferences)" Private="false" />
|
||||
<!-- Publicize these assemblies so we can access their internal members -->
|
||||
<Reference Include="$(ManagedDir)Assembly-CSharp.dll" Private="false" Publicize="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Build Thunderstore package by calling `dotnet build -c Release -target:PackTS -v d` (verbosity detailed).
|
||||
Publish to Thunderstore by including `-property:PublishTS=true` in the command.
|
||||
-->
|
||||
<Target Name="PackTS" DependsOnTargets="Build" Condition="$(ThunderstorePackable) != 'false'">
|
||||
<Error
|
||||
Text=" PackTS must be called with Release configuration."
|
||||
Condition="'$(Configuration)' != 'Release'"
|
||||
/>
|
||||
<PropertyGroup>
|
||||
<BuildArgument Condition="'$(PublishTS)' != 'true'">build</BuildArgument>
|
||||
<BuildArgument Condition="'$(PublishTS)' == 'true'">publish</BuildArgument>
|
||||
</PropertyGroup>
|
||||
<Exec Command="dotnet tool restore" />
|
||||
<Exec Command="dotnet tcli $(BuildArgument) --package-version $(Version)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- This is the most appropriate target framework for the game's Unity version. -->
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<!-- This is the GUID of your mod. Example: com.github.YourAccount.BepInExTemplate -->
|
||||
<AssemblyName>com.github.StarAppeal.BetterBugphobia</AssemblyName>
|
||||
<!-- This is the display name of your mod. Example: BepInEx Template -->
|
||||
<AssemblyTitle>BetterBugphobia</AssemblyTitle>
|
||||
<!-- This is the version number of your mod. -->
|
||||
<Version>0.1.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
How to include thunderstore mods as dependencies via nuget
|
||||
|
||||
We have already added the windows10ce nuget feed to this project
|
||||
in NuGet.Config so all you need to do is list a dependency like
|
||||
this:
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ModTeam-ModName" Version="1.0.0" Private="False"/>
|
||||
</ItemGroup>
|
||||
|
||||
Private="false" will stop it from being copied to the output folder
|
||||
during build. This will cause the mod to be downloaded and its
|
||||
methods will be available at compile time for your code. You'll still
|
||||
need to add it as a dependency in your manifest.json, of course
|
||||
-->
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterBugphobia;
|
||||
|
||||
[HarmonyPatch(typeof(BugPhobia), "Start")]
|
||||
public class BugPhobiaPatch
|
||||
{
|
||||
private static readonly Dictionary<string, string> MonsterTypeCache = new();
|
||||
|
||||
[HarmonyPostfix]
|
||||
static void Postfix(BugPhobia __instance)
|
||||
{
|
||||
string gameObjectName = __instance.gameObject.name;
|
||||
|
||||
if (MonsterTypeCache.TryGetValue(gameObjectName, out var monsterName))
|
||||
{
|
||||
Plugin.Log.LogInfo($"[BetterBugphobia] Cache Hit: {monsterName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var allComponents = __instance.gameObject.GetComponents<MonoBehaviour>();
|
||||
foreach (var component in allComponents)
|
||||
{
|
||||
var componentName = component.GetType().Name;
|
||||
if (!Plugin.bugPhobiaMap.ContainsKey(componentName)) continue;
|
||||
monsterName = componentName;
|
||||
break;
|
||||
}
|
||||
|
||||
if (monsterName != null)
|
||||
{
|
||||
MonsterTypeCache[gameObjectName] = monsterName;
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.Log.LogInfo($"[BetterBugphobia] Patching {monsterName}");
|
||||
|
||||
if (monsterName == null) return;
|
||||
|
||||
Plugin.ApplyBugphobia(__instance, monsterName);
|
||||
|
||||
Plugin.Log.LogInfo($"[BetterBugphobia] Patch finished for {monsterName}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Logging;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterBugphobia;
|
||||
|
||||
[BepInAutoPlugin]
|
||||
public partial class Plugin : BaseUnityPlugin
|
||||
{
|
||||
internal static ManualLogSource Log { get; private set; } = null!;
|
||||
|
||||
private List<Type> mobList = [typeof(Spider), typeof(Scorpion), typeof(Antlion), typeof(Beetle)];
|
||||
|
||||
public static Dictionary<string, ConfigEntry<bool>> bugPhobiaMap = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Log = Logger;
|
||||
|
||||
foreach (var mob in mobList)
|
||||
{
|
||||
var configEntry = Config.Bind("General", mob.Name, false, "BingBong?");
|
||||
configEntry.SettingChanged += OnSettingChanged;
|
||||
bugPhobiaMap.Add(mob.Name, configEntry);
|
||||
}
|
||||
|
||||
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly);
|
||||
|
||||
Log.LogInfo($"Plugin {Name} is loaded!");
|
||||
}
|
||||
|
||||
private void OnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Log.LogInfo("Setting Changed!");
|
||||
ApplyAllBugphobiaSettings();
|
||||
}
|
||||
|
||||
private void ApplyAllBugphobiaSettings()
|
||||
{
|
||||
foreach (var mobType in mobList)
|
||||
{
|
||||
foreach (var mob in FindObjectsOfType(mobType))
|
||||
{
|
||||
var monsterComponent = mob as MonoBehaviour;
|
||||
if (monsterComponent == null) continue;
|
||||
if (monsterComponent.TryGetComponent<BugPhobia>(out var bugPhobiaComponent))
|
||||
{
|
||||
ApplyBugphobia(bugPhobiaComponent, mobType.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyBugphobia(BugPhobia bugPhobiaComponent, string monsterName)
|
||||
{
|
||||
if (!bugPhobiaMap.TryGetValue(monsterName, out var configEntry)) return;
|
||||
foreach(var go in bugPhobiaComponent.defaultGameObjects) go.SetActive(!configEntry.Value);
|
||||
foreach(var go in bugPhobiaComponent.bugPhobiaGameObjects) go.SetActive(configEntry.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
[config]
|
||||
schemaVersion = "0.0.1"
|
||||
|
||||
[general]
|
||||
repository = "https://thunderstore.io"
|
||||
|
||||
[package]
|
||||
namespace = "StarAppeal"
|
||||
name = "BetterBugphobia"
|
||||
description = "Individually toggle each bug to be BING BONG"
|
||||
websiteUrl = "" # TODO: Add a link to your mod repository here (optional)
|
||||
containsNsfwContent = false
|
||||
|
||||
[package.dependencies]
|
||||
BepInEx-BepInExPack_PEAK = "5.4.2403"
|
||||
|
||||
[build]
|
||||
icon = "../../icon.png"
|
||||
readme = "../../README.md"
|
||||
outdir = "../../artifacts/thunderstore/"
|
||||
|
||||
[[build.copy]]
|
||||
source = "../../artifacts/bin/BetterBugphobia/release/com.github.StarAppeal.BetterBugphobia.dll"
|
||||
target = "plugins/"
|
||||
|
||||
[[build.copy]]
|
||||
source = "../../CHANGELOG.md"
|
||||
target = "/"
|
||||
|
||||
[[build.copy]]
|
||||
source = "../../LICENSE"
|
||||
target = "/"
|
||||
|
||||
# The following config options only apply when using TCLI to publish to Thunderstore directly:
|
||||
|
||||
[publish]
|
||||
# See communities at:
|
||||
# https://thunderstore.io/api/experimental/community/
|
||||
communities = [ "peak", ]
|
||||
|
||||
[publish.categories]
|
||||
# See categories at:
|
||||
# https://thunderstore.io/api/experimental/community/peak/category/
|
||||
peak = [ "mods", ]
|
||||
Reference in New Issue
Block a user