complete refactor

This commit is contained in:
Rendo 2025-07-25 18:48:49 +05:00
commit de2e8b1e50
71 changed files with 212 additions and 137 deletions

View file

@ -1,18 +1,19 @@
using Godot;
using Newlon.Components.GUI.Seedpackets;
using Newlon.Components.Plants;
using Newlon.Resources;
namespace Newlon.Components.Level;
public partial class PlantField : Node2D
{
private Node2D _plantSetter;
private EntityResource _resource;
private GridEntityResource _resource;
private Seedpacket _slot;
private bool _previousCanPlace;
private ChannelPlayer player;
[Export] private PackedScene particles;
public static PlantField Instance {get; private set;}
public static PlantField Instance { get; private set; }
public override void _Ready()
{
@ -21,13 +22,13 @@ public partial class PlantField : Node2D
player = GetNode<ChannelPlayer>("PlantPlayer");
}
public void SetPlant(Seedpacket slot, EntityResource resource)
public void SetPlant(Seedpacket slot, GridEntityResource resource)
{
_resource = resource;
_slot = slot;
if (resource == null)
{
foreach(var child in _plantSetter.GetChildren())
foreach (var child in _plantSetter.GetChildren())
child.QueueFree();
}
else
@ -40,7 +41,7 @@ public partial class PlantField : Node2D
public void ResetPlant()
{
SetPlant(null,null);
SetPlant(null, null);
}
public override void _Process(double delta)
@ -99,7 +100,7 @@ public partial class PlantField : Node2D
RuntimeLevelData.Instance.SpendSun((int)_resource.Cost);
PoolContainer.Instance.SpawnParticles(particles, plant.GlobalPosition + Vector2.Down * FieldParams.TileHeight/2.0f);
PoolContainer.Instance.SpawnParticles(particles, plant.GlobalPosition + Vector2.Down * FieldParams.TileHeight / 2.0f);
player.Play();