From d143cf8dbf34031adc08c28d52a36cb29d608af4 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 28 Jul 2024 11:12:53 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20bullet=20through=20wall=20issue.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=90=E5=BC=B9=E7=A9=BF=E5=A2=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/character/AiCharacter.cs | 3 +- scripts/character/CharacterTemplate.cs | 1 - scripts/loader/uiLoader/SplashScreenLoader.cs | 2 +- scripts/projectile/ProjectileTemplate.cs | 2 +- scripts/utils/TileMapUtils.cs | 36 ------------------- scripts/weapon/WeaponTemplate.cs | 2 +- 6 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 scripts/utils/TileMapUtils.cs diff --git a/scripts/character/AiCharacter.cs b/scripts/character/AiCharacter.cs index 2cd2b6b..c035fe4 100644 --- a/scripts/character/AiCharacter.cs +++ b/scripts/character/AiCharacter.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using ColdMint.scripts.bubble; using ColdMint.scripts.camp; +using ColdMint.scripts.debug; using ColdMint.scripts.inventory; using ColdMint.scripts.stateMachine; using ColdMint.scripts.utils; @@ -210,7 +211,7 @@ public sealed partial class AiCharacter : CharacterTemplate /// private void AddInitialWeapon(string? initWeaponRes) { - if (initWeaponRes == null) + if (string.IsNullOrEmpty(initWeaponRes)) { return; } diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index b0f7f89..3c2e32b 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -403,7 +403,6 @@ public partial class CharacterTemplate : CharacterBody2D } NodeUtils.CallDeferredReparent(ItemMarker2D, pickAbleItemNode2D); - pickAbleItemNode2D.Position = Vector2.Zero; return true; } diff --git a/scripts/loader/uiLoader/SplashScreenLoader.cs b/scripts/loader/uiLoader/SplashScreenLoader.cs index 06b71cc..318c314 100644 --- a/scripts/loader/uiLoader/SplashScreenLoader.cs +++ b/scripts/loader/uiLoader/SplashScreenLoader.cs @@ -130,6 +130,6 @@ public partial class SplashScreenLoader : UiLoaderTemplate ModLoader.LoadAllMods(modPath); } - await Task.CompletedTask; + await Task.Yield(); } } \ No newline at end of file diff --git a/scripts/projectile/ProjectileTemplate.cs b/scripts/projectile/ProjectileTemplate.cs index 92b444e..e254b26 100644 --- a/scripts/projectile/ProjectileTemplate.cs +++ b/scripts/projectile/ProjectileTemplate.cs @@ -105,7 +105,7 @@ public partial class ProjectileTemplate : CharacterBody2D return false; } - if (target is TileMap) + if (target is TileMapLayer) { //When we hit the tile, we return true to prevent the bullet from penetrating the tile. //撞击到瓦片时,我们返回true,是为了防止子弹穿透瓦片。 diff --git a/scripts/utils/TileMapUtils.cs b/scripts/utils/TileMapUtils.cs deleted file mode 100644 index 09399a6..0000000 --- a/scripts/utils/TileMapUtils.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Godot; - -namespace ColdMint.scripts.utils; - -/// -/// TileMapUtils -/// TileMap工具 -/// -public static class TileMapUtils -{ - /// - /// Get the layer number corresponding to LayerName in TileMap - /// 在TileMap内获取LayerName所对应的图层序号 - /// - /// - /// - /// - ///− 1 is returned after obtaining failure - ///获取失败返回-1 - /// - public static int GetTileMapLayer(TileMap tileMap, string layerName) - { - var count = tileMap.GetLayersCount(); - for (var i = 0; i < count; i++) - { - var currentLayerName = tileMap.GetLayerName(i); - if (currentLayerName == layerName) - { - return i; - } - } - - return -1; - } - -} \ No newline at end of file diff --git a/scripts/weapon/WeaponTemplate.cs b/scripts/weapon/WeaponTemplate.cs index 4ae56ed..b6380f9 100644 --- a/scripts/weapon/WeaponTemplate.cs +++ b/scripts/weapon/WeaponTemplate.cs @@ -82,7 +82,7 @@ public abstract partial class WeaponTemplate : PickAbleTemplate var forceX = Math.Abs(_recoil.X); if (Math.Abs(RotationDegrees) < 90) { - //The weapon goes to the right and we apply a recoil to the left + //The weapon goes to the right, and we apply a recoil to the left //武器朝向右边我们向左施加后坐力 forceX = -forceX; }