using Godot; using System; public partial class Ball : RigidBody2D { public bool _placed, _available, _hovered, _selected, _aimed, _moving; public float _moveThreshold = 5.0f; public static Ball Create(int number, Vector2 position) { PackedScene scene = ResourceLoader.Load("res://Gameplay/ball.tscn"); Ball newBall = scene.Instantiate(); string fileName; if (number == 0) { fileName = "res://art/cue_ball.png"; } else { fileName = "res://art/ball_"+number+".png"; } Texture2D image = GD.Load(fileName); newBall.GetNode("Image").Texture = image; newBall.Position = position; return newBall; } public override void _Ready() { _placed = false; _hovered = false; _selected = false; _aimed = false; _moving = false; _available = false; } public override void _Process(double delta_) { _moving = false; if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold) { Sleeping = true; } else if (LinearVelocity.Length() >= _moveThreshold) { _moving = true; } if (!((Battle)GetParent()).CheckMovement()) { if (!_available) { _available = true; GetParent().GetNode("Cue").ShowCue(); } } else { if (_available) { _available = false; GetParent().GetNode("Cue").HideCue(); } } } }