-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameModule.cs
78 lines (63 loc) · 2.65 KB
/
GameModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Space.Assets;
using Space.Bullets;
using Space.Game;
using Space.Hud;
using Space.Invaders;
using Space.Player;
using Space.Shields;
using Space.Splash;
using Titan.Core.Maths;
using Titan.ECS.Components;
using Titan.Modules;
using Titan.Setup;
namespace Space;
internal struct GameModule : IModule
{
private static readonly Size OriginalBoardSize = new(224, 256);
private const uint InvaderRows = 5;
private const uint InvaderColumns = 11;
private const float InvaderMinShootingCooldown = 2f;
private const float InvaderMaxShootingCooldown = 3f;
private const int MaxLives = 3;
public static bool Build(IAppBuilder builder)
{
builder
.AddComponent<PlayerComponent>(5, ComponentPoolType.Packed)
.AddComponent<ScoreComponent>(5, ComponentPoolType.Packed)
.AddComponent<ShieldComponent>(10, ComponentPoolType.Packed)
.AddComponent<InvaderComponent>(100, ComponentPoolType.Packed)
.AddComponent<BulletComponent>(100, ComponentPoolType.Packed) // bullet component has smaller size than the entity id.
.AddComponent<LivesComponent>(5, ComponentPoolType.Packed)
.AddComponent<ExplosionComponent>(100, ComponentPoolType.Packed)
.AddSystem<SplashSystem>()
.AddSystem<GameOverSystem>()
.AddSystem<GameStartupSystem>()
.AddSystem<GameCameraSystem>()
.AddSystem<ScoreSystem>()
.AddSystem<LevelCompletedSystem>()
.AddSystem<ShieldSpawnSystem>()
.AddSystem<ShieldDamageSystem>()
.AddSystem<InvaderSpawnSystem>()
.AddSystem<InvaderMovementSystem>()
.AddSystem<InvaderDamageSystem>()
.AddSystem<InvaderShootingSystem>()
.AddSystem<InvaderAnimationSystem>()
.AddSystem<PlayerShootingSystem>()
.AddSystem<PlayerHitSystem>()
.AddSystem<PlayerMovementSystem>()
.AddSystem<PlayerDamageSystem>()
.AddSystem<PlayerSpawnSystem>()
.AddSystem<BulletSystem>()
.AddSystem<CameraShakeSystem>()
.AddSystem<ExplosionSystem>()
.AddSystem<HudSystem>()
.AddSystem<ScoreDispaySystem>()
.AddSystem<LivesDisplaySystem>()
.AddResource(new GameState(OriginalBoardSize, InvaderRows, InvaderColumns, InvaderMinShootingCooldown, InvaderMaxShootingCooldown, MaxLives) { CurrentState = GameStateTypes.Splash })
.AddAssetsManifest<AssetRegistry.Manifest>()
;
return true;
}
public static bool Init(IApp app) => true;
public static bool Shutdown(IApp app) => true;
}