add SixthSense
This commit is contained in:
parent
fcfd0cd626
commit
df0945daf9
87
Projects/SamSWAT.SixthSense/Plugin.cs
Normal file
87
Projects/SamSWAT.SixthSense/Plugin.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.UI;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace SamSWAT.SixthSense
|
||||
{
|
||||
[BepInPlugin("com.samswat.sixthsense", "SamSWAT.SixthSense", "1.0.0")]
|
||||
public class Plugin : BaseUnityPlugin
|
||||
{
|
||||
internal static AudioClip AudioClip;
|
||||
internal static ConfigEntry<bool> PluginEnabled;
|
||||
internal static ConfigEntry<float> Cooldown;
|
||||
async void Awake()
|
||||
{
|
||||
PluginEnabled = Config.Bind(
|
||||
"Main Settings",
|
||||
"Plugin on/off",
|
||||
true,
|
||||
"");
|
||||
|
||||
Cooldown = Config.Bind(
|
||||
"Main Settings",
|
||||
"Sound cooldown",
|
||||
5f,
|
||||
"Time between sound playback in seconds");
|
||||
|
||||
new Patch().Enable();
|
||||
|
||||
string uri = "file://" + (BepInEx.Paths.PluginPath + "/SamSWAT.SixthSense/audio.ogg").Replace("\\", "/");
|
||||
using (UnityWebRequest web = UnityWebRequestMultimedia.GetAudioClip(uri, AudioType.OGGVORBIS))
|
||||
{
|
||||
var asyncOperation = web.SendWebRequest();
|
||||
|
||||
while (!asyncOperation.isDone)
|
||||
await Task.Yield();
|
||||
|
||||
if (!web.isNetworkError && !web.isHttpError)
|
||||
{
|
||||
AudioClip = DownloadHandlerAudioClip.GetContent(web);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Can't load audio at path: '{uri}', error: {web.error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Patch : ModulePatch
|
||||
{
|
||||
private static float nextTime = 0;
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(BotGroupClass).GetMethod("CalcGoalForBot");
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void PatchPostfix(BotOwner bot)
|
||||
{
|
||||
if (Plugin.PluginEnabled.Value && Plugin.AudioClip != null && Time.time > nextTime)
|
||||
{
|
||||
//GClass442 goalEnemy = bot.Memory.GoalEnemy;
|
||||
object goalEnemy = bot.Memory.GetType().GetProperty("GoalEnemy").GetValue(bot.Memory);
|
||||
|
||||
if (goalEnemy != null)
|
||||
{
|
||||
IAIDetails person = (IAIDetails)goalEnemy.GetType().GetProperty("Person").GetValue(goalEnemy);
|
||||
bool isVisible = (bool)goalEnemy.GetType().GetProperty("IsVisible").GetValue(goalEnemy);
|
||||
|
||||
if (person.GetPlayer.IsYourPlayer && isVisible)
|
||||
{
|
||||
Singleton<GUISounds>.Instance.PlaySound(Plugin.AudioClip);
|
||||
nextTime = Time.time + Plugin.Cooldown.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
Projects/SamSWAT.SixthSense/Properties/AssemblyInfo.cs
Normal file
36
Projects/SamSWAT.SixthSense/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Общие сведения об этой сборке предоставляются следующим набором
|
||||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("SamSWAT.SixthSense")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("SamSWAT.SixthSense")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
|
||||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
|
||||
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
|
||||
[assembly: Guid("8fdfc616-1704-4056-a87e-2783692cc153")]
|
||||
|
||||
// Сведения о версии сборки состоят из указанных ниже четырех значений:
|
||||
//
|
||||
// Основной номер версии
|
||||
// Дополнительный номер версии
|
||||
// Номер сборки
|
||||
// Редакция
|
||||
//
|
||||
// Можно задать все значения или принять номера сборки и редакции по умолчанию
|
||||
// используя "*", как показано ниже:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
68
Projects/SamSWAT.SixthSense/SamSWAT.SixthSense.csproj
Normal file
68
Projects/SamSWAT.SixthSense/SamSWAT.SixthSense.csproj
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{8FDFC616-1704-4056-A87E-2783692CC153}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>SamSWAT.SixthSense</RootNamespace>
|
||||
<AssemblyName>SamSWAT.SixthSense</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>..\..\References\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\References\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BepInEx">
|
||||
<HintPath>..\..\References\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort">
|
||||
<HintPath>..\..\References\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\References\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.AudioModule">
|
||||
<HintPath>..\..\References\UnityEngine.AudioModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\References\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UnityWebRequestAudioModule">
|
||||
<HintPath>..\..\References\UnityEngine.UnityWebRequestAudioModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UnityWebRequestModule">
|
||||
<HintPath>..\..\References\UnityEngine.UnityWebRequestModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Plugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
25
Projects/SamSWAT.SixthSense/SamSWAT.SixthSense.sln
Normal file
25
Projects/SamSWAT.SixthSense/SamSWAT.SixthSense.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32002.261
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.SixthSense", "SamSWAT.SixthSense.csproj", "{8FDFC616-1704-4056-A87E-2783692CC153}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8FDFC616-1704-4056-A87E-2783692CC153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8FDFC616-1704-4056-A87E-2783692CC153}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8FDFC616-1704-4056-A87E-2783692CC153}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8FDFC616-1704-4056-A87E-2783692CC153}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {37D92541-AB40-4482-8A3E-62C29777D542}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
References/UnityEngine.UnityWebRequestModule.dll
Normal file
BIN
References/UnityEngine.UnityWebRequestModule.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user