Fixed an issue where players could not pick up items.

修复玩家不能拾起物品的问题。
This commit is contained in:
Cold-Mint 2024-06-02 22:25:07 +08:00
parent b474ac0ed3
commit 64688252f0
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
2 changed files with 18 additions and 1 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using ColdMint.scripts.camp; using ColdMint.scripts.camp;
using ColdMint.scripts.damage; using ColdMint.scripts.damage;
using ColdMint.scripts.debug;
using ColdMint.scripts.health; using ColdMint.scripts.health;
using ColdMint.scripts.inventory; using ColdMint.scripts.inventory;
using ColdMint.scripts.utils; using ColdMint.scripts.utils;
@ -433,6 +434,21 @@ public partial class CharacterTemplate : CharacterBody2D
/// <param name="damageTemplate"></param> /// <param name="damageTemplate"></param>
protected virtual void OnDie(DamageTemplate damageTemplate) protected virtual void OnDie(DamageTemplate damageTemplate)
{ {
//If the attacker is not empty and the role name is not empty, then the role death message is printed
//如果攻击者不为空,且角色名不为空,那么打印角色死亡信息
if (damageTemplate.Attacker != null && !string.IsNullOrEmpty(CharacterName))
{
if (damageTemplate.Attacker is CharacterTemplate characterTemplate &&
!string.IsNullOrEmpty(characterTemplate.CharacterName))
{
LogCat.LogWithFormat("death_info", CharacterName, characterTemplate.CharacterName);
}
else
{
LogCat.LogWithFormat("death_info", CharacterName, damageTemplate.Attacker.Name);
}
}
QueueFree(); QueueFree();
} }

View File

@ -1,6 +1,5 @@
using ColdMint.scripts.character; using ColdMint.scripts.character;
using ColdMint.scripts.debug; using ColdMint.scripts.debug;
using ColdMint.scripts.loader.sceneLoader;
using ColdMint.scripts.map.events; using ColdMint.scripts.map.events;
using Godot; using Godot;
@ -33,6 +32,7 @@ public partial class PlayerSpawn : Marker2D
GameSceneNodeHolder.Player.Position = GlobalPosition; GameSceneNodeHolder.Player.Position = GlobalPosition;
return; return;
} }
if (GameSceneNodeHolder.PlayerContainer == null) if (GameSceneNodeHolder.PlayerContainer == null)
{ {
return; return;
@ -50,6 +50,7 @@ public partial class PlayerSpawn : Marker2D
return; return;
} }
player.ItemContainer = GameSceneNodeHolder.HotBar;
GameSceneNodeHolder.PlayerContainer.AddChild(player); GameSceneNodeHolder.PlayerContainer.AddChild(player);
GameSceneNodeHolder.Player = player; GameSceneNodeHolder.Player = player;
player.Position = GlobalPosition; player.Position = GlobalPosition;