remove unnecessary class vars

main
Evan Hemsley 2020-07-19 19:00:24 -07:00
parent 1c57a4a79f
commit b2198f448b
2 changed files with 15 additions and 20 deletions

View File

@ -6,7 +6,7 @@ using PongFE.Messages;
namespace PongFE.Engines
{
[Reads(typeof(GameStateComponent))]
[Reads(typeof(GameStateComponent), typeof(PlayAreaComponent))]
[Receives(typeof(ChangeGameStateMessage))]
[Sends(
typeof(BallSpawnMessage),
@ -17,15 +17,6 @@ namespace PongFE.Engines
[Writes(typeof(GameStateComponent))]
public class GameStateEngine : Engine
{
private int PlayAreaWidth { get; }
private int PlayAreaHeight { get; }
public GameStateEngine(int playAreaWidth, int playAreaHeight)
{
PlayAreaWidth = playAreaWidth;
PlayAreaHeight = playAreaHeight;
}
public override void Update(double dt)
{
ref readonly var gameStateEntity = ref ReadEntity<GameStateComponent>();
@ -66,9 +57,13 @@ namespace PongFE.Engines
private void StartGame()
{
ref readonly var playAreaComponent = ref ReadComponent<PlayAreaComponent>();
var playAreaWidth = playAreaComponent.Width;
var playAreaHeight = playAreaComponent.Height;
SendMessage(
new PaddleSpawnMessage(
new MoonTools.Structs.Position2D(20, PlayAreaHeight / 2 - 40),
new MoonTools.Structs.Position2D(20, playAreaHeight / 2 - 40),
Enums.PlayerIndex.One,
PaddleControl.Player,
20,
@ -78,7 +73,7 @@ namespace PongFE.Engines
SendMessage(
new PaddleSpawnMessage(
new MoonTools.Structs.Position2D(PlayAreaWidth - 45, PlayAreaHeight / 2 - 40),
new MoonTools.Structs.Position2D(playAreaWidth - 45, playAreaHeight / 2 - 40),
Enums.PlayerIndex.Two,
PaddleControl.Computer,
20,
@ -88,7 +83,7 @@ namespace PongFE.Engines
SendMessage(
new BallSpawnMessage(
new MoonTools.Structs.Position2D(PlayAreaWidth / 2, PlayAreaHeight / 2),
new MoonTools.Structs.Position2D(playAreaWidth / 2, playAreaHeight / 2),
500,
16,
16
@ -100,7 +95,7 @@ namespace PongFE.Engines
SendMessage(
new BoundarySpawnMessage(
new MoonTools.Structs.Position2D(0, -6),
PlayAreaWidth,
playAreaWidth,
6
)
);
@ -108,8 +103,8 @@ namespace PongFE.Engines
// bottom boundary
SendMessage(
new BoundarySpawnMessage(
new MoonTools.Structs.Position2D(0, PlayAreaHeight),
PlayAreaWidth,
new MoonTools.Structs.Position2D(0, playAreaHeight),
playAreaWidth,
6
)
);
@ -118,9 +113,9 @@ namespace PongFE.Engines
SendMessage(
new GoalBoundarySpawnMessage(
Enums.PlayerIndex.One,
new MoonTools.Structs.Position2D(PlayAreaWidth, 0),
new MoonTools.Structs.Position2D(playAreaWidth, 0),
6,
PlayAreaHeight
playAreaHeight
)
);
@ -130,7 +125,7 @@ namespace PongFE.Engines
Enums.PlayerIndex.Two,
new MoonTools.Structs.Position2D(-6, 0),
6,
PlayAreaHeight
playAreaHeight
)
);
}

View File

@ -69,7 +69,7 @@ namespace PongFE
48
);
WorldBuilder.AddEngine(new GameStateEngine(PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT));
WorldBuilder.AddEngine(new GameStateEngine());
WorldBuilder.AddEngine(new InputEngine());
WorldBuilder.AddEngine(new PaddleMovementEngine());
WorldBuilder.AddEngine(new VelocityEngine());