using GameCore.Attributes; using GameCore.ECS; using GameCore.ECS.Interfaces; using GameCore.Events; using GameCore.Input; using GameCore.Physics; using Attribute = GameCore.Attributes.Attribute; namespace GameCore.Movement; public class JumpSystem : ISystem { public void Update(World world, float deltaTime) { var entities = world.GetEntitiesWith(); foreach (var entity in entities) { var input = world.GetComponent(entity); var velocity = world.GetComponent(entity); var attributes = world.GetComponent(entity); var characterState = world.GetComponent(entity); if (input == null || velocity == null || attributes == null || characterState == null) continue; if (input.IsJumping && characterState.IsOnFloor) { var jumpHeight = attributes.GetValue(Attribute.JumpHeight); velocity.DesiredVelocity.Y = (float)System.Math.Sqrt(2f * world.Config.GravityStrength * jumpHeight); world.PublishEvent(new PlayerJumpEvent()); } } } }