Add attribute system with core stats and gameplay components

This commit is contained in:
2025-10-13 12:10:45 +02:00
commit ce3596efaa
55 changed files with 1161 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
using GameCore.Combat.Effects;
using GameCore.ECS;
using GameCore.ECS.Interfaces;
using GameCore.Events;
using GameCore.Input;
using GameCore.Movement;
using GameCore.Physics;
namespace GameCore.Combat;
public class WeaponSystem : ISystem
{
public void Update(World world, float deltaTime)
{
var entities = world.GetEntitiesWith<InputStateComponent>();
foreach (var entity in entities)
{
var input = world.GetComponent<InputStateComponent>(entity);
var weapon = world.GetComponent<WeaponComponent>(entity);
var position = world.GetComponent<PositionComponent>(entity);
var rotation = world.GetComponent<RotationComponent>(entity);
if (input == null || weapon == null || position == null || rotation == null)
continue;
if (weapon.CooldownTimer > 0f) weapon.CooldownTimer -= deltaTime;
if (input.IsFiring && weapon.CooldownTimer <= 0f)
{
var context = new EffectContext { World = world, Owner = entity };
foreach (var effect in weapon.OnFireEffects) effect.Execute(context);
world.PublishEvent(new WeaponFiredEvent(entity, input.MuzzlePosition));
weapon.CooldownTimer = 1f / weapon.FireRate;
}
}
}
}