Skip to content

Commit

Permalink
build:update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jul 10, 2024
1 parent f834d4b commit a3f3161
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ mono_crash.*.json

target/

# Godot Cpp
gdcpp/extension_api.json

# Python
__pycache__/

# Protobuf
gdrust/proto/src/proto/*.rs

# For Debug
debug/
52 changes: 26 additions & 26 deletions gdrust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gdrust/src/bullets/star_wrath_bullet.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use derive::gen_debug;
use godot::classes::{Area2D, IArea2D};
use godot::global::print;
use godot::obj::WithBaseField;
use godot::prelude::*;
use rand::{thread_rng, Rng};
Expand Down
1 change: 1 addition & 0 deletions gdrust/src/cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub const SWORD_DEBUG: &str = "debug/sword";
2 changes: 0 additions & 2 deletions gdrust/src/fight.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::OnceLock;

use crate::debug_check;
use crate::fight_items::sword::{SwordManager, START};
use godot::classes::{Control, IControl, Timer};
Expand Down
36 changes: 33 additions & 3 deletions gdrust/src/fight_items/sword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ use godot::{
obj::{Base, Gd, WithBaseField},
register::{godot_api, GodotClass},
};
use std::sync::OnceLock;
use std::{
collections::{HashMap, HashSet},
fs,
sync::OnceLock,
};

use crate::debug_check;
use crate::{cfg::SWORD_DEBUG, debug_check};

#[derive(GodotClass)]
#[class(base = Node)]
Expand All @@ -18,9 +22,35 @@ pub struct SwordManager {
pub const START: &str = "start";
pub const ATTACK_FINISHED: &str = "attack_finished";

fn get_sword_map() -> &'static HashSet<&'static str> {
static TMP: OnceLock<HashSet<&'static str>> = OnceLock::new();
TMP.get_or_init(|| {
collection_literals::collection! {
"EnchantedSword", "StarWrath"
}
})
}

fn get_fight_list() -> &'static Vec<&'static str> {
static TMP: OnceLock<Vec<&'static str>> = OnceLock::new();
TMP.get_or_init(|| vec!["EnchantedSword", "StarWrath"])
TMP.get_or_init(|| {
#[cfg(debug_assertions)]
{
// 检查是否存在提前运行的文件
match fs::read_to_string(SWORD_DEBUG) {
Err(_) => {}
Ok(sword) => {
// 检查剑是否存在
if get_sword_map().contains(sword.as_str()) {
return vec![get_sword_map().get(sword.as_str()).unwrap()];
} else {
panic!("Found {},but sword {} not found", SWORD_DEBUG, sword)
}
}
}
}
get_sword_map().clone().into_iter().collect()
})
}

#[godot_api]
Expand Down
1 change: 1 addition & 0 deletions gdrust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod bullets;
mod cfg;
mod consts;
mod fight;
mod fight_items;
Expand Down
2 changes: 1 addition & 1 deletion gdrust/src/weapons/star_wrath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl StarWrath {
let mut star = bullet.instantiate_as::<StarWrathBullet>();
let sz = self.base_mut().get_viewport_rect().size.x - 100.0;
let random_x = thread_rng().gen_range(100.0..sz);
godot_print!("{}", random_x);
// godot_print!("{}", random_x);
self.base_mut().add_child(star.clone().upcast());
star.bind_mut().init_from_sky(random_x);
}
Expand Down
1 change: 0 additions & 1 deletion scenes/bullets/star_wrath/star_wrath_original.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ func _ready() -> void:

func _on_killer_screen_exited() -> void:
await get_tree().create_timer(0.5).timeout
print("Killing")
queue_free()
3 changes: 1 addition & 2 deletions scenes/bullets/star_wrath/track.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ func general_hide():


func _draw() -> void:
draw_set_transform_matrix(Transform2D(global_transform.inverse()))
draw_set_transform_matrix(global_transform.inverse())
var real_color = color
real_color.a = a / 255.0
print("draw", real_color)
var y_sz = get_viewport_rect().size.y
const WIDTH = 50
draw_rect(
Expand Down
3 changes: 3 additions & 0 deletions scenes/weapons/enchanted_sword/enchanted_sword.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ func _ready():
]
if get_tree().current_scene == self:
exit()
else:
hide()


# fight调用这个
# 开始
func start():
show()
exit()


Expand Down
7 changes: 6 additions & 1 deletion scenes/weapons/star_wrath/star_wrath.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends StarWrath

@export var star_wrath_origin: PackedScene
var operations = [func(): self.fall_star()]
var operations = [func(): self.fall_star_process()]
var operation_idx = 0


Expand All @@ -21,3 +21,8 @@ func next_operation():
return
operations[operation_idx].call()
operation_idx += 1

func fall_star_process():
for i in range(10):
self.fall_star()
await get_tree().create_timer(randf_range(1.0,2.0)).timeout
2 changes: 1 addition & 1 deletion scenes/weapons/star_wrath/star_wrath_root.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func _ready() -> void:
$StarWrath.start()
else:
$StarWrath.hide()

$Bg.hide()

func start():
$StarWrath.start()
Expand Down

0 comments on commit a3f3161

Please sign in to comment.