23 lines
687 B
C#
23 lines
687 B
C#
using GameCore.ECS;
|
|
using GameCore.ECS.Interfaces;
|
|
|
|
namespace GameCore.Attributes;
|
|
|
|
public class AttributeSystem : ISystem
|
|
{
|
|
public void Update(World world, float deltaTime)
|
|
{
|
|
var entities = world.GetEntitiesWith<AttributeComponent>();
|
|
|
|
foreach (var entity in entities)
|
|
{
|
|
var attributes = world.GetComponent<AttributeComponent>(entity);
|
|
if (attributes == null) continue;
|
|
|
|
var maxHealth = attributes.GetValue(Attribute.MaxHealth);
|
|
var currentHealth = attributes.GetValue(Attribute.Health);
|
|
|
|
if (currentHealth > maxHealth) attributes.SetCurrentValue(Attribute.Health, maxHealth);
|
|
}
|
|
}
|
|
} |