ravensight-playtest 0.17.0 → 0.19.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/README.md +160 -16
- package/addons/desktop/RavensightDesktop.swift +367 -0
- package/addons/mobile/UITests/MobileInputTests.swift +67 -1
- package/addons/ravensight_driver/driver.gd +557 -4
- package/docs/ADAPTERS.md +37 -7
- package/docs/DESKTOP.md +117 -0
- package/docs/MOBILE.md +30 -3
- package/docs/UNITY.md +149 -0
- package/docs/UNREAL.md +123 -0
- package/docs/godot-driver.md +98 -1
- package/package.json +15 -5
- package/src/cli.js +26 -10
- package/src/commands/build.js +40 -0
- package/src/commands/fakeCore.js +1 -1
- package/src/commands/feature.js +1 -1
- package/src/commands/hosted.js +78 -9
- package/src/commands/run.js +47 -13
- package/src/commands/validate.js +1 -1
- package/src/commands/validateHosted.js +4 -1
- package/src/hosted/archivePreflight.js +31 -4
- package/src/hosted/buildStatus.js +26 -0
- package/src/hosted/buildUpload.js +39 -22
- package/src/hosted/nativeBuild.js +87 -0
- package/src/hosted/recordedRun.js +15 -3
- package/src/run/anygame/genre.js +98 -24
- package/src/run/anygame/genre2d.js +108 -0
- package/src/run/anygame/index.js +33 -7
- package/src/run/anygame/memory.js +31 -0
- package/src/run/anygame/scene3d.js +562 -0
- package/src/run/anygame/shared-hashes.json +5 -3
- package/src/run/anygame/shared.js +3 -3
- package/src/run/args.js +15 -4
- package/src/run/drivers/desktop/app.js +104 -0
- package/src/run/drivers/desktop/common.js +336 -0
- package/src/run/drivers/desktop/driver.js +383 -0
- package/src/run/drivers/desktop/helper.js +98 -0
- package/src/run/drivers/desktop/keys.js +124 -0
- package/src/run/drivers/desktop/output.js +107 -0
- package/src/run/drivers/desktop/preflight.js +134 -0
- package/src/run/drivers/desktop3d.js +106 -0
- package/src/run/drivers/desktopSequence.js +72 -0
- package/src/run/drivers/godot-3d.js +298 -0
- package/src/run/drivers/godot.js +465 -30
- package/src/run/drivers/index.js +6 -0
- package/src/run/drivers/mobile/adb.js +25 -1
- package/src/run/drivers/mobile/frame.js +3 -2
- package/src/run/drivers/mobile/gestures.js +76 -0
- package/src/run/drivers/mobile/lock.js +51 -11
- package/src/run/drivers/mobile/multitouch.js +150 -0
- package/src/run/drivers/mobile/native.js +229 -31
- package/src/run/drivers/mobile/preflight.js +14 -1
- package/src/run/drivers/mobile/target.js +21 -1
- package/src/run/drivers/stdio.js +150 -12
- package/src/run/drivers/unity/app.js +72 -0
- package/src/run/drivers/unity/engine.js +58 -0
- package/src/run/drivers/unity/link.js +108 -0
- package/src/run/drivers/unity/logs.js +76 -0
- package/src/run/drivers/unreal/app.js +40 -0
- package/src/run/drivers/unreal/driver.js +686 -0
- package/src/run/drivers/unreal/frames.js +243 -0
- package/src/run/drivers/unreal/logs.js +276 -0
- package/src/run/drivers/unreal/preflight.js +61 -0
- package/src/run/drivers/web.js +211 -13
- package/src/run/drivers/webdriver.js +79 -12
- package/src/run/endScreen.js +88 -0
- package/src/run/engineErrors.js +16 -0
- package/src/run/featureLoop.js +1 -1
- package/src/run/fingers.js +99 -0
- package/src/run/focusForKeys.js +54 -0
- package/src/run/gameMemory.js +4 -3
- package/src/run/godotTesterProbes.js +21 -2
- package/src/run/honesty.js +11 -1
- package/src/run/inputs.js +3 -3
- package/src/run/intent.js +12 -0
- package/src/run/pauseHook.js +494 -0
- package/src/run/personaLoop.js +139 -10
- package/src/run/pixels.js +22 -10
- package/src/run/planGuard.js +103 -0
- package/src/run/replay.js +5 -1
- package/src/run/reportChecks.js +17 -4
- package/src/run/resume.js +6 -2
- package/src/run/sessions.js +170 -0
- package/src/run/startFrom.js +415 -0
- package/src/run/testerProbes.js +36 -5
- package/src/run/tools.js +191 -10
- package/src/run/view3dState.js +125 -0
- package/src/run/web3d.js +375 -0
- package/src/run/world3d.js +164 -0
- package/src/upload/host.js +40 -0
- package/src/upload/index.js +15 -1
- package/templates/godot-3d/README.md +3 -2
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
# it was parked, which is one of the limits docs/REPLAY.md names.
|
|
31
31
|
extends Node
|
|
32
32
|
|
|
33
|
-
const DRIVER_VERSION := "1.
|
|
33
|
+
const DRIVER_VERSION := "1.10.0"
|
|
34
34
|
const DEFAULT_PORT := 47800
|
|
35
35
|
const FEATURE_TAG := "ravensight_driver"
|
|
36
36
|
const ADDON_DIR := "ravensight_driver"
|
|
@@ -92,6 +92,10 @@ var _step_selects: Array = []
|
|
|
92
92
|
## The pointer as the driver last left it, and the buttons it holds down: a
|
|
93
93
|
## drag is a press, moves that carry the held button, and a release.
|
|
94
94
|
var _mouse_pos := Vector2.ZERO
|
|
95
|
+
## Fingers down on the touch screen (driver 1.10.0): index to where it is.
|
|
96
|
+
var _touch_pos := {}
|
|
97
|
+
const MAX_TOUCH_INDEX := 9
|
|
98
|
+
const TOUCH_KINDS := ["down", "move", "up"]
|
|
95
99
|
var _mouse_mask := 0
|
|
96
100
|
## In lockstep the game hears only the run's pointer (driver 1.6.0): a node last in
|
|
97
101
|
## the root's input order swallows any mouse event the driver is not sending.
|
|
@@ -371,6 +375,7 @@ func _handle_line(line: String) -> void:
|
|
|
371
375
|
"key": _rpc_key(id, params)
|
|
372
376
|
"click": _rpc_click(id, params)
|
|
373
377
|
"mouse": _rpc_mouse(id, params)
|
|
378
|
+
"touch": _rpc_touch(id, params)
|
|
374
379
|
"wait_frames": _rpc_wait_frames(id, params)
|
|
375
380
|
"seed": _rpc_seed(id, params)
|
|
376
381
|
"step": _rpc_step(id, params)
|
|
@@ -387,6 +392,9 @@ func _handle_line(line: String) -> void:
|
|
|
387
392
|
"set_time_scale": _rpc_set_time_scale(id, params)
|
|
388
393
|
"list_actions": _send_result(id, {"actions": _action_names()})
|
|
389
394
|
"quit": _rpc_quit(id, params)
|
|
395
|
+
"playtest_start": _rpc_playtest_start(id, params)
|
|
396
|
+
"joypad": _rpc_joypad(id, params)
|
|
397
|
+
"view3d": _rpc_view3d(id, params)
|
|
390
398
|
_: _send_error(id, ERR_METHOD_NOT_FOUND, "method not found: %s" % method)
|
|
391
399
|
|
|
392
400
|
|
|
@@ -750,6 +758,8 @@ func _send_mouse_event(kind: String, pos: Vector2, params: Dictionary) -> void:
|
|
|
750
758
|
_stamp_modifiers(click)
|
|
751
759
|
_mouse_pos = pos
|
|
752
760
|
_parse_pointer(click)
|
|
761
|
+
"look":
|
|
762
|
+
_send_look(params)
|
|
753
763
|
"wheel":
|
|
754
764
|
_send_mouse_event("move", pos, params)
|
|
755
765
|
var dy := float(params.get("dy", 0.0))
|
|
@@ -781,12 +791,14 @@ func _send_wheel(pos: Vector2, button: MouseButton, amount: float, params: Dicti
|
|
|
781
791
|
_parse_pointer(wheel)
|
|
782
792
|
|
|
783
793
|
|
|
784
|
-
const MOUSE_KINDS := ["move", "down", "up", "wheel"]
|
|
794
|
+
const MOUSE_KINDS := ["move", "down", "up", "wheel", "look"]
|
|
785
795
|
|
|
786
796
|
|
|
787
797
|
## Where a mouse event lands: a node's centre, or the point given. Null when a
|
|
788
798
|
## named node cannot be pointed at.
|
|
789
799
|
func _mouse_target(params: Dictionary) -> Variant:
|
|
800
|
+
if str(params.get("kind", "")) == "look":
|
|
801
|
+
return _mouse_pos
|
|
790
802
|
if params.has("node_path"):
|
|
791
803
|
return _click_position(get_node_or_null(NodePath(str(params.get("node_path")))))
|
|
792
804
|
return Vector2(float(params.get("x", 0.0)), float(params.get("y", 0.0)))
|
|
@@ -805,7 +817,7 @@ func _rpc_mouse(id: Variant, params: Dictionary) -> void:
|
|
|
805
817
|
return
|
|
806
818
|
var kind := str(params.get("kind", ""))
|
|
807
819
|
if not (kind in MOUSE_KINDS):
|
|
808
|
-
_send_error(id, ERR_INVALID_PARAMS, "kind must be move, down, up or
|
|
820
|
+
_send_error(id, ERR_INVALID_PARAMS, "kind must be move, down, up, wheel or look")
|
|
809
821
|
return
|
|
810
822
|
var at: Variant = _mouse_target(params)
|
|
811
823
|
if at == null:
|
|
@@ -815,6 +827,75 @@ func _rpc_mouse(id: Variant, params: Dictionary) -> void:
|
|
|
815
827
|
_send_result(id, {"ok": true, "position": [(at as Vector2).x, (at as Vector2).y]})
|
|
816
828
|
|
|
817
829
|
|
|
830
|
+
## --- Touch (driver 1.10.0) ------------------------------------------------------
|
|
831
|
+
## A finger on a touch screen, as a phone's is: `down` and `up` are an
|
|
832
|
+
## InputEventScreenTouch, `move` an InputEventScreenDrag carrying how far that
|
|
833
|
+
## finger moved since its last event. Each finger has its own index, so two
|
|
834
|
+
## fingers are down at once (a thumb on a stick while the other taps fire, a
|
|
835
|
+
## pinch). Godot makes the first finger a mouse too when the project's
|
|
836
|
+
## emulate_mouse_from_touch is on (its default), as on a device.
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
## The checked form of a touch event: `{kind, index, position}`, or `{code, message}`.
|
|
840
|
+
func _check_touch(params: Dictionary) -> Dictionary:
|
|
841
|
+
var problem := _check_params(params, {"kind": "string", "index": "number", "x": "number", "y": "number"})
|
|
842
|
+
if not problem.is_empty():
|
|
843
|
+
return {"code": ERR_INVALID_PARAMS, "message": problem}
|
|
844
|
+
var kind := str(params.get("kind", ""))
|
|
845
|
+
if not (kind in TOUCH_KINDS):
|
|
846
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a touch event's kind is down, move or up"}
|
|
847
|
+
var index_value := float(params.get("index", 0))
|
|
848
|
+
if index_value != floor(index_value) or index_value < 0 or index_value > MAX_TOUCH_INDEX:
|
|
849
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a finger's index is a whole number from 0 to %d" % MAX_TOUCH_INDEX}
|
|
850
|
+
return {"kind": kind, "index": int(index_value), "position": Vector2(float(params.get("x", 0.0)), float(params.get("y", 0.0)))}
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
func _send_touch_event(kind: String, index: int, pos: Vector2) -> void:
|
|
854
|
+
if kind == "move" and not _touch_pos.has(index):
|
|
855
|
+
# A finger that moves is down: one that was not is put down where it is.
|
|
856
|
+
kind = "down"
|
|
857
|
+
match kind:
|
|
858
|
+
"down", "up":
|
|
859
|
+
var down := kind == "down"
|
|
860
|
+
if not down and not _touch_pos.has(index):
|
|
861
|
+
return
|
|
862
|
+
var touch := InputEventScreenTouch.new()
|
|
863
|
+
touch.index = index
|
|
864
|
+
touch.position = pos
|
|
865
|
+
touch.pressed = down
|
|
866
|
+
if down:
|
|
867
|
+
_touch_pos[index] = pos
|
|
868
|
+
else:
|
|
869
|
+
_touch_pos.erase(index)
|
|
870
|
+
_parse_pointer(touch)
|
|
871
|
+
"move":
|
|
872
|
+
var drag := InputEventScreenDrag.new()
|
|
873
|
+
drag.index = index
|
|
874
|
+
drag.position = pos
|
|
875
|
+
drag.relative = pos - (_touch_pos[index] as Vector2)
|
|
876
|
+
# A property Godot gained after 4.2, so it is set by name.
|
|
877
|
+
if "screen_relative" in drag:
|
|
878
|
+
drag.set("screen_relative", drag.relative)
|
|
879
|
+
_touch_pos[index] = pos
|
|
880
|
+
_parse_pointer(drag)
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
## Lift every finger still down: a run never leaves one on the screen.
|
|
884
|
+
func _lift_all_fingers() -> void:
|
|
885
|
+
for index in _touch_pos.keys():
|
|
886
|
+
_send_touch_event("up", int(index), _touch_pos[index])
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
## `touch{kind, index, x, y}`: one finger's event.
|
|
890
|
+
func _rpc_touch(id: Variant, params: Dictionary) -> void:
|
|
891
|
+
var touch := _check_touch(params)
|
|
892
|
+
if touch.has("code"):
|
|
893
|
+
_send_error(id, int(touch["code"]), str(touch["message"]))
|
|
894
|
+
return
|
|
895
|
+
_send_touch_event(str(touch["kind"]), int(touch["index"]), touch["position"])
|
|
896
|
+
_send_result(id, {"ok": true, "fingers": _touch_pos.size()})
|
|
897
|
+
|
|
898
|
+
|
|
818
899
|
func _rpc_wait_frames(id: Variant, params: Dictionary) -> void:
|
|
819
900
|
var problem := _check_params(params, {"n": "number"})
|
|
820
901
|
if not problem.is_empty():
|
|
@@ -1486,10 +1567,461 @@ func _rpc_quit(id: Variant, params: Dictionary) -> void:
|
|
|
1486
1567
|
_send_result(id, {"ok": true})
|
|
1487
1568
|
if _peer != null:
|
|
1488
1569
|
_peer.poll()
|
|
1570
|
+
# close_request (driver 1.8.0): closed the way a player closes the window, so
|
|
1571
|
+
# a game that saves on NOTIFICATION_WM_CLOSE_REQUEST saves, and gets a few
|
|
1572
|
+
# frames to write it before the engine quits. The clock runs for them.
|
|
1573
|
+
if params.get("close_request", false) == true:
|
|
1574
|
+
if _lockstep:
|
|
1575
|
+
Engine.time_scale = _resume_scale
|
|
1576
|
+
elif Engine.time_scale <= 0.0:
|
|
1577
|
+
Engine.time_scale = 1.0
|
|
1578
|
+
get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
|
|
1579
|
+
for i in 10:
|
|
1580
|
+
await get_tree().process_frame
|
|
1489
1581
|
await get_tree().process_frame
|
|
1490
1582
|
get_tree().quit(code)
|
|
1491
1583
|
|
|
1492
1584
|
|
|
1585
|
+
## The run's start (driver 1.8.0): the CLI placed the studio's saves before
|
|
1586
|
+
## boot, and this hands the start spec to the game. The game opts in by giving
|
|
1587
|
+
## any node in the group "ravensight_playtest_start", or any autoload, a method
|
|
1588
|
+
## _ravensight_playtest_start(spec: Dictionary) that loads what it names and
|
|
1589
|
+
## answers with what it loaded (a String, or a Dictionary with "loaded" and
|
|
1590
|
+
## "where"). The first node that has the method is called, once.
|
|
1591
|
+
const START_METHOD := "_ravensight_playtest_start"
|
|
1592
|
+
const START_GROUP := "ravensight_playtest_start"
|
|
1593
|
+
|
|
1594
|
+
func _rpc_playtest_start(id: Variant, params: Dictionary) -> void:
|
|
1595
|
+
var problem := _check_params(params, {"spec": "string", "saves": "array"})
|
|
1596
|
+
if not problem.is_empty():
|
|
1597
|
+
_send_error(id, ERR_INVALID_PARAMS, problem)
|
|
1598
|
+
return
|
|
1599
|
+
var target: Node = null
|
|
1600
|
+
for node in get_tree().get_nodes_in_group(START_GROUP):
|
|
1601
|
+
if node.has_method(START_METHOD):
|
|
1602
|
+
target = node
|
|
1603
|
+
break
|
|
1604
|
+
if target == null:
|
|
1605
|
+
for node in get_tree().root.get_children():
|
|
1606
|
+
if node != self and node.has_method(START_METHOD):
|
|
1607
|
+
target = node
|
|
1608
|
+
break
|
|
1609
|
+
if target == null:
|
|
1610
|
+
_send_result(id, {"handled": false, "reason": "the game has no _ravensight_playtest_start method, so it was given the files and the environment variable only"})
|
|
1611
|
+
return
|
|
1612
|
+
var spec := {"spec": str(params.get("spec", "")), "saves": params.get("saves", [])}
|
|
1613
|
+
var answer: Variant = target.call(START_METHOD, spec)
|
|
1614
|
+
var out := {"handled": true, "method": str(target.get_path())}
|
|
1615
|
+
if typeof(answer) == TYPE_STRING:
|
|
1616
|
+
out["loaded"] = str(answer).left(500)
|
|
1617
|
+
elif typeof(answer) == TYPE_DICTIONARY:
|
|
1618
|
+
out["loaded"] = str((answer as Dictionary).get("loaded", "")).left(500)
|
|
1619
|
+
out["where"] = str((answer as Dictionary).get("where", "")).left(200)
|
|
1620
|
+
elif typeof(answer) == TYPE_BOOL and answer == false:
|
|
1621
|
+
out["handled"] = false
|
|
1622
|
+
out["reason"] = "the game's start method answered false"
|
|
1623
|
+
_send_result(id, out)
|
|
1624
|
+
|
|
1625
|
+
|
|
1626
|
+
## --- 3D play (driver 1.9.0) ----------------------------------------------------
|
|
1627
|
+
|
|
1628
|
+
## A relative mouse move, as a mouse turning a first person view sends it: the
|
|
1629
|
+
## motion's `relative` is the move, which is what a mouse look reads. With the
|
|
1630
|
+
## mouse captured the pointer stays where the engine keeps it, the middle of the
|
|
1631
|
+
## window; otherwise it moves by the same amount, kept inside the window. Held
|
|
1632
|
+
## buttons ride along, so a look with the right button held is an orbit drag.
|
|
1633
|
+
func _send_look(params: Dictionary) -> void:
|
|
1634
|
+
var delta := Vector2(float(params.get("dx", 0.0)), float(params.get("dy", 0.0)))
|
|
1635
|
+
var size := Vector2(get_window().size)
|
|
1636
|
+
var pos := _mouse_pos
|
|
1637
|
+
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
|
1638
|
+
pos = size / 2.0
|
|
1639
|
+
else:
|
|
1640
|
+
pos = (pos + delta).clamp(Vector2.ZERO, (size - Vector2.ONE).max(Vector2.ZERO))
|
|
1641
|
+
var motion := InputEventMouseMotion.new()
|
|
1642
|
+
motion.position = pos
|
|
1643
|
+
motion.global_position = pos
|
|
1644
|
+
motion.relative = delta
|
|
1645
|
+
motion.velocity = delta * float(maxi(Engine.physics_ticks_per_second, 1))
|
|
1646
|
+
# Properties Godot gained after 4.2, so they are set by name.
|
|
1647
|
+
if "screen_relative" in motion:
|
|
1648
|
+
motion.set("screen_relative", delta)
|
|
1649
|
+
if "screen_velocity" in motion:
|
|
1650
|
+
motion.set("screen_velocity", motion.velocity)
|
|
1651
|
+
motion.button_mask = _mouse_mask
|
|
1652
|
+
_stamp_modifiers(motion)
|
|
1653
|
+
_mouse_pos = pos
|
|
1654
|
+
_parse_pointer(motion)
|
|
1655
|
+
|
|
1656
|
+
|
|
1657
|
+
func _mouse_mode_name() -> String:
|
|
1658
|
+
match Input.mouse_mode:
|
|
1659
|
+
Input.MOUSE_MODE_CAPTURED: return "captured"
|
|
1660
|
+
Input.MOUSE_MODE_HIDDEN: return "hidden"
|
|
1661
|
+
Input.MOUSE_MODE_CONFINED, Input.MOUSE_MODE_CONFINED_HIDDEN: return "confined"
|
|
1662
|
+
return "visible"
|
|
1663
|
+
|
|
1664
|
+
|
|
1665
|
+
## A virtual gamepad on device 0: its buttons (the engine's JoyButton numbers)
|
|
1666
|
+
## and six axes (left x and y, right x and y, left and right trigger). A step
|
|
1667
|
+
## sets the whole pad; what changed is sent as joypad events, so actions bound
|
|
1668
|
+
## to a stick read its strength and Input.get_joy_axis reads the stick.
|
|
1669
|
+
const JOY_DEVICE := 0
|
|
1670
|
+
const MAX_JOY_BUTTON := 20
|
|
1671
|
+
const JOY_AXES := 6
|
|
1672
|
+
var _joy_buttons := {}
|
|
1673
|
+
var _joy_axes: Array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
|
1674
|
+
var _joy_used := false
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
func _check_joypad(event: Dictionary) -> Dictionary:
|
|
1678
|
+
var raw_buttons: Variant = event.get("buttons", [])
|
|
1679
|
+
var raw_axes: Variant = event.get("axes", [])
|
|
1680
|
+
if typeof(raw_buttons) != TYPE_ARRAY or typeof(raw_axes) != TYPE_ARRAY:
|
|
1681
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a joypad event has buttons and axes arrays"}
|
|
1682
|
+
var buttons: Array = []
|
|
1683
|
+
for value in raw_buttons:
|
|
1684
|
+
if typeof(value) != TYPE_INT and typeof(value) != TYPE_FLOAT:
|
|
1685
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a joypad button is a number from 0 to %d" % MAX_JOY_BUTTON}
|
|
1686
|
+
var index := int(value)
|
|
1687
|
+
if index < 0 or index > MAX_JOY_BUTTON:
|
|
1688
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a joypad button is a number from 0 to %d" % MAX_JOY_BUTTON}
|
|
1689
|
+
if not (index in buttons):
|
|
1690
|
+
buttons.append(index)
|
|
1691
|
+
if raw_axes.size() > JOY_AXES:
|
|
1692
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a joypad has %d axes" % JOY_AXES}
|
|
1693
|
+
var axes: Array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
|
1694
|
+
for i in raw_axes.size():
|
|
1695
|
+
var value: Variant = raw_axes[i]
|
|
1696
|
+
if typeof(value) != TYPE_INT and typeof(value) != TYPE_FLOAT:
|
|
1697
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a joypad axis is a number from -1 to 1"}
|
|
1698
|
+
axes[i] = clampf(float(value), 0.0 if i >= 4 else -1.0, 1.0)
|
|
1699
|
+
return {"buttons": buttons, "axes": axes}
|
|
1700
|
+
|
|
1701
|
+
|
|
1702
|
+
func _apply_joypad(pad: Dictionary) -> void:
|
|
1703
|
+
_joy_used = true
|
|
1704
|
+
var wanted := {}
|
|
1705
|
+
for index in pad["buttons"]:
|
|
1706
|
+
wanted[int(index)] = true
|
|
1707
|
+
var every := _joy_buttons.duplicate()
|
|
1708
|
+
every.merge(wanted)
|
|
1709
|
+
for index in every:
|
|
1710
|
+
var down := wanted.has(index)
|
|
1711
|
+
if down == _joy_buttons.has(index):
|
|
1712
|
+
continue
|
|
1713
|
+
_send_joy_button(int(index), down)
|
|
1714
|
+
_joy_buttons = wanted
|
|
1715
|
+
for i in JOY_AXES:
|
|
1716
|
+
var value := float(pad["axes"][i])
|
|
1717
|
+
if is_equal_approx(value, float(_joy_axes[i])):
|
|
1718
|
+
continue
|
|
1719
|
+
_joy_axes[i] = value
|
|
1720
|
+
_send_joy_axis(i, value)
|
|
1721
|
+
|
|
1722
|
+
|
|
1723
|
+
func _send_joy_button(index: int, pressed: bool) -> void:
|
|
1724
|
+
var event := InputEventJoypadButton.new()
|
|
1725
|
+
event.device = JOY_DEVICE
|
|
1726
|
+
event.button_index = index as JoyButton
|
|
1727
|
+
event.pressed = pressed
|
|
1728
|
+
Input.parse_input_event(event)
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
func _send_joy_axis(axis: int, value: float) -> void:
|
|
1732
|
+
var event := InputEventJoypadMotion.new()
|
|
1733
|
+
event.device = JOY_DEVICE
|
|
1734
|
+
event.axis = axis as JoyAxis
|
|
1735
|
+
event.axis_value = value
|
|
1736
|
+
Input.parse_input_event(event)
|
|
1737
|
+
|
|
1738
|
+
|
|
1739
|
+
## The desktop can take the pad's state away with focus, as it does held keys;
|
|
1740
|
+
## the trace says the stick is pushed, so it is pushed again on the next tick.
|
|
1741
|
+
func _reassert_joypad() -> void:
|
|
1742
|
+
if not _joy_used:
|
|
1743
|
+
return
|
|
1744
|
+
for i in JOY_AXES:
|
|
1745
|
+
if absf(Input.get_joy_axis(JOY_DEVICE, i as JoyAxis) - float(_joy_axes[i])) > 0.001:
|
|
1746
|
+
_reasserted += 1
|
|
1747
|
+
_send_joy_axis(i, float(_joy_axes[i]))
|
|
1748
|
+
for index in _joy_buttons:
|
|
1749
|
+
if not Input.is_joy_button_pressed(JOY_DEVICE, int(index) as JoyButton):
|
|
1750
|
+
_reasserted += 1
|
|
1751
|
+
_send_joy_button(int(index), true)
|
|
1752
|
+
|
|
1753
|
+
|
|
1754
|
+
func _rpc_joypad(id: Variant, params: Dictionary) -> void:
|
|
1755
|
+
var pad := _check_joypad(params)
|
|
1756
|
+
if pad.has("code"):
|
|
1757
|
+
_send_error(id, int(pad["code"]), str(pad["message"]))
|
|
1758
|
+
return
|
|
1759
|
+
_apply_joypad(pad)
|
|
1760
|
+
_send_result(id, {"ok": true, "buttons": pad["buttons"], "axes": pad["axes"]})
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
## `view3d{target}`: what a 3D game's own state says about the view and the
|
|
1764
|
+
## player, read without moving anything (so a lockstep digest is unchanged).
|
|
1765
|
+
## The camera's place and facing, whether it sits inside a solid body and what
|
|
1766
|
+
## stands between it and the player, what the middle of the screen points at,
|
|
1767
|
+
## the bodies that move (their velocity and is_on_floor), what is on screen,
|
|
1768
|
+
## and how far the level's solid geometry reaches. `target` (a node path) adds
|
|
1769
|
+
## where that node is on screen and how far the view must turn to face it.
|
|
1770
|
+
const MAX_VIEW_BODIES := 12
|
|
1771
|
+
const MAX_VIEW_TARGETS := 12
|
|
1772
|
+
const VIEW_RAY_LENGTH := 2000.0
|
|
1773
|
+
var _world_scene_id := 0
|
|
1774
|
+
var _world_box: Variant = null
|
|
1775
|
+
|
|
1776
|
+
|
|
1777
|
+
func _rpc_view3d(id: Variant, params: Dictionary) -> void:
|
|
1778
|
+
var problem := _check_params(params, {"target": "string"})
|
|
1779
|
+
if not problem.is_empty():
|
|
1780
|
+
_send_error(id, ERR_INVALID_PARAMS, problem)
|
|
1781
|
+
return
|
|
1782
|
+
var window_size := Vector2(get_window().size)
|
|
1783
|
+
var out := {"has_3d": false, "paused": get_tree().paused, "mouse_mode": _mouse_mode_name(), "window": [window_size.x, window_size.y]}
|
|
1784
|
+
var camera := get_viewport().get_camera_3d()
|
|
1785
|
+
var scene := get_tree().current_scene
|
|
1786
|
+
if camera == null or scene == null or not camera.is_inside_tree():
|
|
1787
|
+
_send_result(id, out)
|
|
1788
|
+
return
|
|
1789
|
+
out["has_3d"] = true
|
|
1790
|
+
var space := camera.get_world_3d().direct_space_state
|
|
1791
|
+
var forward := -camera.global_transform.basis.z.normalized()
|
|
1792
|
+
var up := camera.global_transform.basis.y.normalized()
|
|
1793
|
+
var carriers := _carrier_rids(camera)
|
|
1794
|
+
var bodies := _moving_bodies(scene)
|
|
1795
|
+
var player: Variant = _player_of(bodies, camera)
|
|
1796
|
+
var cam := {
|
|
1797
|
+
"path": str(camera.get_path()),
|
|
1798
|
+
"position": _vec3(camera.global_position),
|
|
1799
|
+
"forward": _vec3(forward),
|
|
1800
|
+
"up": _vec3(up),
|
|
1801
|
+
"yaw": snappedf(_yaw_of(forward), 0.01),
|
|
1802
|
+
"pitch": snappedf(rad_to_deg(asin(clampf(forward.y, -1.0, 1.0))), 0.01),
|
|
1803
|
+
"fov": snappedf(camera.fov, 0.01),
|
|
1804
|
+
"orthogonal": camera.projection == Camera3D.PROJECTION_ORTHOGONAL,
|
|
1805
|
+
}
|
|
1806
|
+
var inside := _solid_at(space, camera.global_position, carriers)
|
|
1807
|
+
if not inside.is_empty():
|
|
1808
|
+
cam["inside"] = inside
|
|
1809
|
+
if player != null and not ((player as Node3D) in _carrier_nodes(camera)):
|
|
1810
|
+
var blocked := _first_hit(space, (player as Node3D).global_position, camera.global_position, carriers + [(player as CollisionObject3D).get_rid()])
|
|
1811
|
+
if not blocked.is_empty():
|
|
1812
|
+
cam["blocked_by"] = blocked
|
|
1813
|
+
out["camera"] = cam
|
|
1814
|
+
var centre := camera.get_viewport().get_visible_rect().size / 2.0
|
|
1815
|
+
var from := camera.project_ray_origin(centre)
|
|
1816
|
+
var aim := _first_hit(space, from, from + camera.project_ray_normal(centre) * VIEW_RAY_LENGTH, carriers)
|
|
1817
|
+
if not aim.is_empty():
|
|
1818
|
+
out["crosshair"] = aim
|
|
1819
|
+
out["screen_centre"] = [window_size.x / 2.0, window_size.y / 2.0]
|
|
1820
|
+
var listed: Array = []
|
|
1821
|
+
if player != null:
|
|
1822
|
+
listed.append(_body_view(player as Node3D, true))
|
|
1823
|
+
var others := bodies.filter(func(b): return b != player)
|
|
1824
|
+
if player != null:
|
|
1825
|
+
var anchor := (player as Node3D).global_position
|
|
1826
|
+
others.sort_custom(func(a, b): return (a as Node3D).global_position.distance_squared_to(anchor) < (b as Node3D).global_position.distance_squared_to(anchor))
|
|
1827
|
+
for body in others:
|
|
1828
|
+
if listed.size() >= MAX_VIEW_BODIES:
|
|
1829
|
+
break
|
|
1830
|
+
listed.append(_body_view(body as Node3D, false))
|
|
1831
|
+
out["bodies"] = listed
|
|
1832
|
+
out["on_screen"] = _on_screen(scene, camera, player)
|
|
1833
|
+
var box := _world_bounds(scene)
|
|
1834
|
+
if box != null:
|
|
1835
|
+
var aabb: AABB = box
|
|
1836
|
+
out["world"] = {"min": _vec3(aabb.position), "max": _vec3(aabb.end)}
|
|
1837
|
+
if params.has("target"):
|
|
1838
|
+
var node := get_node_or_null(NodePath(str(params.get("target"))))
|
|
1839
|
+
if not (node is Node3D):
|
|
1840
|
+
_send_error(id, ERR_NODE_NOT_FOUND, "3D node not found: %s" % str(params.get("target")))
|
|
1841
|
+
return
|
|
1842
|
+
out["target"] = _target_view(node as Node3D, camera, forward)
|
|
1843
|
+
_send_result(id, out)
|
|
1844
|
+
|
|
1845
|
+
|
|
1846
|
+
func _vec3(v: Vector3) -> Array:
|
|
1847
|
+
return [snappedf(v.x, 0.001), snappedf(v.y, 0.001), snappedf(v.z, 0.001)]
|
|
1848
|
+
|
|
1849
|
+
|
|
1850
|
+
## Degrees turned from facing -Z, positive to the left: the camera's rotation.y.
|
|
1851
|
+
func _yaw_of(direction: Vector3) -> float:
|
|
1852
|
+
return rad_to_deg(atan2(-direction.x, -direction.z))
|
|
1853
|
+
|
|
1854
|
+
|
|
1855
|
+
## The bodies a camera rides on (a first person camera inside the player's
|
|
1856
|
+
## capsule is not inside a wall), by node and by physics id.
|
|
1857
|
+
func _carrier_nodes(camera: Node) -> Array:
|
|
1858
|
+
var out: Array = []
|
|
1859
|
+
var node := camera.get_parent()
|
|
1860
|
+
while node != null:
|
|
1861
|
+
if node is CollisionObject3D:
|
|
1862
|
+
out.append(node)
|
|
1863
|
+
node = node.get_parent()
|
|
1864
|
+
return out
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
func _carrier_rids(camera: Node) -> Array:
|
|
1868
|
+
var out: Array = []
|
|
1869
|
+
for node in _carrier_nodes(camera):
|
|
1870
|
+
out.append((node as CollisionObject3D).get_rid())
|
|
1871
|
+
return out
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
func _solid_at(space: PhysicsDirectSpaceState3D, point: Vector3, exclude: Array) -> Dictionary:
|
|
1875
|
+
var query := PhysicsPointQueryParameters3D.new()
|
|
1876
|
+
query.position = point
|
|
1877
|
+
query.collide_with_areas = false
|
|
1878
|
+
query.collide_with_bodies = true
|
|
1879
|
+
query.exclude = exclude
|
|
1880
|
+
for hit in space.intersect_point(query, 4):
|
|
1881
|
+
var collider: Variant = hit.get("collider")
|
|
1882
|
+
if collider is Node:
|
|
1883
|
+
return {"path": str((collider as Node).get_path()), "name": str((collider as Node).name)}
|
|
1884
|
+
return {}
|
|
1885
|
+
|
|
1886
|
+
|
|
1887
|
+
func _first_hit(space: PhysicsDirectSpaceState3D, from: Vector3, to: Vector3, exclude: Array) -> Dictionary:
|
|
1888
|
+
var query := PhysicsRayQueryParameters3D.create(from, to)
|
|
1889
|
+
query.exclude = exclude
|
|
1890
|
+
query.collide_with_areas = false
|
|
1891
|
+
var hit := space.intersect_ray(query)
|
|
1892
|
+
if hit.is_empty() or not (hit.get("collider") is Node):
|
|
1893
|
+
return {}
|
|
1894
|
+
var collider: Node = hit["collider"]
|
|
1895
|
+
var point: Vector3 = hit["position"]
|
|
1896
|
+
return {"path": str(collider.get_path()), "name": str(collider.name), "distance": snappedf(from.distance_to(point), 0.01), "point": _vec3(point)}
|
|
1897
|
+
|
|
1898
|
+
|
|
1899
|
+
## The bodies that move: CharacterBody3D, VehicleBody3D and RigidBody3D in the
|
|
1900
|
+
## current scene, in tree order.
|
|
1901
|
+
func _moving_bodies(scene: Node) -> Array:
|
|
1902
|
+
var out: Array = []
|
|
1903
|
+
var stack: Array = [scene]
|
|
1904
|
+
var seen := 0
|
|
1905
|
+
while not stack.is_empty() and seen < MAX_NODES:
|
|
1906
|
+
var node: Node = stack.pop_back()
|
|
1907
|
+
seen += 1
|
|
1908
|
+
if node is CharacterBody3D or node is RigidBody3D:
|
|
1909
|
+
out.append(node)
|
|
1910
|
+
var children := node.get_children()
|
|
1911
|
+
children.reverse()
|
|
1912
|
+
stack.append_array(children)
|
|
1913
|
+
return out
|
|
1914
|
+
|
|
1915
|
+
|
|
1916
|
+
## The player: a body in the group "player", else the body the camera rides,
|
|
1917
|
+
## else the first character body, else the first vehicle.
|
|
1918
|
+
func _player_of(bodies: Array, camera: Camera3D) -> Variant:
|
|
1919
|
+
for body in bodies:
|
|
1920
|
+
if (body as Node).is_in_group("player") or (body as Node).is_in_group("Player"):
|
|
1921
|
+
return body
|
|
1922
|
+
for node in _carrier_nodes(camera):
|
|
1923
|
+
if node in bodies:
|
|
1924
|
+
return node
|
|
1925
|
+
for body in bodies:
|
|
1926
|
+
if body is CharacterBody3D:
|
|
1927
|
+
return body
|
|
1928
|
+
for body in bodies:
|
|
1929
|
+
if body is VehicleBody3D:
|
|
1930
|
+
return body
|
|
1931
|
+
return null
|
|
1932
|
+
|
|
1933
|
+
|
|
1934
|
+
func _body_view(body: Node3D, is_player: bool) -> Dictionary:
|
|
1935
|
+
var out := {"path": str(body.get_path()), "name": str(body.name), "type": body.get_class(), "position": _vec3(body.global_position)}
|
|
1936
|
+
var velocity := Vector3.ZERO
|
|
1937
|
+
if body is CharacterBody3D:
|
|
1938
|
+
var character := body as CharacterBody3D
|
|
1939
|
+
velocity = character.velocity
|
|
1940
|
+
out["on_floor"] = character.is_on_floor()
|
|
1941
|
+
out["on_wall"] = character.is_on_wall()
|
|
1942
|
+
out["on_ceiling"] = character.is_on_ceiling()
|
|
1943
|
+
elif body is RigidBody3D:
|
|
1944
|
+
velocity = (body as RigidBody3D).linear_velocity
|
|
1945
|
+
out["sleeping"] = (body as RigidBody3D).sleeping
|
|
1946
|
+
out["velocity"] = _vec3(velocity)
|
|
1947
|
+
out["speed"] = snappedf(velocity.length(), 0.01)
|
|
1948
|
+
if is_player:
|
|
1949
|
+
out["player"] = true
|
|
1950
|
+
return out
|
|
1951
|
+
|
|
1952
|
+
|
|
1953
|
+
## What is on screen to aim at: solid bodies and areas in front of the camera,
|
|
1954
|
+
## inside the window, nearest the middle of the screen first.
|
|
1955
|
+
func _on_screen(scene: Node, camera: Camera3D, player: Variant) -> Array:
|
|
1956
|
+
var out: Array = []
|
|
1957
|
+
var window_size := Vector2(get_window().size)
|
|
1958
|
+
var centre := window_size / 2.0
|
|
1959
|
+
var carriers := _carrier_nodes(camera)
|
|
1960
|
+
var stack: Array = [scene]
|
|
1961
|
+
var seen := 0
|
|
1962
|
+
while not stack.is_empty() and seen < MAX_NODES:
|
|
1963
|
+
var node: Node = stack.pop_back()
|
|
1964
|
+
seen += 1
|
|
1965
|
+
stack.append_array(node.get_children())
|
|
1966
|
+
if not (node is CollisionObject3D) or node == player or node in carriers:
|
|
1967
|
+
continue
|
|
1968
|
+
if node is StaticBody3D and not (node is AnimatableBody3D):
|
|
1969
|
+
continue
|
|
1970
|
+
var body := node as Node3D
|
|
1971
|
+
if not body.is_visible_in_tree() or camera.is_position_behind(body.global_position):
|
|
1972
|
+
continue
|
|
1973
|
+
var at := get_window().get_final_transform() * camera.unproject_position(body.global_position)
|
|
1974
|
+
if at.x < 0.0 or at.y < 0.0 or at.x > window_size.x or at.y > window_size.y:
|
|
1975
|
+
continue
|
|
1976
|
+
out.append({"path": str(body.get_path()), "name": str(body.name), "screen": [roundf(at.x), roundf(at.y)], "distance": snappedf(camera.global_position.distance_to(body.global_position), 0.01), "_off": at.distance_to(centre)})
|
|
1977
|
+
out.sort_custom(func(a, b): return float(a["_off"]) < float(b["_off"]))
|
|
1978
|
+
out = out.slice(0, MAX_VIEW_TARGETS)
|
|
1979
|
+
for item in out:
|
|
1980
|
+
(item as Dictionary).erase("_off")
|
|
1981
|
+
return out
|
|
1982
|
+
|
|
1983
|
+
|
|
1984
|
+
func _target_view(node: Node3D, camera: Camera3D, forward: Vector3) -> Dictionary:
|
|
1985
|
+
var to := node.global_position - camera.global_position
|
|
1986
|
+
var out := {"path": str(node.get_path()), "name": str(node.name), "position": _vec3(node.global_position), "distance": snappedf(to.length(), 0.01), "behind": camera.is_position_behind(node.global_position)}
|
|
1987
|
+
if to.length() > 0.0001:
|
|
1988
|
+
var direction := to.normalized()
|
|
1989
|
+
out["yaw_error"] = snappedf(wrapf(_yaw_of(direction) - _yaw_of(forward), -180.0, 180.0), 0.01)
|
|
1990
|
+
out["pitch_error"] = snappedf(rad_to_deg(asin(clampf(direction.y, -1.0, 1.0)) - asin(clampf(forward.y, -1.0, 1.0))), 0.01)
|
|
1991
|
+
if not out["behind"]:
|
|
1992
|
+
var at := get_window().get_final_transform() * camera.unproject_position(node.global_position)
|
|
1993
|
+
out["screen"] = [roundf(at.x), roundf(at.y)]
|
|
1994
|
+
return out
|
|
1995
|
+
|
|
1996
|
+
|
|
1997
|
+
## How far the level's solid geometry reaches: the bounds of every collision
|
|
1998
|
+
## shape on a static body, worked out once per scene. A body far below its
|
|
1999
|
+
## lowest point has fallen out of the world.
|
|
2000
|
+
func _world_bounds(scene: Node) -> Variant:
|
|
2001
|
+
if scene.get_instance_id() == _world_scene_id:
|
|
2002
|
+
return _world_box
|
|
2003
|
+
_world_scene_id = scene.get_instance_id()
|
|
2004
|
+
_world_box = null
|
|
2005
|
+
var stack: Array = [scene]
|
|
2006
|
+
var seen := 0
|
|
2007
|
+
while not stack.is_empty() and seen < MAX_NODES:
|
|
2008
|
+
var node: Node = stack.pop_back()
|
|
2009
|
+
seen += 1
|
|
2010
|
+
stack.append_array(node.get_children())
|
|
2011
|
+
var box: Variant = null
|
|
2012
|
+
if node is CollisionShape3D and node.get_parent() is StaticBody3D and (node as CollisionShape3D).shape != null and not (node as CollisionShape3D).disabled:
|
|
2013
|
+
var shape := node as CollisionShape3D
|
|
2014
|
+
var mesh := shape.shape.get_debug_mesh()
|
|
2015
|
+
if mesh != null:
|
|
2016
|
+
box = shape.global_transform * mesh.get_aabb()
|
|
2017
|
+
elif node is CSGShape3D and (node as CSGShape3D).use_collision and (node as CSGShape3D).is_root_shape():
|
|
2018
|
+
box = (node as CSGShape3D).global_transform * (node as CSGShape3D).get_aabb()
|
|
2019
|
+
if box == null:
|
|
2020
|
+
continue
|
|
2021
|
+
_world_box = box if _world_box == null else (_world_box as AABB).merge(box)
|
|
2022
|
+
return _world_box
|
|
2023
|
+
|
|
2024
|
+
|
|
1493
2025
|
## --- Lockstep -----------------------------------------------------------------
|
|
1494
2026
|
|
|
1495
2027
|
## Stops the clock and takes the seed. Runs in _ready, before the main scene, and
|
|
@@ -1753,6 +2285,7 @@ func _reassert_held() -> void:
|
|
|
1753
2285
|
if not Input.is_action_pressed(action):
|
|
1754
2286
|
_reasserted += 1
|
|
1755
2287
|
Input.action_press(action)
|
|
2288
|
+
_reassert_joypad()
|
|
1756
2289
|
|
|
1757
2290
|
|
|
1758
2291
|
func _check_step_event(raw: Variant) -> Dictionary:
|
|
@@ -1781,7 +2314,7 @@ func _check_step_event(raw: Variant) -> Dictionary:
|
|
|
1781
2314
|
return {"type": "click", "position": pos, "params": event}
|
|
1782
2315
|
"mouse":
|
|
1783
2316
|
if not (str(event.get("kind", "")) in MOUSE_KINDS):
|
|
1784
|
-
return {"code": ERR_INVALID_PARAMS, "message": "a mouse event's kind is move, down, up or
|
|
2317
|
+
return {"code": ERR_INVALID_PARAMS, "message": "a mouse event's kind is move, down, up, wheel or look"}
|
|
1785
2318
|
var where: Variant = _mouse_target(event)
|
|
1786
2319
|
if where == null:
|
|
1787
2320
|
return {"code": ERR_NODE_NOT_FOUND, "message": "clickable node not found: %s" % str(event.get("node_path"))}
|
|
@@ -1791,6 +2324,16 @@ func _check_step_event(raw: Variant) -> Dictionary:
|
|
|
1791
2324
|
if plan.has("code"):
|
|
1792
2325
|
return plan
|
|
1793
2326
|
return {"type": "select", "plan": plan}
|
|
2327
|
+
"joypad":
|
|
2328
|
+
var pad := _check_joypad(event)
|
|
2329
|
+
if pad.has("code"):
|
|
2330
|
+
return pad
|
|
2331
|
+
return {"type": "joypad", "pad": pad}
|
|
2332
|
+
"touch":
|
|
2333
|
+
var touch := _check_touch(event)
|
|
2334
|
+
if touch.has("code"):
|
|
2335
|
+
return touch
|
|
2336
|
+
return {"type": "touch", "touch": touch}
|
|
1794
2337
|
return {"code": ERR_INVALID_PARAMS, "message": "unknown event type: %s" % str(event.get("type", ""))}
|
|
1795
2338
|
|
|
1796
2339
|
|
|
@@ -1809,6 +2352,11 @@ func _apply_step_event(event: Dictionary) -> void:
|
|
|
1809
2352
|
_send_mouse_event(str((event["params"] as Dictionary).get("kind", "move")), where, event["params"])
|
|
1810
2353
|
"select":
|
|
1811
2354
|
_step_selects.append(_select_apply(event["plan"]))
|
|
2355
|
+
"joypad":
|
|
2356
|
+
_apply_joypad(event["pad"])
|
|
2357
|
+
"touch":
|
|
2358
|
+
var touch: Dictionary = event["touch"]
|
|
2359
|
+
_send_touch_event(str(touch["kind"]), int(touch["index"]), touch["position"])
|
|
1812
2360
|
"click":
|
|
1813
2361
|
var at: Vector2 = event["position"]
|
|
1814
2362
|
_step_clicks.append([at.x, at.y])
|
|
@@ -1991,6 +2539,11 @@ func _node_to_dict(node: Node, depth: int, max_depth: int, visible_only: bool, b
|
|
|
1991
2539
|
# it: _text_of is shared with the simulate addon's state digest.
|
|
1992
2540
|
if text.is_empty() and node is Window and node != get_tree().root and not (node is PopupMenu):
|
|
1993
2541
|
text = (node as Window).title
|
|
2542
|
+
# Words drawn in the world (a prompt over a door, a name over a unit) are
|
|
2543
|
+
# what a player reads too. Only the outline shows them, so a trace recorded
|
|
2544
|
+
# before driver 1.9.0 still digests the same.
|
|
2545
|
+
if text.is_empty() and node is Label3D:
|
|
2546
|
+
text = (node as Label3D).text
|
|
1994
2547
|
if not text.is_empty():
|
|
1995
2548
|
out["text"] = text.substr(0, MAX_TEXT_CHARS)
|
|
1996
2549
|
else:
|