Add attribute system with core stats and gameplay components
This commit is contained in:
23
GameCore/Movement/GravitySystem.cs
Normal file
23
GameCore/Movement/GravitySystem.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Physics;
|
||||
|
||||
namespace GameCore.Movement;
|
||||
|
||||
public class GravitySystem : ISystem
|
||||
{
|
||||
public void Update(World world, float deltaTime)
|
||||
{
|
||||
var entities = world.GetEntitiesWith<VelocityComponent>();
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
var velocity = world.GetComponent<VelocityComponent>(entity);
|
||||
var characterState = world.GetComponent<CharacterStateComponent>(entity);
|
||||
|
||||
if (velocity == null || characterState == null)
|
||||
continue;
|
||||
|
||||
if (!characterState.IsOnFloor) velocity.DesiredVelocity.Y -= world.Config.GravityStrength * deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user