Skip to content

feat: 更新至 v1.8.7,增强对话和音效触发功能#16

Merged
BAKAOLC merged 8 commits into
mainfrom
develop
Nov 21, 2025
Merged

feat: 更新至 v1.8.7,增强对话和音效触发功能#16
BAKAOLC merged 8 commits into
mainfrom
develop

Conversation

@BAKAOLC
Copy link
Copy Markdown
Collaborator

@BAKAOLC BAKAOLC commented Nov 21, 2025

更新内容

  • 新增自定义对话系统,支持在动画状态机中触发对话
  • 新增 ModelSoundTrigger 组件,支持在动画状态机中直接触发音效
  • 增强音效触发功能,新增多个战斗相关音效标签
  • 增强动画器控制功能,新增多个战斗相关触发器
  • 增强 ModelHandler 音效触发功能,支持暴击判断和音效播放概率配置
  • 优化音效标签处理,移除标签验证限制
  • 更新 README 和 CHANGELOG 文档

相关提交

  • feat: 添加自定义对话管理器以增强对话功能
  • feat: 添加 ModelSoundTrigger 以增强音效触发机制
  • feat: 增强 CustomAnimatorControl 和 ModelHandler 的音效触发功能
  • feat: 更新至 v1.8.7,增强对话和音效触发功能

- 新增 CustomDialogueManager 以管理对话触发和语言变化
- 添加 DialogueDefinition 类以定义对话内容和播放模式
- 实现 ModelDialogueTrigger 以在动画状态进入时触发对话
- 更新 ModEntry.cs 以初始化和清理自定义对话管理器
- 扩展 ModelHandler 以提供当前模型目录信息
- 新增 ModelSoundTrigger 类,支持在动画状态进入时触发音效播放
- 更新 ModelHandler 以注册和注销音效触发事件
- 优化音效标签处理,确保标签规范化并支持空白标签过滤
- 改进音效播放逻辑,确保在特定条件下正确播放音效
- 在 CustomAnimatorControl 中新增多个触发器方法(TriggerHurt、TriggerDead、TriggerHitTarget、TriggerKillTarget、TriggerCritHurt、TriggerCritDead、TriggerCritHitTarget、TriggerCritKillTarget)
- 更新 ModelHandler 以支持全局受伤和死亡事件的处理,调用相应的动画触发器
- 引入音效标签的随机播放概率,优化音效播放逻辑以支持不同的受伤和死亡情况
- 更新 SoundTags 和 ModelInfo 以包含新的音效标签和播放概率设置
- 新增自定义对话系统,支持在动画状态机中触发对话,包含多语言支持和多种播放模式
- 添加 ModelSoundTrigger 组件,支持在动画状态机中直接触发音效,优化音效播放逻辑
- 增强 ModelHandler 和 CustomAnimatorControl 的音效触发功能,支持多种战斗相关触发器
- 引入音效标签播放概率配置,允许自定义标签的使用
- 更新文档以反映新功能和配置选项
Copilot AI review requested due to automatic review settings November 21, 2025 21:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the mod to v1.8.7, introducing a comprehensive dialogue system and enhancing combat-related audio and animation triggers. The changes enable more dynamic character interactions through dialogue bubbles and expanded sound effect triggers for combat events, including critical hit variations. The implementation removes previous sound tag validation restrictions, allowing for more flexible custom sound configurations.

Key Changes

  • Added custom dialogue system with multilingual support and multiple playback modes (Sequential, Random, RandomNoRepeat, Continuous)
  • Added ModelSoundTrigger and ModelDialogueTrigger components for triggering audio and dialogue from animation state machines
  • Enhanced combat event handling with 6 new sound tags and 8 new animator triggers for normal and critical hit/death scenarios
  • Added sound playback probability configuration (SoundTagPlayChance) for fine-grained audio control

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
README.md Added documentation for dialogue system, ModelSoundTrigger/ModelDialogueTrigger components, combat triggers, and sound probability configuration (Chinese)
README_EN.md Added documentation for dialogue system, ModelSoundTrigger/ModelDialogueTrigger components, combat triggers, and sound probability configuration (English)
DuckovCustomModel/Constant.cs Updated version to 1.8.7
DuckovCustomModel/ModEntry.cs Added CustomDialogueManager initialization and cleanup
DuckovCustomModel/MonoBehaviours/ModelHandler.cs Enhanced sound triggering with crit detection, global damage/death event handling, probability configuration, and ModelSoundTrigger event subscription
DuckovCustomModel/MonoBehaviours/CustomAnimatorControl.cs Added 8 new trigger methods for combat events (Hurt, Dead, HitTarget, KillTarget + Crit variants)
DuckovCustomModel/Managers/CustomDialogueManager.cs New manager for loading, caching, and playing dialogue with multilingual support
DuckovCustomModel.Core/MonoBehaviours/Animators/ModelSoundTrigger.cs New StateMachineBehaviour for triggering sounds from animation states
DuckovCustomModel.Core/MonoBehaviours/Animators/ModelDialogueTrigger.cs New StateMachineBehaviour for triggering dialogue from animation states
DuckovCustomModel.Core/Data/SoundTags.cs Added 6 new combat-related sound tag constants
DuckovCustomModel.Core/Data/SoundInfo.cs Removed tag validation restriction to allow custom tags
DuckovCustomModel.Core/Data/ModelInfo.cs Added SoundTagPlayChance property for probability configuration
DuckovCustomModel.Core/Data/DialogueDefinition.cs New data class for dialogue configuration
DuckovCustomModel.Core/Data/CustomAnimatorHash.cs Added 8 new animator parameter hashes for combat triggers
CHANGELOG.md Documented v1.8.7 changes (Chinese)
CHANGELOG_EN.md Documented v1.8.7 changes (English)
Comments suppressed due to low confidence (1)

