filesystem rework
This commit is contained in:
parent
64323290cc
commit
2905db3dce
174 changed files with 93 additions and 353 deletions
|
|
@ -1,44 +0,0 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Newlon.Components.Plants;
|
||||
|
||||
public partial class Eyesight : Area2D
|
||||
{
|
||||
private bool _enemyDetected;
|
||||
public bool EnemyDetected => _enemyDetected;
|
||||
private readonly List<Entity> _detectedEntities = new List<Entity>();
|
||||
private RuntimePlantData _plantData;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_plantData = GetParent<RuntimePlantData>();
|
||||
AreaEntered += OnAreaEntered;
|
||||
AreaExited += OnAreaExited;
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var entity = area.GetParent<Entity>();
|
||||
if (entity != null)
|
||||
{
|
||||
_detectedEntities.Add(entity);
|
||||
}
|
||||
|
||||
_enemyDetected = _detectedEntities.Count > 0;
|
||||
}
|
||||
|
||||
public void OnAreaExited(Area2D area)
|
||||
{
|
||||
var entity = area.GetParent<Entity>();
|
||||
if (entity != null)
|
||||
{
|
||||
if (_detectedEntities.Contains(entity))
|
||||
{
|
||||
_detectedEntities.Remove(entity);
|
||||
}
|
||||
}
|
||||
|
||||
_enemyDetected = _detectedEntities.Count > 0;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue