Add attribute system with core stats and gameplay components
This commit is contained in:
25
GameCore/Combat/ProjectileCleanupSystem.cs
Normal file
25
GameCore/Combat/ProjectileCleanupSystem.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Physics;
|
||||
|
||||
namespace GameCore.Combat;
|
||||
|
||||
public class ProjectileCleanupSystem : ISystem
|
||||
{
|
||||
public void Update(World world, float deltaTime)
|
||||
{
|
||||
var projectiles = world.GetEntitiesWith<ProjectileComponent>();
|
||||
foreach (var projectile in projectiles)
|
||||
{
|
||||
var projectileData = world.GetComponent<ProjectileComponent>(projectile);
|
||||
var position = world.GetComponent<PositionComponent>(projectile);
|
||||
var velocity = world.GetComponent<VelocityComponent>(projectile);
|
||||
|
||||
if (projectileData == null || position == null || velocity == null)
|
||||
continue;
|
||||
|
||||
projectileData.Lifetime -= deltaTime;
|
||||
if (projectileData.Lifetime <= 0f) world.AddComponent(projectile, new DeathComponent());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user