Documentation
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
// Generated by `wit-bindgen` 0.54.0. DO NOT EDIT!
//
// This code was generated from the following packages:
//     wasvy:ecs
//     component:go

package wasvy_ecs_app

import (
	witRuntime "go.bytecodealliance.org/pkg/wit/runtime"
	witTypes "go.bytecodealliance.org/pkg/wit/types"
	"runtime"
	"unsafe"
)

//go:wasmimport wasvy:ecs/app [resource-drop]app
func resourceDropApp(handle int32)

// This is an interface (similar to bevy::App) through which mods may interact with the Bevy App.
//
// To access this, make sure to import the 'guest' world and implement `setup`.
type App struct {
	handle *witRuntime.Handle
}

func (self *App) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *App) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *App) Handle() int32 {
	return self.handle.Use()
}

func (self *App) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropApp(handle)
	}
}

func AppFromOwnHandle(handleValue int32) *App {
	handle := witRuntime.MakeHandle(handleValue)
	value := &App{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropApp(handleValue)
		}
	}, 0)
	return value
}

func AppFromBorrowHandle(handleValue int32) *App {
	handle := witRuntime.MakeHandle(handleValue)
	return &App{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]system
func resourceDropSystem(handle int32)

// An interface with which to define a new system for the host.
//
// Usage:
// 1. Construct a new system, giving it a unique name
// 2. Add system-params by calling 0 or more add-* methods
// 3. Order the system relative to others
// 4. Add the system to a schedule
type System struct {
	handle *witRuntime.Handle
}

func (self *System) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *System) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *System) Handle() int32 {
	return self.handle.Use()
}

func (self *System) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropSystem(handle)
	}
}

func SystemFromOwnHandle(handleValue int32) *System {
	handle := witRuntime.MakeHandle(handleValue)
	value := &System{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropSystem(handleValue)
		}
	}, 0)
	return value
}

func SystemFromBorrowHandle(handleValue int32) *System {
	handle := witRuntime.MakeHandle(handleValue)
	return &System{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]commands
func resourceDropCommands(handle int32)

// A `command` queue system param to perform structural changes to the world.
//
// Since each command requires exclusive access to the world,
// all queued commands are automatically applied in sequence.
//
// Each command can be used to modify the world in arbitrary ways:
// - spawning or despawning entities
// - inserting components on new or existing entities
// - etc.
type Commands struct {
	handle *witRuntime.Handle
}

func (self *Commands) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *Commands) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *Commands) Handle() int32 {
	return self.handle.Use()
}

func (self *Commands) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropCommands(handle)
	}
}

func CommandsFromOwnHandle(handleValue int32) *Commands {
	handle := witRuntime.MakeHandle(handleValue)
	value := &Commands{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropCommands(handleValue)
		}
	}, 0)
	return value
}

func CommandsFromBorrowHandle(handleValue int32) *Commands {
	handle := witRuntime.MakeHandle(handleValue)
	return &Commands{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]entity-commands
func resourceDropEntityCommands(handle int32)

// A list of commands that will be run to modify an `entity`.
type EntityCommands struct {
	handle *witRuntime.Handle
}

func (self *EntityCommands) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *EntityCommands) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *EntityCommands) Handle() int32 {
	return self.handle.Use()
}

func (self *EntityCommands) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropEntityCommands(handle)
	}
}

func EntityCommandsFromOwnHandle(handleValue int32) *EntityCommands {
	handle := witRuntime.MakeHandle(handleValue)
	value := &EntityCommands{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropEntityCommands(handleValue)
		}
	}, 0)
	return value
}

func EntityCommandsFromBorrowHandle(handleValue int32) *EntityCommands {
	handle := witRuntime.MakeHandle(handleValue)
	return &EntityCommands{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]entity
func resourceDropEntity(handle int32)

// An identifier for an entity.
type Entity struct {
	handle *witRuntime.Handle
}

func (self *Entity) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *Entity) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *Entity) Handle() int32 {
	return self.handle.Use()
}

func (self *Entity) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropEntity(handle)
	}
}

func EntityFromOwnHandle(handleValue int32) *Entity {
	handle := witRuntime.MakeHandle(handleValue)
	value := &Entity{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropEntity(handleValue)
		}
	}, 0)
	return value
}

func EntityFromBorrowHandle(handleValue int32) *Entity {
	handle := witRuntime.MakeHandle(handleValue)
	return &Entity{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]query
func resourceDropQuery(handle int32)

// A query system param
type Query struct {
	handle *witRuntime.Handle
}

func (self *Query) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *Query) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *Query) Handle() int32 {
	return self.handle.Use()
}

func (self *Query) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropQuery(handle)
	}
}

func QueryFromOwnHandle(handleValue int32) *Query {
	handle := witRuntime.MakeHandle(handleValue)
	value := &Query{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropQuery(handleValue)
		}
	}, 0)
	return value
}

func QueryFromBorrowHandle(handleValue int32) *Query {
	handle := witRuntime.MakeHandle(handleValue)
	return &Query{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]query-result
func resourceDropQueryResult(handle int32)

// A query system param
type QueryResult struct {
	handle *witRuntime.Handle
}

func (self *QueryResult) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *QueryResult) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *QueryResult) Handle() int32 {
	return self.handle.Use()
}

func (self *QueryResult) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropQueryResult(handle)
	}
}

func QueryResultFromOwnHandle(handleValue int32) *QueryResult {
	handle := witRuntime.MakeHandle(handleValue)
	value := &QueryResult{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropQueryResult(handleValue)
		}
	}, 0)
	return value
}

func QueryResultFromBorrowHandle(handleValue int32) *QueryResult {
	handle := witRuntime.MakeHandle(handleValue)
	return &QueryResult{handle}
}

//go:wasmimport wasvy:ecs/app [resource-drop]component
func resourceDropComponent(handle int32)

type Component struct {
	handle *witRuntime.Handle
}

func (self *Component) TakeHandle() int32 {
	return self.handle.Take()
}

func (self *Component) SetHandle(handle int32) {
	self.handle.Set(handle)
}

func (self *Component) Handle() int32 {
	return self.handle.Use()
}

func (self *Component) Drop() {
	handle := self.handle.TakeOrNil()
	if handle != 0 {
		resourceDropComponent(handle)
	}
}

func ComponentFromOwnHandle(handleValue int32) *Component {
	handle := witRuntime.MakeHandle(handleValue)
	value := &Component{handle}
	runtime.AddCleanup(value, func(_ int) {
		handleValue := handle.TakeOrNil()
		if handleValue != 0 {
			resourceDropComponent(handleValue)
		}
	}, 0)
	return value
}

func ComponentFromBorrowHandle(handleValue int32) *Component {
	handle := witRuntime.MakeHandle(handleValue)
	return &Component{handle}
}

// A fully-qualified type name
type TypePath = string

// JSON serialized version of the actual component that is being passed between WASM and Bevy.
// So for every instance of `component` make sure you deserialize it yourself to the struct that it actually is.
//
// Note: for components returned by query::optional this is an option<t>
type SerializedComponent = string

// Just a simple list of tuples composed of the type-path and the serialized component string
type Bundle = []witTypes.Tuple2[string, string]

// A bundle without the serialized components
type BundleTypes = []string

// Each query supports up to 255 components
type ComponentIndex = uint8

const (
	// A custom schedule that runs the first time a mod is loaded.
	//
	// Note this is not the same as Bevy's Startup schedule
	ScheduleModStartup uint8 = 0
	// Runs during the Bevy PreUpdate schedule
	SchedulePreUpdate uint8 = 1
	// Runs during the Bevy Update schedule
	ScheduleUpdate uint8 = 2
	// Runs during the Bevy PostUpdate schedule
	SchedulePostUpdate uint8 = 3
	// Runs during the Bevy FixedPreUpdate schedule
	ScheduleFixedPreUpdate uint8 = 4
	// Runs during the Bevy FixedUpdate schedule
	ScheduleFixedUpdate uint8 = 5
	// Runs during the Bevy FixedPostUpdate schedule
	ScheduleFixedPostUpdate uint8 = 6
	// Runs during the Bevy Update schedule
	ScheduleCustom uint8 = 7
)

type Schedule struct {
	tag   uint8
	value any
}

func (self Schedule) Tag() uint8 {
	return self.tag
}

func (self Schedule) Custom() string {
	if self.tag != ScheduleCustom {
		panic("tag mismatch")
	}
	return self.value.(string)
}

func MakeScheduleModStartup() Schedule {
	return Schedule{ScheduleModStartup, nil}
}
func MakeSchedulePreUpdate() Schedule {
	return Schedule{SchedulePreUpdate, nil}
}
func MakeScheduleUpdate() Schedule {
	return Schedule{ScheduleUpdate, nil}
}
func MakeSchedulePostUpdate() Schedule {
	return Schedule{SchedulePostUpdate, nil}
}
func MakeScheduleFixedPreUpdate() Schedule {
	return Schedule{ScheduleFixedPreUpdate, nil}
}
func MakeScheduleFixedUpdate() Schedule {
	return Schedule{ScheduleFixedUpdate, nil}
}
func MakeScheduleFixedPostUpdate() Schedule {
	return Schedule{ScheduleFixedPostUpdate, nil}
}
func MakeScheduleCustom(value string) Schedule {
	return Schedule{ScheduleCustom, value}
}

const (
	QueryForRef     uint8 = 0
	QueryForMut     uint8 = 1
	QueryForWith    uint8 = 2
	QueryForWithout uint8 = 3
)

type QueryFor struct {
	tag   uint8
	value any
}

func (self QueryFor) Tag() uint8 {
	return self.tag
}

func (self QueryFor) Ref() string {
	if self.tag != QueryForRef {
		panic("tag mismatch")
	}
	return self.value.(string)
}
func (self QueryFor) Mut() string {
	if self.tag != QueryForMut {
		panic("tag mismatch")
	}
	return self.value.(string)
}
func (self QueryFor) With() string {
	if self.tag != QueryForWith {
		panic("tag mismatch")
	}
	return self.value.(string)
}
func (self QueryFor) Without() string {
	if self.tag != QueryForWithout {
		panic("tag mismatch")
	}
	return self.value.(string)
}

func MakeQueryForRef(value string) QueryFor {
	return QueryFor{QueryForRef, value}
}
func MakeQueryForMut(value string) QueryFor {
	return QueryFor{QueryForMut, value}
}
func MakeQueryForWith(value string) QueryFor {
	return QueryFor{QueryForWith, value}
}
func MakeQueryForWithout(value string) QueryFor {
	return QueryFor{QueryForWithout, value}
}

//go:wasmimport wasvy:ecs/app [method]app.add-systems
func wasm_import_method_app_add_systems(arg0 int32, arg1 int32, arg2 uintptr, arg3 uint32, arg4 uintptr, arg5 uint32)

func (self *App) AddSystems(schedule Schedule, systems []*System) {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	var variant int32
	var variant0 uintptr
	var variant1 uint32
	switch schedule.Tag() {
	case ScheduleModStartup:

		variant = int32(0)
		variant0 = 0
		variant1 = 0

	case SchedulePreUpdate:

		variant = int32(1)
		variant0 = 0
		variant1 = 0

	case ScheduleUpdate:

		variant = int32(2)
		variant0 = 0
		variant1 = 0

	case SchedulePostUpdate:

		variant = int32(3)
		variant0 = 0
		variant1 = 0

	case ScheduleFixedPreUpdate:

		variant = int32(4)
		variant0 = 0
		variant1 = 0

	case ScheduleFixedUpdate:

		variant = int32(5)
		variant0 = 0
		variant1 = 0

	case ScheduleFixedPostUpdate:

		variant = int32(6)
		variant0 = 0
		variant1 = 0

	case ScheduleCustom:
		payload := schedule.Custom()
		utf8 := unsafe.Pointer(unsafe.StringData(payload))
		pinner.Pin(utf8)

		variant = int32(7)
		variant0 = uintptr(utf8)
		variant1 = uint32(len(payload))

	default:
		panic("unreachable")
	}
	slice := systems
	length := uint32(len(slice))
	result := witRuntime.Allocate(pinner, uintptr(length*4), 4)
	for index, element := range slice {
		base := unsafe.Add(result, index*4)
		*(*int32)(unsafe.Add(unsafe.Pointer(base), 0)) = (element).Handle()

	}

	wasm_import_method_app_add_systems((self).Handle(), variant, variant0, variant1, uintptr(result), length)

}

//go:wasmimport wasvy:ecs/app [constructor]system
func wasm_import_constructor_system(arg0 uintptr, arg1 uint32) int32

func MakeSystem(name string) *System {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	utf8 := unsafe.Pointer(unsafe.StringData(name))
	pinner.Pin(utf8)
	result := wasm_import_constructor_system(uintptr(utf8), uint32(len(name)))
	return SystemFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]system.add-commands
func wasm_import_method_system_add_commands(arg0 int32)

func (self *System) AddCommands() {

	wasm_import_method_system_add_commands((self).Handle())

}

//go:wasmimport wasvy:ecs/app [method]system.add-query
func wasm_import_method_system_add_query(arg0 int32, arg1 uintptr, arg2 uint32)

func (self *System) AddQuery(query []QueryFor) {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	slice := query
	length := uint32(len(slice))
	result := witRuntime.Allocate(pinner, uintptr(length*(3*4)), 4)
	for index, element := range slice {
		base := unsafe.Add(result, index*(3*4))

		switch element.Tag() {
		case QueryForRef:
			payload := element.Ref()
			*(*int8)(unsafe.Add(unsafe.Pointer(base), 0)) = int8(int32(0))
			utf8 := unsafe.Pointer(unsafe.StringData(payload))
			pinner.Pin(utf8)
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uint32(len(payload)))
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uintptr(uintptr(utf8)))

		case QueryForMut:
			payload := element.Mut()
			*(*int8)(unsafe.Add(unsafe.Pointer(base), 0)) = int8(int32(1))
			utf80 := unsafe.Pointer(unsafe.StringData(payload))
			pinner.Pin(utf80)
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uint32(len(payload)))
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uintptr(uintptr(utf80)))

		case QueryForWith:
			payload := element.With()
			*(*int8)(unsafe.Add(unsafe.Pointer(base), 0)) = int8(int32(2))
			utf81 := unsafe.Pointer(unsafe.StringData(payload))
			pinner.Pin(utf81)
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uint32(len(payload)))
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uintptr(uintptr(utf81)))

		case QueryForWithout:
			payload := element.Without()
			*(*int8)(unsafe.Add(unsafe.Pointer(base), 0)) = int8(int32(3))
			utf82 := unsafe.Pointer(unsafe.StringData(payload))
			pinner.Pin(utf82)
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uint32(len(payload)))
			*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uintptr(uintptr(utf82)))

		default:
			panic("unreachable")
		}

	}

	wasm_import_method_system_add_query((self).Handle(), uintptr(result), length)

}

//go:wasmimport wasvy:ecs/app [method]system.after
func wasm_import_method_system_after(arg0 int32, arg1 int32)

func (self *System) After(other *System) {

	wasm_import_method_system_after((self).Handle(), (other).Handle())

}

//go:wasmimport wasvy:ecs/app [method]system.before
func wasm_import_method_system_before(arg0 int32, arg1 int32)

func (self *System) Before(other *System) {

	wasm_import_method_system_before((self).Handle(), (other).Handle())

}

//go:wasmimport wasvy:ecs/app [method]commands.spawn-empty
func wasm_import_method_commands_spawn_empty(arg0 int32) int32

func (self *Commands) SpawnEmpty() *EntityCommands {

	result := wasm_import_method_commands_spawn_empty((self).Handle())
	return EntityCommandsFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]commands.spawn
func wasm_import_method_commands_spawn(arg0 int32, arg1 uintptr, arg2 uint32) int32

func (self *Commands) Spawn(bundle []witTypes.Tuple2[string, string]) *EntityCommands {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	slice := bundle
	length := uint32(len(slice))
	result := witRuntime.Allocate(pinner, uintptr(length*(4*4)), 4)
	for index, element := range slice {
		base := unsafe.Add(result, index*(4*4))
		utf8 := unsafe.Pointer(unsafe.StringData((element).F0))
		pinner.Pin(utf8)
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uint32(len((element).F0)))
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 0)) = uint32(uintptr(uintptr(utf8)))
		utf80 := unsafe.Pointer(unsafe.StringData((element).F1))
		pinner.Pin(utf80)
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), (3 * 4))) = uint32(uint32(len((element).F1)))
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uintptr(uintptr(utf80)))

	}

	result1 := wasm_import_method_commands_spawn((self).Handle(), uintptr(result), length)
	return EntityCommandsFromOwnHandle(int32(uintptr(result1)))

}

//go:wasmimport wasvy:ecs/app [method]commands.entity
func wasm_import_method_commands_entity(arg0 int32, arg1 int32) int32

func (self *Commands) Entity(entity *Entity) *EntityCommands {

	result := wasm_import_method_commands_entity((self).Handle(), (entity).Handle())
	return EntityCommandsFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]entity-commands.id
func wasm_import_method_entity_commands_id(arg0 int32) int32

func (self *EntityCommands) Id() *Entity {

	result := wasm_import_method_entity_commands_id((self).Handle())
	return EntityFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]entity-commands.insert
func wasm_import_method_entity_commands_insert(arg0 int32, arg1 uintptr, arg2 uint32)

func (self *EntityCommands) Insert(bundle []witTypes.Tuple2[string, string]) {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	slice := bundle
	length := uint32(len(slice))
	result := witRuntime.Allocate(pinner, uintptr(length*(4*4)), 4)
	for index, element := range slice {
		base := unsafe.Add(result, index*(4*4))
		utf8 := unsafe.Pointer(unsafe.StringData((element).F0))
		pinner.Pin(utf8)
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uint32(len((element).F0)))
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 0)) = uint32(uintptr(uintptr(utf8)))
		utf80 := unsafe.Pointer(unsafe.StringData((element).F1))
		pinner.Pin(utf80)
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), (3 * 4))) = uint32(uint32(len((element).F1)))
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), (2 * 4))) = uint32(uintptr(uintptr(utf80)))

	}

	wasm_import_method_entity_commands_insert((self).Handle(), uintptr(result), length)

}

//go:wasmimport wasvy:ecs/app [method]entity-commands.remove
func wasm_import_method_entity_commands_remove(arg0 int32, arg1 uintptr, arg2 uint32)

func (self *EntityCommands) Remove(bundle []string) {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	slice := bundle
	length := uint32(len(slice))
	result := witRuntime.Allocate(pinner, uintptr(length*(2*4)), 4)
	for index, element := range slice {
		base := unsafe.Add(result, index*(2*4))
		utf8 := unsafe.Pointer(unsafe.StringData(element))
		pinner.Pin(utf8)
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 4)) = uint32(uint32(len(element)))
		*(*uint32)(unsafe.Add(unsafe.Pointer(base), 0)) = uint32(uintptr(uintptr(utf8)))

	}

	wasm_import_method_entity_commands_remove((self).Handle(), uintptr(result), length)

}

//go:wasmimport wasvy:ecs/app [method]entity-commands.despawn
func wasm_import_method_entity_commands_despawn(arg0 int32)

func (self *EntityCommands) Despawn() {

	wasm_import_method_entity_commands_despawn((self).Handle())

}

//go:wasmimport wasvy:ecs/app [method]entity-commands.try-despawn
func wasm_import_method_entity_commands_try_despawn(arg0 int32)

func (self *EntityCommands) TryDespawn() {

	wasm_import_method_entity_commands_try_despawn((self).Handle())

}

//go:wasmimport wasvy:ecs/app [method]query.iter
func wasm_import_method_query_iter(arg0 int32, arg1 uintptr)

func (self *Query) Iter() witTypes.Option[*QueryResult] {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	returnArea := uintptr(witRuntime.Allocate(pinner, 8, 4))
	wasm_import_method_query_iter((self).Handle(), returnArea)
	var option witTypes.Option[*QueryResult]
	switch uint8(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))) {
	case 0:

		option = witTypes.None[*QueryResult]()
	case 1:

		option = witTypes.Some[*QueryResult](QueryResultFromOwnHandle(int32(uintptr(*(*int32)(unsafe.Add(unsafe.Pointer(returnArea), 4))))))
	default:
		panic("unreachable")
	}
	result := option
	return result

}

//go:wasmimport wasvy:ecs/app [method]query-result.entity
func wasm_import_method_query_result_entity(arg0 int32) int32

func (self *QueryResult) Entity() *Entity {

	result := wasm_import_method_query_result_entity((self).Handle())
	return EntityFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]query-result.component
func wasm_import_method_query_result_component(arg0 int32, arg1 int32) int32

func (self *QueryResult) Component(index uint8) *Component {

	result := wasm_import_method_query_result_component((self).Handle(), int32(index))
	return ComponentFromOwnHandle(int32(uintptr(result)))

}

//go:wasmimport wasvy:ecs/app [method]component.get
func wasm_import_method_component_get(arg0 int32, arg1 uintptr)

func (self *Component) Get() string {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	returnArea := uintptr(witRuntime.Allocate(pinner, (2 * 4), 4))
	wasm_import_method_component_get((self).Handle(), returnArea)
	value := unsafe.String((*uint8)(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))))), *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4)))
	result := value
	return result

}

//go:wasmimport wasvy:ecs/app [method]component.set
func wasm_import_method_component_set(arg0 int32, arg1 uintptr, arg2 uint32)

func (self *Component) Set(value string) {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	utf8 := unsafe.Pointer(unsafe.StringData(value))
	pinner.Pin(utf8)
	wasm_import_method_component_set((self).Handle(), uintptr(utf8), uint32(len(value)))

}

//go:wasmimport wasvy:ecs/app [method]component.invoke
func wasm_import_method_component_invoke(arg0 int32, arg1 uintptr, arg2 uint32, arg3 uintptr, arg4 uint32, arg5 uintptr)

func (self *Component) Invoke(method string, params string) string {
	pinner := &runtime.Pinner{}
	defer pinner.Unpin()

	returnArea := uintptr(witRuntime.Allocate(pinner, (2 * 4), 4))
	utf8 := unsafe.Pointer(unsafe.StringData(method))
	pinner.Pin(utf8)
	utf80 := unsafe.Pointer(unsafe.StringData(params))
	pinner.Pin(utf80)
	wasm_import_method_component_invoke((self).Handle(), uintptr(utf8), uint32(len(method)), uintptr(utf80), uint32(len(params)), returnArea)
	value := unsafe.String((*uint8)(unsafe.Pointer(uintptr(*(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 0))))), *(*uint32)(unsafe.Add(unsafe.Pointer(returnArea), 4)))
	result := value
	return result

}