@@ -154,6 +154,22 @@ proc reset_level(self: Worker) =
154
154
state.config_value.value:
155
155
level_dir = current_level
156
156
157
+ proc ensure_unit (self: Worker , unit: Unit ) =
158
+ if unit notin self.node_map:
159
+ var node = self.node_map[self.active_unit].copy_tree
160
+ self.map_unit (unit, node)
161
+
162
+ proc current_collider (self: Unit , kind: string ): Unit =
163
+ var collider: Unit
164
+ state.units.value.walk_tree proc (unit: Unit ) =
165
+ if self.collisions.value.any_it (it.id == unit.id):
166
+ if kind == " Unit" or kind == " Player" and unit of Player or
167
+ kind == " Bot" and unit of Bot or kind == " Build" and unit of Build or
168
+ kind == " Sign" and unit of Sign :
169
+ collider = unit
170
+ return
171
+ result = collider
172
+
157
173
proc world_name (): string =
158
174
state.config.world
159
175
@@ -391,9 +407,7 @@ proc all_units(T: type Unit, self: Worker): PNode =
391
407
if unit of T:
392
408
# objects without scripts won't show up in the node map. Create
393
409
# a new dummy object
394
- if unit notin self.node_map:
395
- var node = self.node_map[self.active_unit].copy_tree
396
- self.map_unit (unit, node)
410
+ self.ensure_unit (unit)
397
411
node.add self.to_node (unit)
398
412
result = node
399
413
@@ -425,9 +439,8 @@ proc draw_position_set(self: Build, position: Vector3) =
425
439
(position - self.position).local_to (self.parent)
426
440
427
441
proc save (self: Build , name: string ) =
428
- self.save_points[name] = (
429
- self.draw_transform, self.color_value.value, self.drawing
430
- )
442
+ self.save_points[name] =
443
+ (self.draw_transform, self.color_value.value, self.drawing)
431
444
432
445
proc restore (self: Build , name: string ) =
433
446
(self.draw_transform, self.color_value.value, self.drawing) =
@@ -561,10 +574,9 @@ proc `open=`(self: Sign, value: bool) =
561
574
562
575
proc coding (self: Worker , unit: Unit ): Unit =
563
576
if unit == state.player:
564
- if ? state.open_unit and state.open_unit notin self.node_map:
565
- var node = self.node_map[self.active_unit].copy_tree
566
- self.map_unit (state.open_unit, node)
567
- result = state.open_unit
577
+ if ? state.open_unit:
578
+ self.ensure_unit (state.open_unit)
579
+ result = state.open_unit
568
580
569
581
proc `coding=` (self: Unit , value: Unit ) =
570
582
state.open_unit = value
@@ -583,7 +595,8 @@ proc bridge_to_vm*(worker: Worker) =
583
595
glow, `glow=`, speed, `speed=`, scale, `scale=`, velocity, `velocity=`,
584
596
active_unit, color, `color=`, sees, start_position, wake, frame_count,
585
597
write_stack_trace, show, `show=`, frame_created, lock, `lock=`, reset,
586
- press_action, load_level, level_name, world_name, reset_level
598
+ press_action, load_level, level_name, world_name, reset_level,
599
+ current_collider
587
600
588
601
result .bridged_from_vm " base_bridge_private" ,
589
602
link_dependency, action_running, `action_running=`, yield_script,
0 commit comments