Skip to content

Commit 5f359dd

Browse files
committed
chore: More template fixes and documentation changes.
1 parent 3a8df13 commit 5f359dd

4 files changed

Lines changed: 16 additions & 14 deletions

File tree

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ part 'simple_script.g.dart';
7272
class SimpleScript extends Sprite2D {
7373
// Return the type info that was generated...
7474
@pragma('vm:entry-point')
75-
static TypeInfo get sTypeInfo => _$SimpleScriptTypeInfo();
75+
static final ExtensionTypeInfo<SimpleScript> sTypeInfo = _$SimpleScriptTypeInfo();
7676
// And provide an instance method to get the type info
7777
@override
78-
TypeInfo get typeInfo => SimpleScript.sTypeInfo;
78+
ExtensionTypeInfo<SimpleScript> get typeInfo => sTypeInfo;
7979
8080
// Required constructor
8181
SimpleScript() : super();
@@ -124,8 +124,9 @@ void main() {
124124

125125
### Signals
126126

127-
You can add signals to your script with the `GodotSignal` property. This takes the signal name and a list
128-
of arguments for the signal:
127+
You can add signals to your script with the `GodotSignal` property, and adding one of the `SignalX` objects
128+
provided by Godot Dart, depending on the number of arguments: `Signal0` for a signal with zero arguments,
129+
`Signal1` for a signal with 1, etc.
129130

130131
```dart
131132
@GodotScript()
@@ -134,13 +135,13 @@ class Hud extends CanvasLayer {
134135
135136
136137
@GodotSignal('start_game')
137-
late final Signal _startGame = Signal.fromObjectSignal(this, 'start_game');
138+
late final Signal0 _startGame = Signal0(this, 'start_game');
138139
}
139140
```
140141

141-
You can then emit signals with `Signal.emit`.
142+
You can then emit signals with `SignalX.emit`.
142143

143-
Classes from Godot support type safe signal subscription for each or their signals. For example, if you
144+
These signals, and those provided in Godot, support type safe signal subscription. For example, if you
144145
want to subscribe to the `animation_added` signal on `AnimationLibrary`, you can do so like so:
145146

146147
```dart
@@ -239,9 +240,9 @@ void main() {
239240

240241
### Casting
241242

242-
Early versions of Godot Dart required using `.cast<T>` to perform downcasting. This is no longer
243-
necessary. Dart's built in `is` and `as` operators should now work to perform downcasting. `cast<T>`
244-
has also been removed and replaced with `.as<T>`, which is an implementation of `as?` or `dynamic_cast`.
243+
Dart's built in `is` and `as` operators should now work to perform downcasting. Godot Dart provides a convenience
244+
extension method `.as<T>`, which is an implementation of `as?` or `dynamic_cast`, and returns `null` if the
245+
object is not of the expected type.
245246

246247
### Virtual functions
247248

src/cpp/editor/dart_templates.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ const char *dart_script = "import 'package:godot_dart/godot_dart.dart';\n"
4444
"\n"
4545
"@GodotScript()\n"
4646
"class __CLASS_NAME__ extends __BASE_CLASS__ {\n"
47-
" @pragma('vm:entry-point')"
48-
" static ExtensionTypeInfo<__CLASS_NAME__> get sTypeInfo => _$__CLASS_NAME__TypeInfo();\n"
47+
" @pragma('vm:entry-point')\n"
48+
" static final ExtensionTypeInfo<__CLASS_NAME__> sTypeInfo = _$__CLASS_NAME__TypeInfo();\n"
49+
" @override\n"
50+
" ExtensionTypeInfo<__CLASS_NAME__> get typeInfo => sTypeInfo;\n"
4951
"\n"
5052
" __CLASS_NAME__() : super();\n"
5153
"\n"

src/dart/godot_dart/lib/src/extensions/async_extensions.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:async';
22

33
import '../../godot_dart.dart';
4-
import '../core/godot_dart_native_bridge.dart';
54

65
class SignalAwaiter extends GodotObject {
76
static final sTypeInfo = ExtensionTypeInfo<SignalAwaiter>(

src/dart/godot_dart_build/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: '>=3.6.0 <4.0.0'
88

99
dependencies:
10-
analyzer: ^5.13.0
10+
analyzer: ^9.0.0
1111
meta: ^1.9.0
1212
path: ^1.8.3
1313
collection: ^1.7.1

0 commit comments

Comments
 (0)