using Pausable; using UnityEngine; namespace AI { [RequireComponent(typeof(Rigidbody2D))] public class Projectile : MonoBehaviour, IPausable { private Rigidbody2D _rigidbody = null; private void Awake() { _rigidbody = GetComponent(); } public void SetVelocity(Vector2 velocity) { _rigidbody.velocity = velocity; } private void OnCollisionEnter2D(Collision2D other) { ProjectilePool.Instance.Return(this); if (other.transform.CompareTag("Player")) other.gameObject.GetComponent().Die(); } public bool IsPaused { get; protected set; } = false; public void Pause() { IsPaused = true; UpdateRigidbody(); } public void Resume() { IsPaused = false; UpdateRigidbody(); } private void UpdateRigidbody() { _rigidbody.simulated = !IsPaused; } } }