using Godot; using System; using System.Data; public partial class Ball : RigidBody2D { public bool _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _moving = false, _isCue = false; public int _defense, _defenseMax; public float _moveThreshold = 5.0f; public static Ball _Create(int NUMBER) { PackedScene scene = ResourceLoader.Load("res://Gameplay/ball.tscn"); Ball newBall = scene.Instantiate(); string fileName; if (NUMBER == 0) { fileName = "res://art/cue_ball.png"; newBall._isCue = true; } else { fileName = "res://art/ball_" + NUMBER + ".png"; newBall._isCue = false; ; } Texture2D image = GD.Load(fileName); newBall.GetNode("Image").Texture = image; return newBall; } public override void _Process(double DELTA_) { if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold) { Sleeping = true; if (_moving) { _moving = false; } } else if (LinearVelocity.Length() >= _moveThreshold) { if (!_moving) { _moving = true; } } if (Globals.Instance._anyMovement) { if (_available) { _available = false; } } else { if (!_available) { _available = true; } } } public void Place(Vector2 POSITION) { _placed = true; Position = POSITION; } private void OnMouseEntered() { _hovered = true; } private void OnMouseExited() { _hovered = false; } }