Files
hotdesking/Gameplay/Table.cs

48 lines
901 B
C#

using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class Table : Sprite2D
{
[Signal]
public delegate void OnBallPottedEventHandler(Ball THIS, Pocket POCKET);
public bool _kitchenHovered;
List<Pocket> _pockets;
public override void _Ready()
{
_pockets = GetNode<Node2D>("Pockets")
.GetChildren()
.Select(n => (Pocket)n)
.ToList<Pocket>();
for (int i = 0; i < _pockets.Count; i++)
{
_pockets[i].OnBallPotted += BallPotted;
}
GetNode<Area2D>("Kitchen").MouseEntered += KitchenHovered;
GetNode<Area2D>("Kitchen").MouseExited += KitchenUnhovered;
}
public void BallPotted(Node NODE, Pocket POCKET)
{
if (NODE is Ball)
{
EmitSignal(SignalName.OnBallPotted, (Ball)NODE, POCKET);
}
}
public void KitchenHovered()
{
_kitchenHovered = true;
}
public void KitchenUnhovered()
{
_kitchenHovered = false;
}
}