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

View File

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