38 lines
765 B
C#
38 lines
765 B
C#
using Godot;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Godot.Collections;
|
|
|
|
namespace Rokojori
|
|
{
|
|
[GlobalClass,Tool]
|
|
public partial class Hitable:Node
|
|
{
|
|
[Export]
|
|
public OnCollision onCollision;
|
|
|
|
[Export]
|
|
public Action onReceivedHit;
|
|
|
|
public override void _Ready()
|
|
{
|
|
onCollision.onEnteredSlot.AddAction(
|
|
( n )=>
|
|
{
|
|
Action.Trigger( onReceivedHit );
|
|
var hitter = n.Get<Hitter>();
|
|
|
|
this.LogInfo( "Was hit by:", HierarchyName.Of( n ), HierarchyName.Of( hitter ) );
|
|
|
|
if ( hitter != null )
|
|
{
|
|
hitter.hitable = this;
|
|
Action.Trigger( hitter.onHit );
|
|
hitter.hitable = null;
|
|
}
|
|
|
|
}
|
|
);
|
|
}
|
|
}
|
|
} |