mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
little explosions and fixed more bugs in the ecs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using JamGame.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using MonoGame.Extended;
|
||||
using MonoGame.Extended.Entities;
|
||||
using MonoGame.Extended.Entities.Systems;
|
||||
|
||||
@@ -7,11 +8,13 @@ namespace JamGame.Systems
|
||||
{
|
||||
public class CollisionResponseSystem : EntityProcessingSystem
|
||||
{
|
||||
private readonly EntityFactory _entityFactory;
|
||||
private ComponentMapper<Body> _bodyMapper;
|
||||
|
||||
public CollisionResponseSystem()
|
||||
: base(Aspect.All(typeof(Body)))
|
||||
public CollisionResponseSystem(EntityFactory entityFactory)
|
||||
: base(Aspect.All(typeof(Body), typeof(Transform2)))
|
||||
{
|
||||
_entityFactory = entityFactory;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponentMapperService mapperService)
|
||||
@@ -28,10 +31,17 @@ namespace JamGame.Systems
|
||||
var entity = GetEntity(entityId);
|
||||
|
||||
if (entity.Has<Projectile>())
|
||||
{
|
||||
_entityFactory.SpawnExplosion(entity.Get<Transform2>().Position, body.Velocity / 2f);
|
||||
entity.Destroy();
|
||||
}
|
||||
|
||||
|
||||
if (entity.Has<Enemy>())
|
||||
{
|
||||
_entityFactory.SpawnExplosion(entity.Get<Transform2>().Position, body.Velocity / 2f);
|
||||
entity.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user