made an action be owned by a contact instead of actor; made another example action

This commit is contained in:
2026-02-02 17:51:12 -05:00
parent 7095a140a0
commit 36b934b200
6 changed files with 39 additions and 9 deletions

View File

@@ -4,7 +4,7 @@ using System.Runtime.CompilerServices;
public partial class Contact : Sprite2D
{
public bool _clickable, _interval;
public bool _clickable = false, _interval = false;
public int _number, _calls = 0, _maxCalls = 0;
public Timer _timer, _cooldown;
public Action _action;
@@ -15,11 +15,12 @@ public partial class Contact : Sprite2D
_timer = GetNode<Timer>("Timer");
_cooldown = GetNode<Timer>("Cooldown");
_action = GetNode<Action>("Action");
_action._contact = this;
}
public virtual void CallAction()
{
if (_cooldown.TimeLeft > 0 || _action._cooldownSeconds == 0)
if (_cooldown.TimeLeft == 0 || _action._cooldownSeconds == 0)
{
GD.Print("Action fired!!");
_action.Fire();
@@ -33,17 +34,20 @@ public partial class Contact : Sprite2D
public void PassOwner(Actor OWNER)
{
_owner = OWNER;
_action._owner = OWNER;
}
public void SetTimer(float SECONDS)
{
_action._timerSeconds = SECONDS;
_interval = true;
_clickable = false;
}
public void SetCooldown(int SECONDS)
public void SetCooldown(float SECONDS)
{
_action._cooldownSeconds = SECONDS;
_interval = false;
_clickable = true;
}
public void Start()