38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
|
|
using Godot;
|
||
|
|
|
||
|
|
namespace Theriapolis.GodotHost.Scenes.Widgets;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// Container for unassigned AbilityToken children. Per
|
||
|
|
/// GODOT_PORTING_GUIDE.md §7.3, accepts only slot→pool drops (returning
|
||
|
|
/// an assigned value to the pool); pool→pool drops are no-ops. The step
|
||
|
|
/// consumes <see cref="Dropped"/> and mutates CharacterDraft.StatPool /
|
||
|
|
/// StatAssign in one call so the inevitable refresh re-creates tokens
|
||
|
|
/// in the right places.
|
||
|
|
/// </summary>
|
||
|
|
public partial class AbilityPool : HBoxContainer
|
||
|
|
{
|
||
|
|
[Signal] public delegate void DroppedEventHandler(Godot.Collections.Dictionary payload);
|
||
|
|
|
||
|
|
public override void _Ready()
|
||
|
|
{
|
||
|
|
AddThemeConstantOverride("separation", 8);
|
||
|
|
MouseFilter = MouseFilterEnum.Stop;
|
||
|
|
CustomMinimumSize = new Vector2(0, 64);
|
||
|
|
}
|
||
|
|
|
||
|
|
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||
|
|
{
|
||
|
|
if (data.VariantType != Variant.Type.Dictionary) return false;
|
||
|
|
var d = data.AsGodotDictionary();
|
||
|
|
if (!d.ContainsKey("kind") || d["kind"].AsString() != "ability_value") return false;
|
||
|
|
// Only slot→pool drops are meaningful; pool→pool is a no-op.
|
||
|
|
return d.ContainsKey("from") && d["from"].AsString() == "slot";
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void _DropData(Vector2 atPosition, Variant data)
|
||
|
|
{
|
||
|
|
EmitSignal(SignalName.Dropped, data);
|
||
|
|
}
|
||
|
|
}
|