PongFE/PongFE/Engines/DestroyEngine.cs

28 lines
702 B
C#
Raw Normal View History

2020-07-15 21:00:55 +00:00
using Encompass;
using PongFE.Components;
using PongFE.Messages;
namespace PongFE.Engines
{
2020-07-16 21:39:36 +00:00
[Reads(
typeof(IncreaseScoreAfterDestroyComponent)
)]
2020-07-15 21:00:55 +00:00
[Receives(typeof(DestroyMessage))]
2020-07-20 03:16:15 +00:00
[Sends(typeof(ScoreMessage))]
2020-07-15 21:00:55 +00:00
public class DestroyEngine : Engine
{
public override void Update(double dt)
{
foreach (ref readonly var message in ReadMessages<DestroyMessage>())
{
2020-07-16 21:39:36 +00:00
if (HasComponent<IncreaseScoreAfterDestroyComponent>(message.Entity))
{
SendMessage(new ScoreMessage(message.DestroyedBy));
}
2020-07-15 21:00:55 +00:00
Destroy(message.Entity);
}
}
}
}