egametang/ET · error

类型转换错误: {node.GetType().FullName} to {typeof (Node).Name}

Error message

类型转换错误: {node.GetType().FullName} to {typeof (Node).Name}

What it means

Error "类型转换错误: {node.GetType().FullName} to {typeof (Node).Name}" thrown in egametang/ET.

Source

Thrown at Packages/cn.etetet.spell/Scripts/Model/Client/TargetSelectDispatcher.cs:25

    {
    }
    
    public interface ITargetSelectHandler
    {
        ETTask<int> Handle(TargetSelector node, EntityRef<Unit> unit, SpellConfig spellConfig);
        Type GetNodeType();
    }
    
    [TargetSelectHandler]
    public abstract class TargetSelectHandler<Node>: HandlerObject, ITargetSelectHandler where Node : TargetSelector
    {
        protected abstract ETTask<int> Run(Node node, EntityRef<Unit> unit, SpellConfig spellConfig);

        public async ETTask<int> Handle(TargetSelector node, EntityRef<Unit> unit, SpellConfig spellConfig)
        {
            if (node is not Node c)
            {
                throw new Exception($"类型转换错误: {node.GetType().FullName} to {typeof (Node).Name}");
            }

            return await this.Run(c, unit, spellConfig);
        }

        public Type GetNodeType()
        {
            return typeof (Node);
        }
    }
    
    /// <summary>
    /// 分发组件
    /// </summary>
    [CodeProcess]
    [AllowInstance]
    public class TargetSelectDispatcher: Singleton<TargetSelectDispatcher>, ISingletonAwake
    {

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. 检查配置中节点类型名与实际节点类是否一致
  2. 确认该节点类继承自期望的 Node 基类
  3. 检查程序集热更新后类型是否来自正确的程序集

Example fix

将节点类型改为继承正确 Node 基类的实现,或修正配置中的节点类型名。

When it happens

Trigger: TargetSelectDispatcher 中目标选择节点对象无法转换为期望的 Node 类型,节点类型与配置不匹配

Common situations: See trigger scenarios.


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/c379999401ffad2e. Report an issue: GitHub.