using Godot; using System; using System.Runtime.CompilerServices; public partial class Contact : Sprite2D { public bool _clickable = false, _interval = false; public int _number, _calls = 0, _maxCalls = 0; public Timer _timer, _cooldown; public Action _action; public Actor _owner; public override void _Ready() { _timer = GetNode("Timer"); _cooldown = GetNode("Cooldown"); _action = GetNode("Action"); _action._contact = this; } public virtual void CallAction() { if (_cooldown.TimeLeft == 0 || _action._cooldownSeconds == 0) { GD.Print("Action fired!!"); _action.Fire(); } } public void PassNumber(int NUMBER) { _number = NUMBER; } public void PassOwner(Actor OWNER) { _owner = OWNER; } public void SetTimer(float SECONDS) { _action._timerSeconds = SECONDS; _interval = true; _clickable = false; } public void SetCooldown(float SECONDS) { _action._cooldownSeconds = SECONDS; _interval = false; _clickable = true; } public void Start() { // GD.Print(_action._timerSeconds); if (_action._timerSeconds > 0) { _timer.Start(_action._timerSeconds); _calls = 0; } } private void OnTimerTimeout() { if (_calls <= _maxCalls || _maxCalls == 0) { CallAction(); _timer.Start(_action._timerSeconds); _calls++; } } private void OnCooldownTimeout() { } }