diff --git a/.prettierrc b/.prettierrc index de828d551..3b350c9d1 100644 --- a/.prettierrc +++ b/.prettierrc @@ -10,6 +10,14 @@ "useTabs": false, "semi": false } + }, + { + "files": "*.json", + "options": { + "tabWidth": 2, + "printWidth": 80, + "useTabs": false + } } ] -} +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 5a74ad33e..8b4ff320f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,20 +8,24 @@ "program": "${workspaceFolder}/.bin/godot/godot4_bin", "args": [ "--path", - "${workspaceFolder}/godot" + "${workspaceFolder}/godot", + "--skip-lobby", + "--realm", + "http://localhost:8000", + "--preview" ], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [ { "name": "RUST_LOG", - "value": "debug" + "value": "dclgodot=debug" } ], "externalConsole": true, "preLaunchTask": "Build GDExtension Lib", "sourceFileMap": { - "/rustc/cc66ad468955717ab92600c770da8c1601a4ff33": "${env:HOME}${env:USERPROFILE}\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\src\\rust" + "/rustc/129f3b9964af4d4a709d1383930ade12dfe7c081": "${env:HOME}${env:USERPROFILE}\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\src\\rust" } }, { @@ -29,11 +33,7 @@ "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot", - "--test" - ], + "args": ["--path", "${workspaceFolder}/godot", "--test"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [ @@ -50,11 +50,7 @@ "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot", - "-e" - ], + "args": ["--path", "${workspaceFolder}/godot", "-e"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [], @@ -66,11 +62,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot", - "-e" - ], + "args": ["--path", "${workspaceFolder}/godot", "-e"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [], @@ -82,10 +74,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot" - ], + "args": ["--path", "${workspaceFolder}/godot"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [ @@ -111,11 +100,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot", - "--test" - ], + "args": ["--path", "${workspaceFolder}/godot", "--test"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [], @@ -136,11 +121,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot", - "-e" - ], + "args": ["--path", "${workspaceFolder}/godot", "-e"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [], @@ -153,10 +134,7 @@ "request": "launch", "targetArchitecture": "arm64", "program": "${workspaceFolder}/.bin/godot/godot4_bin", - "args": [ - "--path", - "${workspaceFolder}/godot" - ], + "args": ["--path", "${workspaceFolder}/godot"], "stopAtEntry": false, "cwd": "${workspaceRoot}/godot", "environment": [], @@ -172,4 +150,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/godot/.gitignore b/godot/.gitignore index 433cca793..9d50d53ff 100644 --- a/godot/.gitignore +++ b/godot/.gitignore @@ -2,6 +2,7 @@ /.godot/ /android/ +/addons/**/~*.dll # Godot-specific ignores .import/ diff --git a/godot/src/test/avatar/avatar_list.json b/godot/src/test/avatar/avatar_list.json index 71ea89378..55f561c6e 100644 --- a/godot/src/test/avatar/avatar_list.json +++ b/godot/src/test/avatar/avatar_list.json @@ -230,4 +230,4 @@ "urn:decentraland:matic:collections-v2:0xbada8a315e84e4d78e3b6914003647226d9b4001:11", "urn:decentraland:matic:collections-v2:0x0c956c74518ed34afb7b137d9ddfdaea7ca13751:0" ] -} +} \ No newline at end of file diff --git a/lib/src/godot_classes/animator_controller.rs b/lib/src/godot_classes/animator_controller.rs index 88d70cdae..fb0eda5b0 100644 --- a/lib/src/godot_classes/animator_controller.rs +++ b/lib/src/godot_classes/animator_controller.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use godot::{ bind::{godot_api, GodotClass}, @@ -35,6 +35,8 @@ pub struct MultipleAnimationController { current_time: HashMap, playing_anims: HashMap, + + finished_animations: HashSet, } #[godot_api] @@ -77,6 +79,7 @@ impl MultipleAnimationController { if !looping { self.base .set(anim_item.speed_param_ref_str.clone(), 0_f32.to_variant()); + self.finished_animations.insert(anim_name.clone()); } } else { tracing::error!("finished animation {} not found!", anim_name); @@ -92,6 +95,7 @@ impl MultipleAnimationController { current_time: HashMap::new(), playing_anims: HashMap::new(), existing_anims_duration, + finished_animations: HashSet::new(), }) } @@ -149,6 +153,22 @@ impl MultipleAnimationController { .unwrap_or(&0.0) }; + self.base.set( + anim_state.time_param_ref_str.clone(), + playing_time.to_variant(), + ); + } else if self.finished_animations.contains(&new_state.clip) { + self.finished_animations.remove(&new_state.clip); + + let playing_time = if !anim_state.value.playing_backward() { + 0.0 + } else { + *self + .existing_anims_duration + .get(&anim_state.value.clip) + .unwrap_or(&0.0) + }; + self.base.set( anim_state.time_param_ref_str.clone(), playing_time.to_variant(), @@ -237,7 +257,12 @@ impl MultipleAnimationController { ); let playing_time = if let Some(playing_time) = self.current_time.remove(&anim.clip) { - playing_time + if self.finished_animations.contains(&anim.clip) { + self.finished_animations.remove(&anim.clip); + 0.0 + } else { + playing_time + } } else if !anim_item.value.playing_backward() { 0.0 } else {