30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using Encompass;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using PongFE.Components;
|
|
using PongFE.Messages;
|
|
|
|
namespace PongFE.Spawners
|
|
{
|
|
public class BallSpawner : Spawner<BallSpawnMessage>
|
|
{
|
|
private Texture2D WhitePixel { get; }
|
|
|
|
public BallSpawner(Texture2D whitePixel)
|
|
{
|
|
WhitePixel = whitePixel;
|
|
}
|
|
|
|
protected override void Spawn(BallSpawnMessage message)
|
|
{
|
|
var ball = CreateEntity();
|
|
AddComponent(ball, new PositionComponent(message.Position));
|
|
AddComponent(ball, new VelocityComponent(message.Velocity));
|
|
AddComponent(ball, new CollisionComponent(new MoonTools.Bonk.Rectangle(0, 0, 16, 16)));
|
|
AddComponent(ball, new Texture2DComponent(WhitePixel, 0, new System.Numerics.Vector2(message.Width, message.Height)));
|
|
AddComponent(ball, new CanBeBouncedComponent());
|
|
AddComponent(ball, new BounceResponseComponent());
|
|
AddComponent(ball, new CanBeTrackedComponent());
|
|
}
|
|
}
|
|
}
|