Sun, Shovel, Fastforward, GUI Improvements

This commit is contained in:
Фёдор Веселов 2024-09-16 09:57:11 +05:00
commit 63935d5978
28 changed files with 546 additions and 45 deletions

View file

@ -0,0 +1,39 @@
using Godot;
using System;
public partial class ShovelButton : TextureButton
{
private RayCast2D _shovelCast;
public override void _Ready()
{
_shovelCast = GetNode<RayCast2D>("RayCast2D");
_shovelCast.CallDeferred("reparent", GetTree().CurrentScene);
}
private void OnFocusExited()
{
ButtonPressed = false;
}
public override void _Process(double delta)
{
_shovelCast.GlobalPosition = _shovelCast.GetGlobalMousePosition();
}
public override void _Toggled(bool toggledOn)
{
_shovelCast.Enabled = toggledOn;
Cursor.Instance.shovel = toggledOn;
Cursor.Instance.UpdateCursor();
}
public override void _Input(InputEvent @event)
{
if (@event.IsActionPressed("primary_action"))
{
if (_shovelCast.IsColliding() && (_shovelCast.GetCollider() as CollisionObject2D).GetParent() is RuntimePlantData plant)
{
plant.Kill();
}
ButtonPressed = false;
}
}
}