Skip to content

[Bug] 注册卡牌在弃牌堆右键行为,特定情况会报错 #98

Description

@vitechliu

模块范围

Public API(公开 API)

严重程度

Minor(轻微)

发生了什么?

在弃牌堆右键卡牌,成功执行效果,但是报错。
应该是holder.GetViewport().SetInputAsHandled(); 这里有判空问题。

复现步骤

右键卡牌效果为:将抽牌堆顶上的牌放到弃牌堆,只有这种效果才会报错,可能是丢失了内容

var drawPile = PileType.Draw.GetPile(player);
        if (drawPile.Cards.Count < count) return false;
        var cardModels = drawPile.Cards.Take(count).ToList();
        if (cardModels.Count < count) return false;
        await CardPileCmd.Add(cardModels, PileType.Discard);

期望行为

No response

日志 / 堆栈

Error occurred [0]: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at STS2RitsuLib.Interactions.RightClick.Patches.ModRightClickCardPilePatch.Prefix(NCardGrid __instance, NCardHolder holder) in F:\Github\sts-2-opencode\sts-2-ritsulib\src\Interactions\RightClick\Patches\ModRightClickCardPatches.cs:line 154
   at MegaCrit.Sts2.Core.Nodes.Cards.NCardGrid.OnHolderAltPressed_Patch1(NCardGrid this, NCardHolder holder)
   at Godot.Callable.<From>g__Trampoline|2_0[T0](Object delegateObj, NativeVariantPtrArgs args, godot_variant& ret)
   at Godot.DelegateUtils.InvokeWithVariantArgs(IntPtr delegateGCHandle, Void* trampoline, godot_variant** args, Int32 argc, godot_variant* outRet)
:0 @ void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception)()
C# backtrace (most recent call first):
    [0] void Godot.GD.PushError(string)
    [1] void Godot.NativeInterop.ExceptionUtils.LogException(System.Exception)
    [2] void Godot.DelegateUtils.InvokeWithVariantArgs(nint, System.Void*, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant*)

RitsuLib 版本

最新版

运行环境

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiPublic API, contracts, or compatibility surface.priority/p3Low priority or backlog.severity/minorMinor defect, polish issue, or low-impact bug.status/needs-triageNeeds maintainer or analyzer triage.type/bugDefect or incorrect behavior in RitsuLib.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions