Items held by the player upon death are also destroyed.
玩家死亡后持有的物品也会被销毁。
This commit is contained in:
parent
5ad4c1f09d
commit
1f66376857
|
@ -35,6 +35,7 @@ offset_top = 215.0
|
||||||
offset_right = 50.5
|
offset_right = 50.5
|
||||||
offset_bottom = 248.0
|
offset_bottom = 248.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
|
disabled = true
|
||||||
text = "ui_settings"
|
text = "ui_settings"
|
||||||
|
|
||||||
[node name="levelGraphEditorButton" type="Button" parent="."]
|
[node name="levelGraphEditorButton" type="Button" parent="."]
|
||||||
|
|
|
@ -120,8 +120,11 @@ public interface IItemContainer
|
||||||
/// <para>清理物品</para>
|
/// <para>清理物品</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"></param>
|
/// <param name="index"></param>
|
||||||
/// <returns></returns>
|
/// <returns>
|
||||||
bool ClearItem(int index);
|
///<para>Returns the item to be cleaned, or null if the item to be cleaned cannot be found</para>
|
||||||
|
///<para>返回要清理的物品,如果找不到要清理的物品则返回null</para>
|
||||||
|
/// </returns>
|
||||||
|
IItem? ClearItem(int index);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>ClearAllItems</para>
|
/// <para>ClearAllItems</para>
|
||||||
|
|
|
@ -304,15 +304,16 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool ClearItem(int index)
|
public IItem? ClearItem(int index)
|
||||||
{
|
{
|
||||||
if (!_itemDictionary.TryGetValue(index, out var item))
|
if (!_itemDictionary.TryGetValue(index, out var item))
|
||||||
{
|
{
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
var result = _itemDictionary.Remove(index);
|
if (!_itemDictionary.Remove(index))
|
||||||
if (result)
|
|
||||||
{
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
ItemDataChangeEvent?.Invoke(new ItemDataChangeEvent
|
ItemDataChangeEvent?.Invoke(new ItemDataChangeEvent
|
||||||
{
|
{
|
||||||
NewItem = null,
|
NewItem = null,
|
||||||
|
@ -332,15 +333,20 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer
|
||||||
OldItem = null
|
OldItem = null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
return item;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAllItems()
|
public void ClearAllItems()
|
||||||
{
|
{
|
||||||
foreach (var itemDictionaryKey in _itemDictionary.Keys)
|
foreach (var itemDictionaryKey in _itemDictionary.Keys)
|
||||||
{
|
{
|
||||||
ClearItem(itemDictionaryKey);
|
var item = ClearItem(itemDictionaryKey);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
item.SelfItemContainer?.ClearAllItems();
|
||||||
|
item.QueueFreeSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user