This commit is contained in:
Фёдор Веселов 2024-09-10 19:36:20 +05:00
commit 2eb65c3092
24 changed files with 566 additions and 49 deletions

View file

@ -0,0 +1,41 @@
using Godot;
using System;
public partial class EatBox : Area2D
{
// Rewrite this class completely when field system will be introduced.
[Export] private int _damage;
[Export] private AnimationTree _animationTree;
private RuntimePlantData plant;
public void Bite()
{
plant.TakeDamage(_damage);
}
public void OnAreaEntered(Area2D area)
{
var parent = area.GetParent();
if (parent != null && parent is RuntimePlantData plantData)
{
plant = plantData;
_animationTree.Set("parameters/conditions/eat", true);
_animationTree.Set("parameters/conditions/end_eat", false);
}
}
public void OnAreaExited(Area2D area)
{
var parent = area.GetParent();
if (parent == plant)
{
plant = null;
_animationTree.Set("parameters/conditions/eat", false);
_animationTree.Set("parameters/conditions/end_eat", true);
}
}
}