1
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.SqlServer.Server;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 支持二进制化的的物品容器,适用于网络化物品容器
|
||||
/// 支持属性
|
||||
@@ -74,7 +75,7 @@ namespace BITKit
|
||||
|
||||
public class RuntimeItemContainer : IRuntimeItemContainer
|
||||
{
|
||||
private readonly ConcurrentDictionary<int, IRuntimeItem> _items = new();
|
||||
public readonly ConcurrentDictionary<int, IRuntimeItem> Items = new();
|
||||
public void Read(BinaryReader r)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -86,7 +87,7 @@ namespace BITKit
|
||||
}
|
||||
|
||||
public int Id { get; set; }
|
||||
public IRuntimeItem[] GetItems()=>_items.Values.ToArray();
|
||||
public IRuntimeItem[] GetItems()=>Items.Values.ToArray();
|
||||
|
||||
public bool Add(IRuntimeItem item)
|
||||
{
|
||||
@@ -98,17 +99,17 @@ namespace BITKit
|
||||
}
|
||||
}
|
||||
|
||||
_items.Set(item.Id,item);
|
||||
|
||||
Items.Set(item.Id, item);
|
||||
|
||||
OnAdd?.Invoke(item);
|
||||
//BIT4Log.Log<RuntimeItemContainer>($"添加了了:{item.Id}");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Remove(int id)
|
||||
{
|
||||
if (_items.TryGetValue(id, out var item) is false) return false;
|
||||
if (Items.TryGetValue(id, out var item) is false) return false;
|
||||
|
||||
foreach (var func in RemoveFactory.CastAsFunc())
|
||||
{
|
||||
@@ -117,7 +118,7 @@ namespace BITKit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_items.TryRemove(item.Id);
|
||||
Items.TryRemove(item.Id);
|
||||
OnRemove?.Invoke(item);
|
||||
//BIT4Log.Log<RuntimeItemContainer>($"移除了:{id}");
|
||||
return true;
|
||||
@@ -125,8 +126,7 @@ namespace BITKit
|
||||
|
||||
public bool Drop(int id)
|
||||
{
|
||||
|
||||
if (_items.TryGetValue(id, out var item) is false) return false;
|
||||
if (Items.TryGetValue(id, out var item) is false) return false;
|
||||
foreach (var func in DropFactory.CastAsFunc())
|
||||
{
|
||||
if (func.Invoke(item) is false)
|
||||
@@ -134,7 +134,7 @@ namespace BITKit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_items.TryRemove(item.Id);
|
||||
Items.TryRemove(item.Id);
|
||||
OnDrop?.Invoke(item);
|
||||
//BIT4Log.Log<RuntimeItemContainer>($"丢下了:{id}");
|
||||
return true;
|
||||
|
13
Src/Core/Item/ItemEx.cs
Normal file
13
Src/Core/Item/ItemEx.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家向背包添加物品,但是被其他逻辑处理
|
||||
/// </summary>
|
||||
public sealed class PlayerInventoryAddItemOverridden : InGameException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Src/Core/Item/ItemEx.cs.meta
Normal file
11
Src/Core/Item/ItemEx.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebeadaca27f99904a87e52f3f63042f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user