file refactor

This commit is contained in:
Rendo 2025-07-11 22:35:36 +05:00
commit bffb012a26
175 changed files with 1086 additions and 1107 deletions

View file

@ -0,0 +1,47 @@
using Godot;
using Newlon.Components.Level;
namespace Newlon.Components.Plants.Behaviours;
public partial class AloeBehaviour : BaseBehaviour
{
[Export] private float _hpTreshold = 0.25f;
private Timer _timer;
private bool _charge = true;
public override void _Ready()
{
base._Ready();
_timer = GetNode<Timer>("Timer");
}
public override void _Process(double delta)
{
_tree.Set("parameters/Tree/conditions/charged",_charge);
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
{
if((float)plantData.HP / (float)plantData.MaxHP < _hpTreshold)
{
_charge = false;
_tree.Set("parameters/Tree/conditions/heal",true);
_timer.Start();
}
}
}
public void Heal()
{
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
{
plantData.Heal(3000 + 25 * plantData.MaxHP, GetParent());
}
}
public void OnTimeout()
{
_charge = true;
}
}

View file

@ -0,0 +1 @@
uid://cljytsmqac0w7

View file

@ -0,0 +1,12 @@
using Godot;
namespace Newlon.Components;
public abstract partial class BaseBehaviour : Node
{
protected AnimationTree _tree;
public override void _Ready()
{
_tree = GetNode<AnimationTree>("../AnimationTree");
}
}

View file

@ -0,0 +1 @@
uid://3dbmgnr7qxee

View file

@ -0,0 +1,18 @@
using Godot;
namespace Newlon.Components.Plants.Behaviours;
public partial class HpBasedBehaviour : BaseBehaviour
{
private RuntimePlantData _data;
public override void _Ready()
{
base._Ready();
_data = GetParent<RuntimePlantData>();
}
public void OnHPChanged(int amount,Node origin)
{
_tree.Set("parameters/Tree/blend_position",(float)_data.HP/_data.MaxHP);
}
}

View file

@ -0,0 +1 @@
uid://btkmd86pn828y

View file

@ -0,0 +1,16 @@
using Godot;
namespace Newlon.Components.Plants.Behaviours;
public partial class PeashooterBehaviour : BaseBehaviour
{
[Export] private Timer _shootTimer;
[Export] private Eyesight _sight;
public override void _Process(double delta)
{
bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0;
_tree.Set("parameters/Tree/conditions/ready",readyToShoot);
}
}

View file

@ -0,0 +1 @@
uid://bdk5iqtw4xbkl

View file

@ -0,0 +1,28 @@
using Godot;
namespace Newlon.Components.Plants.Behaviours;
public partial class PotatomineBehaviour : BaseBehaviour
{
[Export] private Area2D _hitbox;
[Export] private CollisionShape2D _unprimedShape;
[Export] private CollisionShape2D _primedShape;
private bool _primed = false;
public void Prime()
{
_tree.Set("parameters/Tree/conditions/primed",true);
_hitbox.Monitorable = false;
_primed = true;
_unprimedShape.Disabled = true;
_primedShape.Disabled = false;
}
public void OnAreaEntered(Area2D area)
{
if (_primed == false) return;
_tree.Set("parameters/Tree/conditions/explode",true);
_primed = false;
}
}

View file

@ -0,0 +1 @@
uid://c7qfh4py0uulo

View file

@ -0,0 +1,19 @@
using Godot;
namespace Newlon.Components.Plants.Behaviours;
public partial class SpikeweedBehaviour : BaseBehaviour
{
private int _inCount = 0;
public void OnHitboxEntered(Area2D _area)
{
if (_inCount++ == 0)
_tree.Set("parameters/Tree/blend_position",1);
}
public void OnHitboxExited(Area2D _area)
{
if (--_inCount == 0)
_tree.Set("parameters/Tree/blend_position",0);
}
}

View file

@ -0,0 +1 @@
uid://dqquodxaijmem

View file

@ -0,0 +1,12 @@
using Godot;
namespace Newlon.Components.Plants.Behaviours;
public partial class SunflowerBehaviour : BaseBehaviour
{
public void Timeout()
{
_tree.Set("parameters/Tree/conditions/produce", true);
}
}

View file

@ -0,0 +1 @@
uid://bth7gah4tn7uj