# scheduler
```typescript=
export class Schedule {
ordered_systems: GroupSystemsPair[]
}
```
```typescript=
import { World } from "vang"
import { Order, Group, UpdateGroup } from "vang/groups";
type Updateable = {
update(world:World): any;
}
type SystemRef = Updateable & { system: System };
function create_system_ref(system: System) {
return {
update: system,
system
}
}
const GROUP_INFO_KEY = Symbol("groupinfo")
type GroupInfo = {
order: GroupOrder;
}
abstract class Group implements Updateable {
readonly members: Updateable[];
public update(world: World) {
for(let i = 0; i < this.members.length; i++) {
this.members.update[i];
}
}
}
@Order({ after: UpdateGroup })
export class FixedUpdateGroup extends Group {
private accumulator: number = 0;
public update(world: World) {
accumulator += world.resource(Time).dt;
// running fixed timestep catch-up
while (accumulator >= fixedTimeStep) {
// update every member in the group
super.update(world)
// next step
accumulator -= fixedTimeStep;
}
}
}
@Order({ after: UpdateGroup })
export class UpdateGroup extends Group {}
@Order({ priority: 999999999999, in: UpdateGroup })
export class VeryLateGroup extends Group {}
export function example_system2 {
for(const [p,v] of query(Pos, Vel)) {
}
}
```
```typescript=
type GroupPair = [name: "UpdateTestGroup", order: { after: UpdateGroup }];
WorldBuilder
.groups(...groups: Group | string | GroupPair)
WorldBuilder
.systems(...params: [string, ...systems: Systems] | ...systems: Systems)
WorldBuilder
.resources(...resources: (Resource | ResourceInstance)[])
WorldBuilder
.plugins(...plugins: Plugin[])
WorldBuilder
.with(options: Partial<WorldOptions>)
WorldBuilder
.done() -> World
```
```typescript=
export class MyCustomGroup extends Group {}
public enum VangGroups = {
Start = "start-group",
End = "end-group"
}
const MyFixedStage = new FixedUpdateStage({
rate: 0.016,
systems: [test_system23, my_system11]
});
World.build()
.systems(Groups.Update, test_system, my_system)
.group_after(Groups.Update, VangGroups.End, new MyCustomGroup(
test_system23, my_system11
))
.group_after(Groups.Update, "test", MyFixedStage)
.group_before(Groups.Update, VangGroups.Start)
.systems(VangGroups.Start, ok_system, net_system)
```
## plugin dependency
need to figure out dependency between plugins??
## example goal
### client
```typescript=
import { World, query } from "vang";
import { Vang3DPlugin } from "@vang/std/3d"
const world = World.build()
.systems(move_system)
.plugins(Vang3DPlugin)
.done();
await world.init();
function loop() {
world.update();
requestAnimation(loop)
}
requestAnimation(loop);
```
### server
```typescript=
import { World, query } from "vang";
import { Vang3DPlugin } from "@vang/std/3d"
const world = World.build()
.systems(move_system)
.plugins(Vang3DPlugin)
.done();
await world.init();
function loop() {
world.update();
requestAnimation(loop)
}
requestAnimation(loop);
```