This commit is contained in:
CortexCore
2023-12-03 17:35:43 +08:00
parent ba342d6627
commit ba9f4eda80
702 changed files with 162078 additions and 21050 deletions

View File

@@ -76,6 +76,14 @@ namespace BITFALL
dictionary.TryRemove(item.Id);
}
public bool TrySetItem(IBasicItem item)
{
if (dictionary.TryGetValue(item.Id, out var currentItem) is false) return false;
dictionary[item.Id] = item;
OnSet?.Invoke(item);
return true;
}
[Inject]
protected IHealth _health;
[Inject]
@@ -147,7 +155,7 @@ namespace BITFALL
}
public bool TryGetItem(Func<IBasicItem, bool> func, out IBasicItem item)
{
return dictionary.Values.TryGetAny(func, out item);
return dictionary.Values.OrderBy(x=>x.TryGetProperty<ICount>(out var count)?count.Count:0).Reverse().TryGetAny(func, out item);
}
public bool Drop(int _Id)
@@ -167,9 +175,8 @@ namespace BITFALL
{
OnDrop?.Invoke(item);
var prefab = item.GetAssetable();
var _transform = transform;
var position = _transform.position;
var rotation = _transform.rotation;
var position = Transform.position + Vector3.up;
var rotation = Transform.rotation;
if (_modelSlots.Slots.TryGetValue(prefab.AddressablePath, out var anchor))
{
position = anchor.position;