-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for generating RPC methods
Add networking demo.
- Loading branch information
1 parent
598cd82
commit 9907d28
Showing
27 changed files
with
979 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Normalize EOL for all files that Git considers text files. | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ | ||
/android/ | ||
|
||
# Ignore built libraries | ||
*.dll | ||
*.lib | ||
*.dylib | ||
*.pdb | ||
*.exp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[configuration] | ||
|
||
entry_symbol = "godot_dart_init" | ||
compatibility_minimum = 4.2 | ||
|
||
[icons] | ||
|
||
DartScript = "res://logo_dart.svg" | ||
|
||
[libraries] | ||
|
||
windows.x86_64 = "godot_dart.dll" | ||
linux.x86_64 = "libgodot_dart.so" | ||
macos.arm64 = "libgodot_dart.dylib" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://b0g1bchdfioi2" | ||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://icon.svg" | ||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 | ||
svg/scale=1.0 | ||
editor/scale_with_editor_scale=false | ||
editor/convert_colors_with_editor_theme=false |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://bvvbwm6rscs1r" | ||
path="res://.godot/imported/logo_dart.svg-7d78e4990ae1b9cb0a988a5863e5eb62.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://logo_dart.svg" | ||
dest_files=["res://.godot/imported/logo_dart.svg-7d78e4990ae1b9cb0a988a5863e5eb62.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 | ||
svg/scale=1.0 | ||
editor/scale_with_editor_scale=false | ||
editor/convert_colors_with_editor_theme=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=5 | ||
|
||
[application] | ||
|
||
config/name="Networking Demo" | ||
run/main_scene="res://world.tscn" | ||
config/features=PackedStringArray("4.4", "Forward Plus") | ||
config/icon="res://icon.svg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Files and directories created by pub. | ||
.dart_tool/ | ||
.packages | ||
|
||
# Conventional directory for build output. | ||
build/ | ||
|
||
# Don't check in generated files | ||
*.g.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
analyzer: | ||
exclude: | ||
- lib/src/gdextension_bindings.dart | ||
language: | ||
strict-casts: true | ||
strict-raw-types: true | ||
|
||
linter: | ||
rules: | ||
prefer_single_quotes: true | ||
prefer_relative_imports: true | ||
unawaited_futures: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:godot_dart/godot_dart.dart'; | ||
|
||
part 'world.g.dart'; | ||
|
||
@GodotScript() | ||
class World extends Node2D { | ||
static TypeInfo get sTypeInfo => _$WorldTypeInfo(); | ||
@override | ||
TypeInfo get typeInfo => sTypeInfo; | ||
|
||
World() : super(); | ||
|
||
World.withNonNullOwner(super.owner) : super.withNonNullOwner(); | ||
|
||
static const port = 12912; | ||
|
||
final enetPeer = ENetMultiplayerPeer(); | ||
late TextEdit _messages; | ||
late LineEdit _userNameBox; | ||
late LineEdit _line; | ||
|
||
String username = 'Unknown'; | ||
|
||
@override | ||
void vReady() { | ||
_line = getNodeT<LineEdit>('Line')!; | ||
_messages = getNodeT<TextEdit>('Messages')!; | ||
_userNameBox = getNodeT<LineEdit>('Username')!; | ||
} | ||
|
||
@GodotExport() | ||
void onHostPressed() { | ||
enetPeer.createServer(port); | ||
|
||
getMultiplayer()!.setMultiplayerPeer(enetPeer); | ||
_joined(); | ||
} | ||
|
||
@GodotExport() | ||
void onJoinPressed() { | ||
enetPeer.createClient('127.0.0.1', port); | ||
getMultiplayer()!.setMultiplayerPeer(enetPeer); | ||
_joined(); | ||
} | ||
|
||
@GodotRpc(mode: MultiplayerAPIRPCMode.rpcModeAnyPeer, callLocal: true) | ||
void messageRpc(String username, String data) { | ||
final newText = _messages.getText() + '$username: $data\n'; | ||
_messages.setText(newText); | ||
} | ||
|
||
@GodotExport() | ||
void onSendPressed() { | ||
final line = _line.getText(); | ||
_line.setText(''); | ||
$rpc.messageRpc(username, line); | ||
} | ||
|
||
void _joined() { | ||
username = _userNameBox.getText(); | ||
if (username.isEmpty) { | ||
username = 'Unknown'; | ||
} | ||
getNodeT<Button>('Host')?.hide(); | ||
getNodeT<Button>('Join')?.hide(); | ||
getNodeT<Control>('Username')?.hide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'godot_dart_scripts.g.dart'; | ||
|
||
void main() { | ||
attachScriptResolver(); | ||
} |
Oops, something went wrong.