61 lines
1.1 KiB
C#
61 lines
1.1 KiB
C#
using Godot;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Godot.Collections;
|
|
|
|
namespace Rokojori
|
|
{
|
|
|
|
[GlobalClass]
|
|
public partial class Pointable:RJPointable
|
|
{
|
|
List<RJPointer> _pointers = new List<RJPointer>();
|
|
|
|
public override int NumPointing()
|
|
{
|
|
return _pointers.Count;
|
|
}
|
|
|
|
public bool IsPointedBy( RJPointer pointer )
|
|
{
|
|
return _pointers.Contains( pointer );
|
|
}
|
|
|
|
public override void UpdatePointerState( RJPointer pointer, bool pointed )
|
|
{
|
|
var isCurrentlyPointed = IsPointedBy( pointer );
|
|
|
|
if ( isCurrentlyPointed == pointed )
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
if ( pointed )
|
|
{
|
|
_pointers.Add( pointer );
|
|
Actions.Trigger( OnPointerAdded );
|
|
|
|
if ( _pointers.Count == 1 )
|
|
{
|
|
Actions.Trigger( OnPointed );
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
_pointers.Remove( pointer );
|
|
|
|
Actions.Trigger( OnPointerRemoved );
|
|
|
|
if ( _pointers.Count == 0 )
|
|
{
|
|
Actions.Trigger( OnUnpointed );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
} |