25 lines
751 B
C#
25 lines
751 B
C#
using Encompass;
|
|
using PongFE.Components;
|
|
using PongFE.Messages;
|
|
|
|
namespace PongFE.Engines
|
|
{
|
|
[Reads(typeof(ScoreComponent))]
|
|
[Receives(typeof(ScoreMessage))]
|
|
[Writes(typeof(ScoreComponent))]
|
|
public class ScoreEngine : Engine
|
|
{
|
|
public override void Update(double dt)
|
|
{
|
|
foreach (ref readonly var scoreMessage in ReadMessages<ScoreMessage>())
|
|
{
|
|
if (HasComponent<ScoreComponent>(scoreMessage.Entity))
|
|
{
|
|
ref readonly var scoreComponent = ref GetComponent<ScoreComponent>(scoreMessage.Entity);
|
|
SetComponent(scoreMessage.Entity, new ScoreComponent(scoreComponent.Score + 1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|