using Godot; using System.Collections; using System.Collections.Generic; using Godot.Collections; namespace Rokojori { [GlobalClass,Tool] public partial class Eat:Action { [Export] public OnCollision onCollision; [Export] public Action onAteSomething; [Export] public Pointer pointer; protected override void _OnTrigger() { var pigs = onCollision.GetNodesInside(); var hasEaten = false; pigs.ForEach( ( p )=> { var eatable = p.Get(); this.LogInfo( eatable ); if ( eatable == null || ! eatable.isEatable ) { return; } eatable.GetEaten(); hasEaten = true; } ); if ( hasEaten ) { Trigger( onAteSomething ); } this.LogInfo( pigs ); } } }