using System.Collections; using Unity.Netcode; using UnityEngine; namespace Game { public abstract class Collectable : NetworkBehaviour { private void OnTriggerEnter2D(Collider2D other) { var player = other.GetComponent().LastContactPlayer; if (player != null) { Destroy(gameObject); OnCollect(player); } } private IEnumerator Start() { Setup(); yield return new WaitForSeconds(Duration()); Destroy(gameObject); } protected abstract void Setup(); protected abstract float Duration(); protected abstract void OnCollect(Player collector); } }