Checkpoint

This commit is contained in:
2026-03-19 21:34:27 +01:00
parent 5b8fecd593
commit 532ede9714
9 changed files with 531 additions and 19 deletions

View File

@@ -1,16 +1,35 @@
using UnityEngine;
using UnityEngine.Events;
public class Checkpoint : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
public static Checkpoint Active { get; private set; }
[SerializeField] private bool _isDefault;
[SerializeField] private UnityEvent _onActivated;
[SerializeField] private UnityEvent _onDisable;
public void Activate()
{
if (Active)
Active.Disable();
Active = this;
_onActivated?.Invoke();
}
// Update is called once per frame
void Update()
public void Disable()
{
if (Active == this)
{
Active = null;
_onDisable?.Invoke();
}
}
void Awake()
{
if (_isDefault)
Activate();
}
}