feat: 添加了受击反馈mod chore: 优化了隐藏角色的代码
This commit is contained in:
9
HitFeedback/Config.cs
Normal file
9
HitFeedback/Config.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HitFeedback
|
||||
{
|
||||
public class Config
|
||||
{
|
||||
public Dictionary<string, float> probability = new Dictionary<string, float>();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,19 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<DuckovPath>D:\steam\steamapps\common\Escape from Duckov</DuckovPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>D:\steam\steamapps\common\Escape from Duckov\Duckov_Data\Mods\HitFeedback</OutputPath>
|
||||
<GenerateDependencyFile>false</GenerateDependencyFile>
|
||||
<DebugType>none</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="$(DuckovPath)\Duckov_Data\Managed\TeamSoda.*" Private="False" />
|
||||
<Reference Include="$(DuckovPath)\Duckov_Data\Managed\ItemStatsSystem.dll" Private="False" />
|
||||
<Reference Include="$(DuckovPath)\Duckov_Data\Managed\Unity*" Private="False" />
|
||||
<Reference Include="$(DuckovPath)\Duckov_Data\Managed\FMODUnity.dll" Private="False" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,116 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Duckov;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Object = UnityEngine.Object;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace HitFeedback
|
||||
{
|
||||
public class ModBehaviour:Duckov.Modding.ModBehaviour
|
||||
{
|
||||
public const string AudioFolderName = "audio";
|
||||
public string audioFolderPath;
|
||||
|
||||
public List<string> audioFilePath = new List<string>();
|
||||
|
||||
public Health health;
|
||||
|
||||
public Config config=new Config();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F8))
|
||||
{
|
||||
PlayRandomAudioClip();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAfterSetup()
|
||||
{
|
||||
LevelManager.OnLevelInitialized += OnSceneLoaded;
|
||||
audioFolderPath=Path.Combine(info.path,AudioFolderName);
|
||||
FindWavFiles();
|
||||
}
|
||||
protected override void OnBeforeDeactivate()
|
||||
{
|
||||
|
||||
LevelManager.OnLevelInitialized -= OnSceneLoaded;
|
||||
}
|
||||
private void FindWavFiles()
|
||||
{
|
||||
audioFilePath.Clear();
|
||||
if (!Directory.Exists(audioFolderPath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
string[] files = Directory.GetFiles(audioFolderPath, "*.wav", SearchOption.TopDirectoryOnly);
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
audioFilePath.Add(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException ex)
|
||||
{
|
||||
Debug.LogError($"Error: Access to '{audioFolderPath}' is denied. {ex.Message}");
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
Debug.LogError($"Error: Directory '{audioFolderPath}' not found. {ex.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"An unexpected error occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneLoaded()
|
||||
{
|
||||
TryAddListener();
|
||||
}
|
||||
|
||||
private void TryAddListener()
|
||||
{
|
||||
if (health)
|
||||
{
|
||||
health.OnHurtEvent.RemoveListener(OnHurtEvent);
|
||||
}
|
||||
health = CharacterMainControl.Main?.Health;
|
||||
if (health)
|
||||
{
|
||||
health.OnHurtEvent.AddListener(OnHurtEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnHurtEvent(DamageInfo damageInfo)
|
||||
{
|
||||
PlayRandomAudioClip();
|
||||
}
|
||||
|
||||
public void PlayRandomAudioClip()
|
||||
{
|
||||
if (audioFilePath.Count > 0)
|
||||
{
|
||||
var randomIndex = Random.Range(0, audioFilePath.Count);
|
||||
var filePath = audioFilePath[randomIndex];
|
||||
AudioManager.PostCustomSFX(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Mod Feedback: No audio clips loaded to play.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5cec8711ddabae774b7b55087269b881165af0e7")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2af09007f967b42ac04776167f814297d14582e3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
84a0140b62d51a4d1e1db6c69a6d53266a2de1b9a06e96eda7354c706b34ce28
|
||||
21bb5d42a925e2609f95fd6bae7df27510f6f676c220089a05b657a9435715db
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
is_global = true
|
||||
build_property.RootNamespace = HitFeedback
|
||||
build_property.ProjectDir = d:\vs_project\DuckovMods\HitFeedback\
|
||||
build_property.ProjectDir = D:\vs_project\DuckovMods\HitFeedback\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.CsWinRTUseWindowsUIXamlProjections = false
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
|
||||
22
HitFeedback/obj/Release/HitFeedback.AssemblyInfo.cs
Normal file
22
HitFeedback/obj/Release/HitFeedback.AssemblyInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2af09007f967b42ac04776167f814297d14582e3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// 由 MSBuild WriteCodeFragment 类生成。
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
af2244db1221597efe6147a09f74a909205fbb96bd2548e7cd4320372ffd41b1
|
||||
@@ -0,0 +1,8 @@
|
||||
is_global = true
|
||||
build_property.RootNamespace = HitFeedback
|
||||
build_property.ProjectDir = D:\vs_project\DuckovMods\HitFeedback\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.CsWinRTUseWindowsUIXamlProjections = false
|
||||
build_property.EffectiveAnalysisLevelStyle =
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
BIN
HitFeedback/obj/Release/HitFeedback.assets.cache
Normal file
BIN
HitFeedback/obj/Release/HitFeedback.assets.cache
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
17059da2b4ba38151f18bb4edeeed66662c124b29efddf4c48967bc01f547046
|
||||
@@ -0,0 +1,7 @@
|
||||
D:\steam\steamapps\common\Escape from Duckov\Duckov_Data\Mods\HitFeedback\HitFeedback.dll
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.csproj.AssemblyReference.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.GeneratedMSBuildEditorConfig.editorconfig
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.AssemblyInfoInputs.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.AssemblyInfo.cs
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.csproj.CoreCompileInputs.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\HitFeedback.dll
|
||||
BIN
HitFeedback/obj/Release/HitFeedback.dll
Normal file
BIN
HitFeedback/obj/Release/HitFeedback.dll
Normal file
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5cec8711ddabae774b7b55087269b881165af0e7")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2af09007f967b42ac04776167f814297d14582e3")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("HitFeedback")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
6dfdb835a50972dc3b35cbc3ef11e4b4945b330f1030bb4e87d430fed92effb8
|
||||
af2244db1221597efe6147a09f74a909205fbb96bd2548e7cd4320372ffd41b1
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
7453d4b6fcee39c7a7d800c9763c938846bec2244ebefaa4c34d16a8d8390f64
|
||||
@@ -0,0 +1,8 @@
|
||||
D:\steam\steamapps\common\Escape from Duckov\Duckov_Data\Mods\HitFeedback\netstandard2.1\HitFeedback.dll
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.csproj.AssemblyReference.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.GeneratedMSBuildEditorConfig.editorconfig
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.AssemblyInfoInputs.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.AssemblyInfo.cs
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.csproj.CoreCompileInputs.cache
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedb.24A289A1.Up2Date
|
||||
D:\vs_project\DuckovMods\HitFeedback\obj\Release\netstandard2.1\HitFeedback.dll
|
||||
BIN
HitFeedback/obj/Release/netstandard2.1/HitFeedback.dll
Normal file
BIN
HitFeedback/obj/Release/netstandard2.1/HitFeedback.dll
Normal file
Binary file not shown.
1
HitFeedback/obj/rider.project.model.nuget.info
Normal file
1
HitFeedback/obj/rider.project.model.nuget.info
Normal file
@@ -0,0 +1 @@
|
||||
17620100186005303
|
||||
Reference in New Issue
Block a user