using UnityEngine; public class Entity : MonoBehaviour { [Header("Identification")] public string entityName; public SpriteRenderer sprite; [Header("Flags")] public bool stalled; public bool invincible; [Header("Stats")] public float health; public float maxHealth; [Header("Movement")] [SerializeField] private bool isFacingRight; [SerializeField] protected Rigidbody2D rb; protected Vector2 moveDirection; public float speed; protected void FlipSprite(Vector2 lookDirection) { if (lookDirection.x < 0f && isFacingRight) { sprite.flipX = true; isFacingRight = !isFacingRight; } else if (lookDirection.x > 0f && !isFacingRight) { sprite.flipX = false; isFacingRight = !isFacingRight; } } protected virtual void FixedUpdate() { if (!stalled) { rb.linearVelocity = moveDirection * speed; } } public void TakeDamage(float damage) { health -= damage; health = Mathf.Clamp(health, 0, maxHealth); if (health < 0) { OnKillEffects(); } } public void Heal(float healingAmount) { health += healingAmount; health = Mathf.Clamp(health, 0, maxHealth); } protected virtual void OnKillEffects() { } }