Tuesday, 05 August 2025 01:43:58

This commit is contained in:
2025-08-05 01:44:03 -04:00
parent 7f65338679
commit 33db2a63a2
25 changed files with 456 additions and 596 deletions

View File

@@ -1,14 +1,33 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class Table : Sprite2D
{
public static Table _Create()
[Signal]
public delegate void OnBallPottedEventHandler(Ball THIS, Pocket POCKET);
List<Pocket> _pockets;
public override void _Ready()
{
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/table.tscn");
Table newTable = scene.Instantiate<Table>();
return newTable;
_pockets = GetNode<Node2D>("Pockets")
.GetChildren()
.Select(n => (Pocket)n)
.ToList<Pocket>();
for (int i = 0; i < _pockets.Count; i++)
{
_pockets[i].OnBallPotted += BallPotted;
}
}
public void BallPotted(Node NODE, Pocket POCKET)
{
if (NODE is Ball)
{
EmitSignal(SignalName.OnBallPotted, (Ball)NODE, POCKET);
}
}
}