Add attribute system with core stats and gameplay components
This commit is contained in:
33
GameCore/Combat/ProjectileInitializationSystem.cs
Normal file
33
GameCore/Combat/ProjectileInitializationSystem.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using GameCore.ECS;
|
||||
using GameCore.ECS.Interfaces;
|
||||
using GameCore.Events;
|
||||
|
||||
namespace GameCore.Combat;
|
||||
|
||||
public class ProjectileInitializationSystem : ISystem
|
||||
{
|
||||
private readonly World _world;
|
||||
|
||||
public ProjectileInitializationSystem(World world)
|
||||
{
|
||||
_world = world;
|
||||
_world.Subscribe<EntitySpawnedEvent>(OnEntitySpawned);
|
||||
}
|
||||
|
||||
public void Update(World world, float deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnEntitySpawned(EntitySpawnedEvent e)
|
||||
{
|
||||
var projComp = _world.GetComponent<ProjectileComponent>(e.NewEntity);
|
||||
if (projComp == null) return;
|
||||
|
||||
var ownerWeapon = _world.GetComponent<WeaponComponent>(e.Owner);
|
||||
if (ownerWeapon != null)
|
||||
{
|
||||
projComp.Owner = e.Owner;
|
||||
projComp.OnHitEffects = ownerWeapon.OnHitEffects;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user