//using Godot;
//using System;
//
//public partial class Ball : RigidBody2D
//{
	//[Signal]
	//public delegate void HoverEventHandler(bool tf = true);
	//[Signal]
	//public delegate void SelectEventHandler(bool tf = true);
	//[Signal]
	//public delegate void AimEventHandler(bool tf = true);
	//[Signal]
	//public delegate void LaunchEventHandler(bool tf = true);
	//[Signal]
	//public delegate void MoveEventHandler(bool tf = true);
	//[Signal]
	//public delegate void BumpMarbleEventHandler(Ball ball);
	//[Signal]
	//public delegate void DefenseDownEventHandler(int damage);
	//
	//public bool _holding, _placed, _hovered, _selected, _aimed, _launched, _moving;
	//public int _defense, _defenseMax, _speed;
	//public Vector2 _force, _velocity, _screenSize;
//
	//
	//public override void _Ready()
	//{
		//_holding = false;
		//_placed = true;
		//_hovered = false;
		//_selected = false;
		//_aimed = false;
		//_launched = false;
		//_moving = false;
		//_defense = 10;
		//_defenseMax = _defense;
		//_speed = 400;
		//_force = new Vector2(0,0);
		//_velocity = new Vector2(0,0);
		//_screenSize = GetViewportRect().Size;
		//
		////Hide();
	//}
	//
	//public override void _PhysicsProcess(double delta) //THIS IS LIKE THE UPDATE FUNCTION
	//{
		//if (_placed)
		//{
			//TrySelect();
			//TryAim();
			//TryLaunch();
			//TryMovement(delta);
		//}
		//else if (_holding)
		//{
			//GetNode<CollisionShape2D>("Bounds").Disabled = true;
			//Vector2 mousePosition = GetGlobalMousePosition();
			//if (Input.IsActionJustReleased("left_click"))
			//{
				//Start(mousePosition);
			//}
		//}
	//}
	//
	//public void DefenseChange(int change)
	//{
		//_defense += change;
		//if (_defense < 0)
		//{
			//EmitSignal(SignalName.DefenseDown); // transfer damage over 0 to player
			//_defense = 0; // set defense back to 0
		//}
	//}
	//
	//public void Start(Vector2 position)
	//{
		//
		//_holding = false;
		//_placed = true;
		//Position = position;
		//Show();
		//GetNode<CollisionShape2D>("Bounds").Disabled = false;
	//}
	//
	//public void TryAim()
	//{
		//if (_selected && Input.IsActionPressed("left_click") && ! _hovered && !_aimed)
		//{
			//_aimed = true;
			//EmitSignal(SignalName.Aim);
		//}
		//
		//if (_aimed)
		//{
			//Vector2 mousePosition = GetGlobalMousePosition();
			//_force = (Position - mousePosition) /6;
			//
			//if (!Input.IsActionPressed("left_click"))
			//{
				//if (!_hovered)
				//{
					//_launched = true;
					//EmitSignal(SignalName.Select, false);
				//}
				//else
				//{
					//_aimed = false;
					//EmitSignal(SignalName.Aim, false);
				//}
			//}
		//}
	//}
	//
	//public void TryLaunch()
	//{
		//if (_aimed && Input.IsActionJustReleased("left_click"))
		//{
			//_selected = false;
			//EmitSignal(SignalName.Select, false);
			//
			//_aimed = false;
			//EmitSignal(SignalName.Aim, false);
			//
			//_launched = true;
			//EmitSignal(SignalName.Launch);
			//
			//ApplyCentralForce(_force * _speed);
			//_force = Vector2.Zero;
		//}
	//}
	//
	//public void TryMovement(double delta)
	//{
		//if (LinearVelocity.Length() > 0 && !Sleeping)
		//{
			//if (!_moving)
			//{
				//_moving = true;
				//EmitSignal(SignalName.Move);
			//}
		//}
		//if (_moving)
		//{			
			////Vector2 Scroll = -LinearVelocity / 100;
////
			////Sprite2D sprite = (Sprite2D)GetNode("Texture");
			////ShaderMaterial material = (ShaderMaterial)sprite.Material;
			////
			////float CurrentScrollX = (float)material.GetShaderParameter("scroll_x");
			////material.SetShaderParameter("scroll_x", (CurrentScrollX + Scroll.X * (float)delta) % 1.0f);
			////
			////float CurrentScrollY = (float)material.GetShaderParameter("scroll_y");
			////material.SetShaderParameter("scroll_y", (CurrentScrollY + Scroll.Y * (float)delta) % 1.0f);
			//
			//
			//if (Sleeping)
			//{
				//_launched = false;
				//_moving = false;
				//EmitSignal(SignalName.Move, false);
			//}
		//}
	//}
	//
	//public void TrySelect()
	//{
		//if ( _hovered)
		//{
			//if (Input.IsActionJustPressed("left_click") && !_selected)
			//{
				//_selected = true;
				//EmitSignal(SignalName.Select);
			//}
		//}
		//
		//if (_selected)
		//{
			//if (!_hovered)
			//{
				//if (Input.IsActionJustPressed("left_click") && _selected)
				//{
					//_selected = false;
					//EmitSignal(SignalName.Select, false);
				//}
			//}
		//}
	//}
	//
	//private void OnMouseEntered()
	//{
		 //_hovered = true;
		//EmitSignal(SignalName.Hover);
	//}
	//
	//private void OnMouseExited()
	//{
		 //_hovered = false;
		//EmitSignal(SignalName.Hover, false);
	//}
	//
	//private void OnBodyEntered(Node2D body)
	//{
		//if (body.GetType() == typeof(Ball))
		//{
			//EmitSignal(SignalName.BumpMarble, (Ball)body);
		//}
	//}
//}
