-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLevelScene.cs
More file actions
86 lines (73 loc) · 3.26 KB
/
LevelScene.cs
File metadata and controls
86 lines (73 loc) · 3.26 KB
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
79
80
81
82
83
84
85
86
using System.Numerics;
using Walgelijk;
using Walgelijk.Onion;
using Walgelijk.ParticleSystem;
using Walgelijk.Physics;
namespace MadnessMicroactive;
public static class LevelScene
{
public static Scene Create(Game game, Levels.Level level)
{
var scene = new Scene(game);
scene.ShouldBeDisposedOnSceneChange = false; //TODO should be true but there is an engine bug... somewhere
scene.AddSystem(new BatchRendererSystem());
scene.AddSystem(new AiControllerSystem());
scene.AddSystem(new PlayerControllerSystem());
scene.AddSystem(new WeaponSystem());
scene.AddSystem(new BulletSystem());
scene.AddSystem(new CharacterSystem());
scene.AddSystem(new CharacterApparelSystem());
scene.AddSystem(new PlayerUiSystem());
scene.AddSystem(new EquippableSystem()); // after character system because equippables position themselves
scene.AddSystem(new PhysicsSystem());
//scene.AddSystem(new PhysicsDebugSystem());
scene.AddSystem(new ParticleSystem());
scene.AddSystem(new TransformSystem());
scene.AddSystem(new MuzzleflashSystem());
scene.AddSystem(new LevelBackgroundSystem());
scene.AddSystem(new LevelProgressSystem());
scene.AddSystem(new EnemySpawnerSystem());
scene.AddSystem(new RoutineSystem());
scene.AddSystem(new DeathSequenceSystem());
scene.AddSystem(new OnionSystem());
scene.AddSystem(new MusicSystem());
scene.AddSystem(new BossSystem());
scene.AddSystem(new CameraSystem() { ExecutionOrder = -1 });
scene.AttachComponent(scene.CreateEntity(), new PhysicsWorldComponent { ChunkSize = 128 });
scene.AttachComponent(scene.CreateEntity(), new LevelProgressComponent());
scene.AttachComponent(scene.CreateEntity(), new BatchRendererStorageComponent());
scene.AttachComponent(scene.CreateEntity(), level.LevelComponent);
var camera = scene.CreateEntity();
scene.AttachComponent(camera, new TransformComponent()
{
Position = new Vector2(0, game.Window.Height / 2)
});
scene.AttachComponent(camera, new CameraComponent()
{
ClearColour = new Color(76, 76, 76),
OrthographicSize = 1,
PixelsPerUnit = 1
});
Prefabs.CreatePlayer(scene);
var casingMat = ParticleMaterialInitialiser.CreateDefaultMaterial();
casingMat.SetUniform("mainTex", Resources.Load<Texture>("casing.png"));
MandessUtils.CreateCasingEjectionParticleSystem(scene, casingMat);
level.Init?.Invoke(scene);
return scene;
}
[Command]
public static CommandResult Revive(bool force = false)
{
var s = Game.Main.Scene;
if (s.FindAnyComponent<PlayerControllerComponent>(out var player))
{
var character = s.GetComponentFrom<CharacterComponent>(player.Entity);
character.Revive();
}
else if (s.HasSystem<PlayerControllerSystem>())
Prefabs.CreatePlayer(s);
else if (!force)
return CommandResult.Error("No player controller system found. You probably shouldn't revive here. Pass true to force a revive anyway.");
return "I will keep bringing them back";
}
}