From a8be1eadd82de0ed8774a8e69ddb53eff92bf7a4 Mon Sep 17 00:00:00 2001 From: ssssssssboom <2810462715@qq.com> Date: Thu, 23 May 2024 21:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E6=9C=AA=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=9B=B6=E4=BB=B6=E7=9A=84=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/dr_game/sr1_ship.py | 46 +++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index 41ed421..4356889 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -188,12 +188,15 @@ class SR1ShipRender(BaseScreen): traceback.print_exc() self.logger.error(traceback.format_exc(), tag="load_xml") return False - def draw_parts(self, - cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]], - count: int, - each_count: int, - draw_part_box: bool): - #渲染传入的parts + def draw_parts( + self, + cache: List[Tuple[SR1PartType_rs, SR1PartData_rs]], + count: int, + each_count: int, + draw_part_box: bool, + draw_alpha: int + ): + # 渲染传入的parts part_group = Group(2, parent=self.part_group) line_box_group = Group(6, parent=self.part_group) for p_id, parts in cache: @@ -201,9 +204,7 @@ class SR1ShipRender(BaseScreen): parts: List[Tuple[SR1PartType_rs, SR1PartData_rs]] batch = [] for p_type, p_data in parts: - sprite_name = self.part_list_rs.get_part_type( - p_data.part_type_id - ).sprite + sprite_name = self.part_list_rs.get_part_type(p_data.part_type_id).sprite part_sprite = Sprite( img=self.textures.get_texture(sprite_name), x=p_data.x * 60, @@ -212,6 +213,7 @@ class SR1ShipRender(BaseScreen): batch=self.main_batch, group=part_group, ) + part_sprite.opacity = draw_alpha part_sprite.rotation = p_data.angle_r part_sprite.scale_x = -1 if p_data.flip_x else 1 part_sprite.scale_y = -1 if p_data.flip_y else 1 @@ -301,37 +303,27 @@ class SR1ShipRender(BaseScreen): #渲染所有未连接零件 all_disconnected_groups = self.rust_ship.disconnected_parts() - logger.info(type(all_disconnected_groups)) - for cache, connections in all_disconnected_groups: - - logger.info(type(cache)) - - logger.info(type(connections)) - + for parts_groups, connections in all_disconnected_groups: draw_part_box = False - count=self.draw_parts(cache, - count, - each_count, - draw_part_box) + cache = [] + for p_type, p_data in parts_groups: + cache.append((p_data.id,parts_groups)) + count=self.draw_parts(cache, count, each_count, draw_part_box, 128) if count >= each_count: count = 0 yield + - - #渲染所有已连接零件 + # 渲染所有已连接零件 draw_part_box = False cache = self.rust_ship.as_dict() - count=self.draw_parts(cache.items(), - count, - each_count, - draw_part_box) + count=self.draw_parts(cache.items(), count, each_count, draw_part_box, 255) if count >= each_count: count = 0 yield - connect_line_group = Group(7, parent=self.part_group) for connect in self.rust_ship.connections().get_raw_data(): # 连接线