DuckovCustomModel/MonoBehaviours/ModelHandler.cs:179

  • [nitpick] The event subscriptions in OnDestroy() are unsubscribed before checking if CharacterMainControl is null (lines 170-173), but the corresponding subscriptions in Initialize() are done after the null check (lines 230-233). While this works, it could lead to attempting to unsubscribe from global events even when initialization failed or never completed. Consider adding a guard to ensure these global event unsubscriptions only occur if initialization was successful, or moving them after the null check for consistency.

Example:

if (CharacterMainControl != null && CharacterMainControl.Health != null)
{
    CharacterMainControl.Health.OnHurtEvent.RemoveListener(OnHurt);
    CharacterMainControl.Health.OnDeadEvent.RemoveListener(OnDeath);
}

ModelSoundTrigger.OnSoundTriggered -= OnSoundTriggered;
Health.OnHurt -= OnGlobalHurt;
Health.OnDead -= OnGlobalDead;
        private void OnDestroy()
        {
            ModelSoundTrigger.OnSoundTriggered -= OnSoundTriggered;

            Health.OnHurt -= OnGlobalHurt;
            Health.OnDead -= OnGlobalDead;

            if (CharacterMainControl == null) return;
            if (CharacterMainControl.Health == null) return;
            CharacterMainControl.Health.OnHurtEvent.RemoveListener(OnHurt);
            CharacterMainControl.Health.OnDeadEvent.RemoveListener(OnDeath);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread DuckovCustomModel/Managers/CustomDialogueManager.cs
Comment thread DuckovCustomModel.Core/MonoBehaviours/Animators/ModelSoundTrigger.cs Outdated
Comment thread DuckovCustomModel/Managers/CustomDialogueManager.cs Outdated
Comment thread DuckovCustomModel/MonoBehaviours/ModelHandler.cs Outdated
Comment thread DuckovCustomModel/MonoBehaviours/ModelHandler.cs Outdated
- 更新音效播放方法,支持根据播放概率决定是否跳过音效
- 在多个类中实现新的 GetRandomSoundByTag 方法,返回音效路径并指示是否因概率跳过
- 改进音效触发逻辑,确保在特定条件下正确播放音效,提升用户体验
- 将对话缓存从 Dictionary 更改为 ConcurrentDictionary,以提高线程安全性
- 优化 ModelSoundTrigger 中的音效选择逻辑,确保索引循环并避免越界
- 更新对话加载方法,确保在处理模型目录时使用更安全的字符串检查
Copilot AI review requested due to automatic review settings November 21, 2025 21:47
- 更新音效标签的处理方式,确保标签在添加到字典之前被规范化(小写和去除空白)
- 移除不必要的中间变量,简化代码结构,提高可读性
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread DuckovCustomModel.Core/Data/DialogueDefinition.cs Outdated
Comment thread DuckovCustomModel/Managers/CustomDialogueManager.cs
Comment thread DuckovCustomModel/MonoBehaviours/ModelHandler.cs Outdated
Comment thread DuckovCustomModel/MonoBehaviours/ModelHandler.cs Outdated
- 在 DialogueDefinition 类中引入锁机制,确保 CurrentIndex 和 RemainingIndices 的线程安全访问
- 简化代码结构,提升可读性,确保在多线程环境下的稳定性
@BAKAOLC BAKAOLC merged commit dbd669a into main Nov 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants