@rbxts/replecs 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/replecs/client.luau +7 -3
- package/out/replecs/index.d.ts +39 -12
- package/out/replecs/init.luau +22 -0
- package/out/replecs/masking/init.luau +237 -309
- package/out/replecs/server.luau +172 -120
- package/out/replecs/ver.luau +2 -1
- package/out/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
package/out/replecs/server.luau
CHANGED
|
@@ -54,23 +54,23 @@ type EntityStorage = {
|
|
|
54
54
|
type Storage = { [Entity]: EntityStorage }
|
|
55
55
|
|
|
56
56
|
export type ServerImp = {
|
|
57
|
-
set_networked: (
|
|
58
|
-
set_reliable: (
|
|
59
|
-
set_unreliable: (
|
|
60
|
-
set_pair: (
|
|
61
|
-
set_relation: (
|
|
62
|
-
|
|
63
|
-
stop_networked: (
|
|
64
|
-
stop_reliable: (
|
|
65
|
-
stop_unreliable: (
|
|
66
|
-
stop_pair: (
|
|
67
|
-
stop_relation: (
|
|
68
|
-
|
|
69
|
-
set_custom: (
|
|
70
|
-
remove_custom: (
|
|
71
|
-
|
|
72
|
-
set_serdes: <T>(
|
|
73
|
-
remove_serdes: (
|
|
57
|
+
set_networked: (self: Server, entity: Entity, filter: AnyFilter?) -> (),
|
|
58
|
+
set_reliable: (self: Server, entity: Entity, component: Component, filter: AnyFilter?) -> (),
|
|
59
|
+
set_unreliable: (self: Server, entity: Entity, component: Component, filter: AnyFilter?) -> (),
|
|
60
|
+
set_pair: (self: Server, entity: Entity, id: Component, filter: AnyFilter?) -> (),
|
|
61
|
+
set_relation: (self: Server, entity: Entity, relation: Component, filter: AnyFilter?) -> (),
|
|
62
|
+
|
|
63
|
+
stop_networked: (self: Server, entity: Entity, keep: boolean?) -> (),
|
|
64
|
+
stop_reliable: (self: Server, entity: Entity, component: Component, keep: boolean?) -> (),
|
|
65
|
+
stop_unreliable: (self: Server, entity: Entity, component: Component, keep: boolean?) -> (),
|
|
66
|
+
stop_pair: (self: Server, entity: Entity, id: Component, keep: boolean?) -> (),
|
|
67
|
+
stop_relation: (self: Server, entity: Entity, relation: Component, keep: boolean?) -> (),
|
|
68
|
+
|
|
69
|
+
set_custom: (self: Server, entity: Entity, component: Component | CustomId) -> (),
|
|
70
|
+
remove_custom: (self: Server, entity: Entity) -> (),
|
|
71
|
+
|
|
72
|
+
set_serdes: <T>(self: Server, id: Component<T>, serdes: types.Serdes<T>) -> (),
|
|
73
|
+
remove_serdes: (self: Server, id: Component) -> (),
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export type Server = ServerImp & {
|
|
@@ -134,17 +134,9 @@ local COMPONENT_TYPES = {
|
|
|
134
134
|
pair_tag = 3,
|
|
135
135
|
pair_component = 4,
|
|
136
136
|
relation = 5,
|
|
137
|
-
|
|
137
|
+
relation_component = 6,
|
|
138
138
|
unreliable = 7,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
local TRACK_TYPES = {
|
|
142
|
-
tag = 1,
|
|
143
|
-
component = 2,
|
|
144
|
-
pair_tag = 3,
|
|
145
|
-
pair_component = 4,
|
|
146
|
-
relation = 5,
|
|
147
|
-
relation_value = 6,
|
|
139
|
+
unreliable_pair = 8,
|
|
148
140
|
}
|
|
149
141
|
|
|
150
142
|
local PACKET_TYPES = {
|
|
@@ -288,6 +280,13 @@ local function allocate_component_change(server: Server, entity: Entity, compone
|
|
|
288
280
|
end
|
|
289
281
|
end
|
|
290
282
|
|
|
283
|
+
local function allocate_unreliable_addition(server: Server, entity: Entity, component: Component)
|
|
284
|
+
-- we dont modify the storage because changes are not tracked
|
|
285
|
+
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
286
|
+
server.masking:allocate_unreliable_addition(entity, component)
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
291
290
|
local function allocate_tag_addition(server: Server, entity: Entity, tag: Component)
|
|
292
291
|
local storage = get_or_set_entity_storage(server, entity)
|
|
293
292
|
storage.tags[tag] = true
|
|
@@ -297,27 +296,27 @@ local function allocate_tag_addition(server: Server, entity: Entity, tag: Compon
|
|
|
297
296
|
end
|
|
298
297
|
end
|
|
299
298
|
|
|
300
|
-
local function
|
|
299
|
+
local function allocate_pair_tag_addition(server: Server, entity: Entity, id: Component)
|
|
301
300
|
local storage = get_or_set_entity_storage(server, entity)
|
|
302
301
|
storage.pair_tags[id] = true
|
|
303
302
|
|
|
304
303
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
305
|
-
server.masking:
|
|
304
|
+
server.masking:allocate_pair_tag_addition(entity, id)
|
|
306
305
|
end
|
|
307
306
|
end
|
|
308
307
|
|
|
309
|
-
local function
|
|
308
|
+
local function allocate_pair_component_change(server: Server, entity: Entity, id: Component, value: any)
|
|
310
309
|
local storage = get_or_set_entity_storage(server, entity)
|
|
311
310
|
|
|
312
311
|
local non_nil = if value == nil then NIL_COMPONENT_VALUE else value
|
|
313
312
|
storage.pair_components[id] = non_nil
|
|
314
313
|
|
|
315
314
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
316
|
-
server.masking:
|
|
315
|
+
server.masking:allocate_pair_component_change(entity, id, non_nil)
|
|
317
316
|
end
|
|
318
317
|
end
|
|
319
318
|
|
|
320
|
-
local function
|
|
319
|
+
local function allocate_relation_component_change(
|
|
321
320
|
server: Server,
|
|
322
321
|
entity: Entity,
|
|
323
322
|
relation: Component,
|
|
@@ -336,11 +335,11 @@ local function allocate_relation_value_change(
|
|
|
336
335
|
values[target] = non_nil
|
|
337
336
|
|
|
338
337
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
339
|
-
server.masking:
|
|
338
|
+
server.masking:allocate_relation_component_change(entity, relation, target, non_nil)
|
|
340
339
|
end
|
|
341
340
|
end
|
|
342
341
|
|
|
343
|
-
local function
|
|
342
|
+
local function allocate_relation_tag_addition(server: Server, entity: Entity, relation: Component, target: Entity)
|
|
344
343
|
local storage = get_or_set_entity_storage(server, entity)
|
|
345
344
|
local targets = storage.relations[relation]
|
|
346
345
|
if targets == nil then
|
|
@@ -350,7 +349,7 @@ local function allocate_relation_addition(server: Server, entity: Entity, relati
|
|
|
350
349
|
targets[target] = true
|
|
351
350
|
|
|
352
351
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
353
|
-
server.masking:
|
|
352
|
+
server.masking:allocate_relation_tag_addition(entity, relation, target)
|
|
354
353
|
end
|
|
355
354
|
end
|
|
356
355
|
|
|
@@ -363,6 +362,12 @@ local function allocate_component_removal(server: Server, entity: Entity, compon
|
|
|
363
362
|
end
|
|
364
363
|
end
|
|
365
364
|
|
|
365
|
+
local function allocate_unreliable_removal(server: Server, entity: Entity, component: Component)
|
|
366
|
+
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
367
|
+
server.masking:allocate_unreliable_removal(entity, component)
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
|
|
366
371
|
local function allocate_tag_removal(server: Server, entity: Entity, tag: Component)
|
|
367
372
|
local storage = get_or_set_entity_storage(server, entity)
|
|
368
373
|
storage.tags[tag] = nil
|
|
@@ -390,7 +395,7 @@ local function allocate_pair_component_removal(server: Server, entity: Entity, i
|
|
|
390
395
|
end
|
|
391
396
|
end
|
|
392
397
|
|
|
393
|
-
local function
|
|
398
|
+
local function allocate_relation_component_removal(server: Server, entity: Entity, relation: Component, target: Entity)
|
|
394
399
|
local storage = get_or_set_entity_storage(server, entity)
|
|
395
400
|
local values = storage.relation_values[relation]
|
|
396
401
|
if values then
|
|
@@ -398,11 +403,11 @@ local function allocate_relation_value_removal(server: Server, entity: Entity, r
|
|
|
398
403
|
end
|
|
399
404
|
|
|
400
405
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
401
|
-
server.masking:
|
|
406
|
+
server.masking:allocate_relation_component_removal(entity, relation, target)
|
|
402
407
|
end
|
|
403
408
|
end
|
|
404
409
|
|
|
405
|
-
local function
|
|
410
|
+
local function allocate_relation_tag_removal(server: Server, entity: Entity, relation: Component, target: Entity)
|
|
406
411
|
local storage = get_or_set_entity_storage(server, entity)
|
|
407
412
|
local targets = storage.relations[relation]
|
|
408
413
|
if targets then
|
|
@@ -410,7 +415,7 @@ local function allocate_relation_removal(server: Server, entity: Entity, relatio
|
|
|
410
415
|
end
|
|
411
416
|
|
|
412
417
|
if not server.additions[entity] and server.track_info.networked[entity] then
|
|
413
|
-
server.masking:
|
|
418
|
+
server.masking:allocate_relation_tag_removal(entity, relation, target)
|
|
414
419
|
end
|
|
415
420
|
end
|
|
416
421
|
|
|
@@ -440,7 +445,7 @@ local function cleanup_entity(server: Server, entity: Entity)
|
|
|
440
445
|
end
|
|
441
446
|
end
|
|
442
447
|
|
|
443
|
-
local function
|
|
448
|
+
local function hook_pair(server: Server, pair_id: Component)
|
|
444
449
|
local world = server.world
|
|
445
450
|
|
|
446
451
|
if server.track_info.pairs[pair_id] then
|
|
@@ -460,10 +465,10 @@ local function track_pair(server: Server, pair_id: Component)
|
|
|
460
465
|
return
|
|
461
466
|
end
|
|
462
467
|
|
|
463
|
-
if track_type ==
|
|
464
|
-
|
|
468
|
+
if track_type == COMPONENT_TYPES.pair_component then
|
|
469
|
+
allocate_pair_component_change(server, entity, id, value)
|
|
465
470
|
else
|
|
466
|
-
|
|
471
|
+
allocate_pair_tag_addition(server, entity, id)
|
|
467
472
|
end
|
|
468
473
|
end))
|
|
469
474
|
hook(HOOK_PAIR_CHANGED(world, pair_id, function(entity, id, value)
|
|
@@ -472,7 +477,7 @@ local function track_pair(server: Server, pair_id: Component)
|
|
|
472
477
|
return
|
|
473
478
|
end
|
|
474
479
|
|
|
475
|
-
|
|
480
|
+
allocate_pair_component_change(server, entity, id, value)
|
|
476
481
|
end))
|
|
477
482
|
hook(HOOK_PAIR_REMOVED(world, pair_id, function(entity, id)
|
|
478
483
|
local track_type = info[entity]
|
|
@@ -480,7 +485,7 @@ local function track_pair(server: Server, pair_id: Component)
|
|
|
480
485
|
return
|
|
481
486
|
end
|
|
482
487
|
|
|
483
|
-
if track_type ==
|
|
488
|
+
if track_type == COMPONENT_TYPES.pair_component then
|
|
484
489
|
allocate_pair_component_removal(server, entity, id)
|
|
485
490
|
else
|
|
486
491
|
allocate_pair_tag_removal(server, entity, id)
|
|
@@ -490,7 +495,7 @@ local function track_pair(server: Server, pair_id: Component)
|
|
|
490
495
|
return info
|
|
491
496
|
end
|
|
492
497
|
|
|
493
|
-
local function
|
|
498
|
+
local function hook_component(server: Server, component: Component)
|
|
494
499
|
local world = server.world
|
|
495
500
|
|
|
496
501
|
if server.track_info.components[component] then
|
|
@@ -510,20 +515,22 @@ local function track_component(server: Server, component: Component)
|
|
|
510
515
|
return
|
|
511
516
|
end
|
|
512
517
|
|
|
513
|
-
if track_type ==
|
|
518
|
+
if track_type == COMPONENT_TYPES.component then
|
|
514
519
|
allocate_component_change(server, entity, component, value)
|
|
515
|
-
elseif track_type ==
|
|
520
|
+
elseif track_type == COMPONENT_TYPES.tag then
|
|
516
521
|
allocate_tag_addition(server, entity, component)
|
|
517
|
-
elseif track_type ==
|
|
522
|
+
elseif track_type == COMPONENT_TYPES.relation then
|
|
518
523
|
if not IS_PAIR(id) then
|
|
519
524
|
return
|
|
520
525
|
end
|
|
521
|
-
|
|
522
|
-
elseif track_type ==
|
|
526
|
+
allocate_relation_tag_addition(server, entity, component, PAIR_SECOND(world, id))
|
|
527
|
+
elseif track_type == COMPONENT_TYPES.relation_component then
|
|
523
528
|
if not IS_PAIR(id) then
|
|
524
529
|
return
|
|
525
530
|
end
|
|
526
|
-
|
|
531
|
+
allocate_relation_component_change(server, entity, component, PAIR_SECOND(world, id), value)
|
|
532
|
+
elseif track_type == COMPONENT_TYPES.unreliable then
|
|
533
|
+
allocate_unreliable_addition(server, entity, component)
|
|
527
534
|
end
|
|
528
535
|
end))
|
|
529
536
|
hook(HOOK_CHANGED(world, component, function(entity, id, value)
|
|
@@ -531,13 +538,13 @@ local function track_component(server: Server, component: Component)
|
|
|
531
538
|
if not track_type then
|
|
532
539
|
return
|
|
533
540
|
end
|
|
534
|
-
if track_type ==
|
|
541
|
+
if track_type == COMPONENT_TYPES.component then
|
|
535
542
|
allocate_component_change(server, entity, component, value)
|
|
536
|
-
elseif track_type ==
|
|
543
|
+
elseif track_type == COMPONENT_TYPES.relation_component then
|
|
537
544
|
if not IS_PAIR(id) then
|
|
538
545
|
return
|
|
539
546
|
end
|
|
540
|
-
|
|
547
|
+
allocate_relation_component_change(server, entity, component, PAIR_SECOND(world, id), value)
|
|
541
548
|
end
|
|
542
549
|
end))
|
|
543
550
|
hook(HOOK_REMOVED(world, component, function(entity, id)
|
|
@@ -546,20 +553,22 @@ local function track_component(server: Server, component: Component)
|
|
|
546
553
|
return
|
|
547
554
|
end
|
|
548
555
|
|
|
549
|
-
if track_type ==
|
|
556
|
+
if track_type == COMPONENT_TYPES.component then
|
|
550
557
|
allocate_component_removal(server, entity, component)
|
|
551
|
-
elseif track_type ==
|
|
558
|
+
elseif track_type == COMPONENT_TYPES.tag then
|
|
552
559
|
allocate_tag_removal(server, entity, component)
|
|
553
|
-
elseif track_type ==
|
|
560
|
+
elseif track_type == COMPONENT_TYPES.relation then
|
|
554
561
|
if not IS_PAIR(id) then
|
|
555
562
|
return
|
|
556
563
|
end
|
|
557
|
-
|
|
558
|
-
elseif track_type ==
|
|
564
|
+
allocate_relation_tag_removal(server, entity, component, PAIR_SECOND(world, id))
|
|
565
|
+
elseif track_type == COMPONENT_TYPES.relation_component then
|
|
559
566
|
if not IS_PAIR(id) then
|
|
560
567
|
return
|
|
561
568
|
end
|
|
562
|
-
|
|
569
|
+
allocate_relation_component_removal(server, entity, component, PAIR_SECOND(world, id))
|
|
570
|
+
elseif track_type == COMPONENT_TYPES.unreliable then
|
|
571
|
+
allocate_unreliable_removal(server, entity, component)
|
|
563
572
|
end
|
|
564
573
|
end))
|
|
565
574
|
|
|
@@ -606,11 +615,21 @@ local function remove_entity_pair_tracked(server: Server, entity: Entity, id: Co
|
|
|
606
615
|
end
|
|
607
616
|
end
|
|
608
617
|
|
|
618
|
+
local function track_entity_unreliable(server: Server, entity: Entity, component: Component)
|
|
619
|
+
local info = server.track_info.components[component]
|
|
620
|
+
if not info then
|
|
621
|
+
info = hook_component(server, component)
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
info[entity] = COMPONENT_TYPES.unreliable
|
|
625
|
+
add_entity_component_tracked(server, entity, component, COMPONENT_TYPES.unreliable)
|
|
626
|
+
end
|
|
627
|
+
|
|
609
628
|
local function track_entity_component(server: Server, entity: Entity, component: Component)
|
|
610
629
|
local world = server.world
|
|
611
630
|
local info = server.track_info.components[component]
|
|
612
631
|
if not info then
|
|
613
|
-
info =
|
|
632
|
+
info = hook_component(server, component)
|
|
614
633
|
end
|
|
615
634
|
|
|
616
635
|
local entity_storage = get_or_set_entity_storage(server, entity)
|
|
@@ -626,8 +645,8 @@ local function track_entity_component(server: Server, entity: Entity, component:
|
|
|
626
645
|
end
|
|
627
646
|
end
|
|
628
647
|
|
|
629
|
-
info[entity] =
|
|
630
|
-
add_entity_component_tracked(server, entity, component,
|
|
648
|
+
info[entity] = COMPONENT_TYPES.component
|
|
649
|
+
add_entity_component_tracked(server, entity, component, COMPONENT_TYPES.component)
|
|
631
650
|
|
|
632
651
|
return COMPONENT_TYPES.component
|
|
633
652
|
else
|
|
@@ -635,8 +654,8 @@ local function track_entity_component(server: Server, entity: Entity, component:
|
|
|
635
654
|
entity_storage.tags[component] = true
|
|
636
655
|
end
|
|
637
656
|
|
|
638
|
-
info[entity] =
|
|
639
|
-
add_entity_component_tracked(server, entity, component,
|
|
657
|
+
info[entity] = COMPONENT_TYPES.tag
|
|
658
|
+
add_entity_component_tracked(server, entity, component, COMPONENT_TYPES.tag)
|
|
640
659
|
|
|
641
660
|
return COMPONENT_TYPES.tag
|
|
642
661
|
end
|
|
@@ -646,7 +665,7 @@ local function track_entity_pair(server: Server, entity: Entity, id: Component)
|
|
|
646
665
|
local world = server.world
|
|
647
666
|
local info = server.track_info.pairs[id]
|
|
648
667
|
if not info then
|
|
649
|
-
info =
|
|
668
|
+
info = hook_pair(server, id)
|
|
650
669
|
end
|
|
651
670
|
|
|
652
671
|
local entity_storage = get_or_set_entity_storage(server, entity)
|
|
@@ -662,8 +681,8 @@ local function track_entity_pair(server: Server, entity: Entity, id: Component)
|
|
|
662
681
|
end
|
|
663
682
|
end
|
|
664
683
|
|
|
665
|
-
info[entity] =
|
|
666
|
-
add_entity_pair_tracked(server, entity, id,
|
|
684
|
+
info[entity] = COMPONENT_TYPES.pair_component
|
|
685
|
+
add_entity_pair_tracked(server, entity, id, COMPONENT_TYPES.pair_component)
|
|
667
686
|
|
|
668
687
|
return COMPONENT_TYPES.pair_component
|
|
669
688
|
else
|
|
@@ -671,8 +690,8 @@ local function track_entity_pair(server: Server, entity: Entity, id: Component)
|
|
|
671
690
|
entity_storage.pair_tags[id] = true
|
|
672
691
|
end
|
|
673
692
|
|
|
674
|
-
info[entity] =
|
|
675
|
-
add_entity_pair_tracked(server, entity, id,
|
|
693
|
+
info[entity] = COMPONENT_TYPES.pair_tag
|
|
694
|
+
add_entity_pair_tracked(server, entity, id, COMPONENT_TYPES.pair_tag)
|
|
676
695
|
|
|
677
696
|
return COMPONENT_TYPES.pair_tag
|
|
678
697
|
end
|
|
@@ -682,7 +701,7 @@ local function track_entity_relation(server: Server, entity: Entity, relation: C
|
|
|
682
701
|
local world = server.world
|
|
683
702
|
local info = server.track_info.components[relation]
|
|
684
703
|
if not info then
|
|
685
|
-
info =
|
|
704
|
+
info = hook_component(server, relation)
|
|
686
705
|
end
|
|
687
706
|
|
|
688
707
|
local entity_storage = get_or_set_entity_storage(server, entity)
|
|
@@ -702,10 +721,10 @@ local function track_entity_relation(server: Server, entity: Entity, relation: C
|
|
|
702
721
|
end
|
|
703
722
|
|
|
704
723
|
entity_storage.relation_values[relation] = targets
|
|
705
|
-
info[entity] =
|
|
706
|
-
add_entity_component_tracked(server, entity, relation,
|
|
724
|
+
info[entity] = COMPONENT_TYPES.relation_component
|
|
725
|
+
add_entity_component_tracked(server, entity, relation, COMPONENT_TYPES.relation_component)
|
|
707
726
|
|
|
708
|
-
return COMPONENT_TYPES.
|
|
727
|
+
return COMPONENT_TYPES.relation_component
|
|
709
728
|
else
|
|
710
729
|
local targets = {} :: Set<Entity>
|
|
711
730
|
|
|
@@ -720,8 +739,8 @@ local function track_entity_relation(server: Server, entity: Entity, relation: C
|
|
|
720
739
|
end
|
|
721
740
|
|
|
722
741
|
entity_storage.relations[relation] = targets
|
|
723
|
-
info[entity] =
|
|
724
|
-
add_entity_component_tracked(server, entity, relation,
|
|
742
|
+
info[entity] = COMPONENT_TYPES.relation
|
|
743
|
+
add_entity_component_tracked(server, entity, relation, COMPONENT_TYPES.relation)
|
|
725
744
|
|
|
726
745
|
return COMPONENT_TYPES.relation
|
|
727
746
|
end
|
|
@@ -844,7 +863,7 @@ function server_replicator.write_variant_value(
|
|
|
844
863
|
cursor.write_vlq(c, len)
|
|
845
864
|
end
|
|
846
865
|
else
|
|
847
|
-
if value == NIL_COMPONENT_VALUE then
|
|
866
|
+
if value == nil or value == NIL_COMPONENT_VALUE then
|
|
848
867
|
-- 128 is zero for vlq
|
|
849
868
|
cursor.writeu8(c, 128)
|
|
850
869
|
else
|
|
@@ -977,7 +996,7 @@ function server_replicator.write_entity(
|
|
|
977
996
|
local entity_mask = 0
|
|
978
997
|
|
|
979
998
|
local total_relation_values = 0
|
|
980
|
-
for relation in active.components[COMPONENT_TYPES.
|
|
999
|
+
for relation in active.components[COMPONENT_TYPES.relation_component] do
|
|
981
1000
|
server_replicator.write_entity_relations_values(server, storage, c, relation, variants)
|
|
982
1001
|
total_relation_values += 1
|
|
983
1002
|
end
|
|
@@ -1023,6 +1042,18 @@ function server_replicator.write_entity(
|
|
|
1023
1042
|
server_replicator.write_component_id(server, c, component)
|
|
1024
1043
|
total_components += 1
|
|
1025
1044
|
end
|
|
1045
|
+
for component in active.components[COMPONENT_TYPES.unreliable] do
|
|
1046
|
+
local has = WORLD_HAS(world, entity, component)
|
|
1047
|
+
if not has then
|
|
1048
|
+
continue
|
|
1049
|
+
end
|
|
1050
|
+
local value = WORLD_GET(world, entity, component)
|
|
1051
|
+
|
|
1052
|
+
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1053
|
+
server_replicator.write_component_id(server, c, component)
|
|
1054
|
+
|
|
1055
|
+
total_components += 1
|
|
1056
|
+
end
|
|
1026
1057
|
entity_mask = write_vlq_bitmask(c, total_components, entity_mask, 1)
|
|
1027
1058
|
|
|
1028
1059
|
local total_tags = 0
|
|
@@ -1273,7 +1304,7 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1273
1304
|
for entity, deleted in component_deletions do
|
|
1274
1305
|
local total_relations = 0
|
|
1275
1306
|
|
|
1276
|
-
for relation in deleted[COMPONENT_TYPES.
|
|
1307
|
+
for relation in deleted[COMPONENT_TYPES.relation_component] do
|
|
1277
1308
|
server_replicator.write_component_id(server, c, relation)
|
|
1278
1309
|
total_relations += 1
|
|
1279
1310
|
end
|
|
@@ -1299,6 +1330,10 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1299
1330
|
server_replicator.write_component_id(server, c, component)
|
|
1300
1331
|
total_components += 1
|
|
1301
1332
|
end
|
|
1333
|
+
for component in deleted[COMPONENT_TYPES.unreliable] do
|
|
1334
|
+
server_replicator.write_component_id(server, c, component)
|
|
1335
|
+
total_components += 1
|
|
1336
|
+
end
|
|
1302
1337
|
for tag in deleted[COMPONENT_TYPES.tag] do
|
|
1303
1338
|
server_replicator.write_component_id(server, c, tag)
|
|
1304
1339
|
total_components += 1
|
|
@@ -1317,7 +1352,7 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1317
1352
|
-- relations remove
|
|
1318
1353
|
|
|
1319
1354
|
local total_relations_removed = 0
|
|
1320
|
-
for relation, targets in changes.
|
|
1355
|
+
for relation, targets in changes.relation_component_removed do
|
|
1321
1356
|
local total_targets = 0
|
|
1322
1357
|
|
|
1323
1358
|
for target in targets do
|
|
@@ -1328,7 +1363,7 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1328
1363
|
server_replicator.write_component_id(server, c, relation)
|
|
1329
1364
|
total_relations_removed += 1
|
|
1330
1365
|
end
|
|
1331
|
-
for relation, targets in changes.
|
|
1366
|
+
for relation, targets in changes.relation_tag_removed do
|
|
1332
1367
|
local total_targets = 0
|
|
1333
1368
|
|
|
1334
1369
|
for target in targets do
|
|
@@ -1347,8 +1382,8 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1347
1382
|
|
|
1348
1383
|
-- relations add/set
|
|
1349
1384
|
|
|
1350
|
-
local
|
|
1351
|
-
for relation, targets in changes.
|
|
1385
|
+
local total_relation_components = 0
|
|
1386
|
+
for relation, targets in changes.relation_component_changed do
|
|
1352
1387
|
local total_targets = 0
|
|
1353
1388
|
|
|
1354
1389
|
for target, value in targets do
|
|
@@ -1358,12 +1393,12 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1358
1393
|
end
|
|
1359
1394
|
cursor.write_vlq(c, total_targets)
|
|
1360
1395
|
server_replicator.write_component_id(server, c, relation)
|
|
1361
|
-
|
|
1396
|
+
total_relation_components += 1
|
|
1362
1397
|
end
|
|
1363
|
-
changed_mask = write_vlq_bitmask(c,
|
|
1398
|
+
changed_mask = write_vlq_bitmask(c, total_relation_components, changed_mask, 7)
|
|
1364
1399
|
|
|
1365
|
-
local
|
|
1366
|
-
for relation, targets in changes.
|
|
1400
|
+
local total_relation_tags = 0
|
|
1401
|
+
for relation, targets in changes.relation_tag_added do
|
|
1367
1402
|
local total_targets = 0
|
|
1368
1403
|
|
|
1369
1404
|
for target in targets do
|
|
@@ -1372,18 +1407,18 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1372
1407
|
end
|
|
1373
1408
|
cursor.write_vlq(c, total_targets)
|
|
1374
1409
|
server_replicator.write_component_id(server, c, relation)
|
|
1375
|
-
|
|
1410
|
+
total_relation_tags += 1
|
|
1376
1411
|
end
|
|
1377
|
-
changed_mask = write_vlq_bitmask(c,
|
|
1412
|
+
changed_mask = write_vlq_bitmask(c, total_relation_tags, changed_mask, 6)
|
|
1378
1413
|
|
|
1379
1414
|
-- pairs removed
|
|
1380
1415
|
|
|
1381
1416
|
local total_pairs_removed = 0
|
|
1382
|
-
for id in changes.
|
|
1417
|
+
for id in changes.pair_component_removed do
|
|
1383
1418
|
server_replicator.write_entity_pair(server, world, c, id)
|
|
1384
1419
|
total_pairs_removed += 1
|
|
1385
1420
|
end
|
|
1386
|
-
for id in changes.
|
|
1421
|
+
for id in changes.pair_tag_removed do
|
|
1387
1422
|
server_replicator.write_entity_pair(server, world, c, id)
|
|
1388
1423
|
total_pairs_removed += 1
|
|
1389
1424
|
end
|
|
@@ -1391,28 +1426,32 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1391
1426
|
|
|
1392
1427
|
-- pairs add/set
|
|
1393
1428
|
|
|
1394
|
-
local
|
|
1395
|
-
for id, value in changes.
|
|
1429
|
+
local total_pair_components = 0
|
|
1430
|
+
for id, value in changes.pair_component_changed do
|
|
1396
1431
|
server_replicator.write_entity_pair_value(server, world, c, id, value, variants)
|
|
1397
|
-
|
|
1432
|
+
total_pair_components += 1
|
|
1398
1433
|
end
|
|
1399
|
-
changed_mask = write_vlq_bitmask(c,
|
|
1434
|
+
changed_mask = write_vlq_bitmask(c, total_pair_components, changed_mask, 4)
|
|
1400
1435
|
|
|
1401
|
-
local
|
|
1402
|
-
for id in changes.
|
|
1436
|
+
local total_pair_tags = 0
|
|
1437
|
+
for id in changes.pair_tag_added do
|
|
1403
1438
|
server_replicator.write_entity_pair(server, world, c, id)
|
|
1404
|
-
|
|
1439
|
+
total_pair_tags += 1
|
|
1405
1440
|
end
|
|
1406
|
-
changed_mask = write_vlq_bitmask(c,
|
|
1441
|
+
changed_mask = write_vlq_bitmask(c, total_pair_tags, changed_mask, 3)
|
|
1407
1442
|
|
|
1408
1443
|
-- tags/components removed
|
|
1409
1444
|
|
|
1410
1445
|
local total_removed = 0
|
|
1411
|
-
for component in changes.
|
|
1446
|
+
for component in changes.component_removed do
|
|
1447
|
+
server_replicator.write_component_id(server, c, component)
|
|
1448
|
+
total_removed += 1
|
|
1449
|
+
end
|
|
1450
|
+
for component in changes.unreliable_removed do
|
|
1412
1451
|
server_replicator.write_component_id(server, c, component)
|
|
1413
1452
|
total_removed += 1
|
|
1414
1453
|
end
|
|
1415
|
-
for component in changes.
|
|
1454
|
+
for component in changes.tag_removed do
|
|
1416
1455
|
server_replicator.write_component_id(server, c, component)
|
|
1417
1456
|
total_removed += 1
|
|
1418
1457
|
end
|
|
@@ -1421,7 +1460,14 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1421
1460
|
-- tags/components set
|
|
1422
1461
|
|
|
1423
1462
|
local total_components = 0
|
|
1424
|
-
for component, value in changes.
|
|
1463
|
+
for component, value in changes.component_changed do
|
|
1464
|
+
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1465
|
+
server_replicator.write_component_id(server, c, component)
|
|
1466
|
+
total_components += 1
|
|
1467
|
+
end
|
|
1468
|
+
for component in changes.unreliable_added do
|
|
1469
|
+
local value = WORLD_GET(world, entity, component)
|
|
1470
|
+
|
|
1425
1471
|
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1426
1472
|
server_replicator.write_component_id(server, c, component)
|
|
1427
1473
|
total_components += 1
|
|
@@ -1429,7 +1475,7 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1429
1475
|
changed_mask = write_vlq_bitmask(c, total_components, changed_mask, 1)
|
|
1430
1476
|
|
|
1431
1477
|
local total_tagged = 0
|
|
1432
|
-
for tag in changes.
|
|
1478
|
+
for tag in changes.tag_added do
|
|
1433
1479
|
server_replicator.write_component_id(server, c, tag)
|
|
1434
1480
|
total_tagged += 1
|
|
1435
1481
|
end
|
|
@@ -1450,7 +1496,7 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1450
1496
|
local added_mask = 0
|
|
1451
1497
|
|
|
1452
1498
|
local total_relation_values = 0
|
|
1453
|
-
for relation in components[COMPONENT_TYPES.
|
|
1499
|
+
for relation in components[COMPONENT_TYPES.relation_component] do
|
|
1454
1500
|
server_replicator.write_entity_relations_values(server, entity_storage, c, relation, variants)
|
|
1455
1501
|
total_relation_values += 1
|
|
1456
1502
|
end
|
|
@@ -1466,10 +1512,6 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1466
1512
|
local total_pair_values = 0
|
|
1467
1513
|
for id in components[COMPONENT_TYPES.pair_component] do
|
|
1468
1514
|
local value = entity_storage.pair_components[id]
|
|
1469
|
-
-- nil is saved here as a special value, this gets automatically handled by write_component_value
|
|
1470
|
-
if value == nil then
|
|
1471
|
-
continue
|
|
1472
|
-
end
|
|
1473
1515
|
|
|
1474
1516
|
server_replicator.write_entity_pair_value(server, world, c, id, value, variants)
|
|
1475
1517
|
total_pair_values += 1
|
|
@@ -1486,10 +1528,14 @@ function server_replicator.collect_updates(server: Server)
|
|
|
1486
1528
|
local total_components = 0
|
|
1487
1529
|
for component in components[COMPONENT_TYPES.component] do
|
|
1488
1530
|
local value = entity_storage.components[component]
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1531
|
+
|
|
1532
|
+
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1533
|
+
server_replicator.write_component_id(server, c, component)
|
|
1534
|
+
total_components += 1
|
|
1535
|
+
end
|
|
1536
|
+
for component in components[COMPONENT_TYPES.unreliable] do
|
|
1537
|
+
local value = WORLD_GET(world, entity, component)
|
|
1538
|
+
|
|
1493
1539
|
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1494
1540
|
server_replicator.write_component_id(server, c, component)
|
|
1495
1541
|
total_components += 1
|
|
@@ -1594,10 +1640,11 @@ function server_replicator.collect_unreliable(server: Server)
|
|
|
1594
1640
|
|
|
1595
1641
|
local total_unreliable = 0
|
|
1596
1642
|
for component in actives.components[COMPONENT_TYPES.unreliable] do
|
|
1597
|
-
local
|
|
1598
|
-
if
|
|
1643
|
+
local has = WORLD_HAS(world, entity, component)
|
|
1644
|
+
if not has then
|
|
1599
1645
|
continue
|
|
1600
1646
|
end
|
|
1647
|
+
local value = WORLD_GET(world, entity, component)
|
|
1601
1648
|
|
|
1602
1649
|
server_replicator.write_component_value(server, c, component, value, variants)
|
|
1603
1650
|
server_replicator.write_component_id(server, c, component)
|
|
@@ -1641,7 +1688,7 @@ end
|
|
|
1641
1688
|
function server_replicator.start_reliable(server: Server, entity: Entity, component: Component, filter: AnyFilter?)
|
|
1642
1689
|
local masking = server.masking
|
|
1643
1690
|
|
|
1644
|
-
local track_type = track_entity_component(server
|
|
1691
|
+
local track_type = track_entity_component(server, entity, component)
|
|
1645
1692
|
masking:deallocate_component_stop(entity, component, track_type)
|
|
1646
1693
|
masking:start_component(entity, component, track_type, filter)
|
|
1647
1694
|
|
|
@@ -1654,11 +1701,16 @@ end
|
|
|
1654
1701
|
|
|
1655
1702
|
function server_replicator.start_unreliable(server: Server, entity: Entity, component: Component, filter: AnyFilter?)
|
|
1656
1703
|
local masking = server.masking
|
|
1704
|
+
local UNRELIABLE_TYPE = COMPONENT_TYPES.unreliable
|
|
1705
|
+
|
|
1706
|
+
track_entity_unreliable(server, entity, component)
|
|
1707
|
+
masking:deallocate_component_stop(entity, component, UNRELIABLE_TYPE)
|
|
1708
|
+
masking:start_component(entity, component, UNRELIABLE_TYPE, filter)
|
|
1657
1709
|
|
|
1658
|
-
masking:deallocate_component_stop(entity, component, COMPONENT_TYPES.unreliable)
|
|
1659
|
-
masking:start_component(entity, component, COMPONENT_TYPES.unreliable, filter)
|
|
1660
1710
|
if server.additions[entity] then
|
|
1661
|
-
masking:
|
|
1711
|
+
masking:allocate_shared_entity_start(entity, component, UNRELIABLE_TYPE)
|
|
1712
|
+
elseif server.track_info.networked[entity] then
|
|
1713
|
+
masking:allocate_component_start(entity, component, UNRELIABLE_TYPE)
|
|
1662
1714
|
end
|
|
1663
1715
|
end
|
|
1664
1716
|
|
|
@@ -1727,7 +1779,7 @@ function server_replicator.change_relation(server: Server, entity: Entity, relat
|
|
|
1727
1779
|
local masking = server.masking
|
|
1728
1780
|
|
|
1729
1781
|
if IS_COMPONENT(world, relation) then
|
|
1730
|
-
masking:set_component(entity, relation, COMPONENT_TYPES.
|
|
1782
|
+
masking:set_component(entity, relation, COMPONENT_TYPES.relation_component, filter)
|
|
1731
1783
|
else
|
|
1732
1784
|
masking:set_component(entity, relation, COMPONENT_TYPES.relation, filter)
|
|
1733
1785
|
end
|
package/out/replecs/ver.luau
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
-- Automatically generated
|
|
2
|
+
return ""
|