@@ -10,55 +10,86 @@ import "maps/particles/move" as particle_move
1010import "maps/particles/clutter_sphere" as clutter_sphere
1111
1212var g_input : InputSystem = undefined;
13- var g_world : World = undefined ;
13+ var g_world : ? World = null ;
1414
1515enum WorldType {
16+ NONE,
17+ MAIN,
1618 DEMO,
1719 LIGHTNING,
1820 PARTICLES,
1921}
2022
21- var world_type : WorldType = .DEMO ;
23+ var world_type : WorldType = .NONE ;
2224
2325fn start(input : InputSystem) : void {
2426 g_input = input;
2527
26- for i in 0..g_world.getPartitionCount() {
27- const handle = g_world.getPartitionHandle(i);
28- const name = g_world.getPartitionName(handle);
29- if endsWith(name, "demo.unv") {
30- world_type = .DEMO;
31- demo.start(g_world);
32- player.init(g_world, g_input);
33- break;
34- }
35- if endsWith(name, "lightning.unv") {
36- const source_value = g_world.findByName("core");
37- if const source = source_value {
38- world_type = .LIGHTNING;
39- lightning.start(g_world, source);
28+ if const world = g_world {
29+ for i in 0..world.getPartitionCount() {
30+ const handle = world.getPartitionHandle(i);
31+ const name = world.getPartitionName(handle);
32+ if endsWith(name, "demo.unv") {
33+ world_type = .DEMO;
34+ demo.start(world);
35+ player.init(world, g_input);
36+ break;
4037 }
41- break;
42- }
43- if endsWith(name, "particles.unv") {
44- const moving = g_world.findByName("world_space_particle");
45- const clutter = g_world.findByName("clutter");
46- if const moving_entity = moving {
47- if const clutter_entity = clutter {
48- if const clutter_child = clutter_entity.getFirstChild() {
49- world_type = .PARTICLES;
50- particle_move.start(moving_entity);
51- clutter_sphere.start(clutter_child, clutter_entity);
38+ if endsWith(name, "lightning.unv") {
39+ const source_value = world.findByName("core");
40+ if const source = source_value {
41+ world_type = .LIGHTNING;
42+ lightning.start(world, source);
43+ }
44+ break;
45+ }
46+ if endsWith(name, "particles.unv") {
47+ const moving = world.findByName("world_space_particle");
48+ const clutter = world.findByName("clutter");
49+ if const moving_entity = moving {
50+ if const clutter_entity = clutter {
51+ if const clutter_child = clutter_entity.getFirstChild() {
52+ world_type = .PARTICLES;
53+ particle_move.start(moving_entity);
54+ clutter_sphere.start(clutter_child, clutter_entity);
55+ }
5256 }
5357 }
58+ break;
5459 }
55- break;
5660 }
5761 }
62+ else {
63+ panic("Unknown world");
64+ }
5865}
5966
6067fn update(td : f32) : void {
6168 match world_type {
69+ case .NONE:
70+ case .MAIN:
71+ panic("TODO"); //TODO
72+ for event in g_input.getEvents() {
73+ match event {
74+ case ButtonEvent:
75+ if event.device_type == .KEYBOARD {
76+ }
77+ case:
78+ }
79+ }
80+ //if not loaded and event.type == "button" then
81+ // if event.device.type == "keyboard" then
82+ // local old_partition = this.world:getActivePartition()
83+ // local demo = this.world:createPartition("demo")
84+ // this.world:setActivePartition(demo)
85+ // this.world:load("maps/demo/demo.unv", function()
86+ // this.world.ui:load("maps/demo/demo.ui")
87+ // --this.world:destroyPartition(old_partition)
88+ // end)
89+ //
90+ // loaded = true
91+ // end
92+ // end
6293 case .DEMO: demo.update(td, g_input);
6394 case .LIGHTNING: lightning.update(td);
6495 case .PARTICLES:
0 commit comments