using Godot; using System; public partial class IQBasedEnemy : RigidBody2D { // Enemy Stats public int IQ; public float HP; public float MaxHP; // Enemy Conditions float CurrentYVelocity; float PreviousYVelocity; public bool IsGrounded; // Enemy Abilities public override void _Ready() { IQ = (int)GetMeta("IQ"); // Read IQ MaxHP = (float)GetMeta("MaxHP"); // Get Max HP if (IQ >= 100) MaxHP += 20; HP = MaxHP; CurrentYVelocity = 0f; PreviousYVelocity = 0f; IsGrounded = true; } public override void _Process(double delta) { // Ground Detection CurrentYVelocity = LinearVelocity[1]; if (CurrentYVelocity == 0 && PreviousYVelocity == 0) IsGrounded = true; else IsGrounded = false; PreviousYVelocity = CurrentYVelocity; } }