1
This commit is contained in:
@@ -6,22 +6,29 @@ using BITKit.Animations;
|
||||
using BITKit.Entities;
|
||||
namespace BITFALL.Entites
|
||||
{
|
||||
public class EntityProxyCharacter : EntityComponent, IHealthCallback
|
||||
public class EntityProxyCharacter : EntityComponent
|
||||
{
|
||||
public UnityAnimator animator;
|
||||
[SerializeReference, SubclassSelector] public References _getDamage;
|
||||
[SerializeField] private Optional<Collider> aliveCollider = new();
|
||||
[Inject]
|
||||
private IHealth _health;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
entity.RegisterCallback<IHealthCallback>(this);
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
}
|
||||
|
||||
public void OnSetAlive(bool alive)
|
||||
{
|
||||
|
||||
if (aliveCollider.Allow)
|
||||
aliveCollider.Value.enabled = alive;
|
||||
}
|
||||
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
if (_getDamage is null || animator is null) return;
|
||||
animator.animator.Play(_getDamage,-1,0);
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine.InputSystem;
|
||||
using static UnityEditor.Progress;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
@@ -16,8 +15,6 @@ namespace BITFALL
|
||||
/// </summary>
|
||||
public interface IPlayerEquipSelector
|
||||
{
|
||||
event Action<IBasicItem> OnEquip;
|
||||
event Action<IBasicItem> OnDeEquip;
|
||||
event Action<IDictionary<int, IBasicItem>> OnUpdateEquip;
|
||||
bool TryDeEquip(IBasicItem item);
|
||||
}
|
||||
|
@@ -1,16 +0,0 @@
|
||||
using BITKit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public interface IEquipmentAsArms : IProperty { }
|
||||
[System.Serializable]
|
||||
public record EquipmentAsWeapon: IEquipmentAsArms { }
|
||||
[System.Serializable]
|
||||
public record EquipmentAsMelee : IEquipmentAsArms { }
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
using BITKit;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITFALL
|
||||
{
|
||||
public interface IEquipmentSlot
|
||||
{
|
||||
|
||||
}
|
||||
public abstract record EquipmentSlot: IEquipmentSlot
|
||||
{
|
||||
public override int GetHashCode() => GetType().GetHashCode();
|
||||
}
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsHead: EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsBody : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsArmor : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsHeal : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsBackpack : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsArmorPlates : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsTactics : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsThrow : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsEquip : EquipmentSlot { }
|
||||
[System.Serializable]
|
||||
public sealed record EquipmentAsSlot : IProperty
|
||||
{
|
||||
[SerializeReference, SubclassSelector] public IEquipmentSlot slot;
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.Core.Inventory",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:7efac18f239530141802fb139776f333",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:9e24947de15b9834991c9d8411ea37cf",
|
||||
"GUID:84651a3751eca9349aac36a66bba901b",
|
||||
"GUID:84d565da37ad40546a118cfb3c3509f3",
|
||||
"GUID:30cdc242b1ac6a944a460f4ab0b77b88",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:ef0bb553b58b90b488bdbe8672e3be0b"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.Equipment",
|
||||
"name": "BITFALL.Entities.Inventory",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:ef0bb553b58b90b488bdbe8672e3be0b"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
@@ -1,154 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using AYellowpaper.SerializedCollections;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public interface IEntityInventoryCallback
|
||||
{
|
||||
void OnAdd(IBasicItem item);
|
||||
void OnRemove(IBasicItem item);
|
||||
}
|
||||
[CustomType(typeof(IBasicItemContainer))]
|
||||
public abstract class EntityInventory : EntityComponent, IBasicItemContainer
|
||||
{
|
||||
public SerializedDictionary<string, GameObject> itemAnchor = new();
|
||||
/// <summary>
|
||||
/// 数据字典
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, IBasicItem> dictionary = new();
|
||||
/// <summary>
|
||||
/// 隐式接口实现
|
||||
/// </summary>
|
||||
public int Id => (int)entity.Id;
|
||||
/// <summary>
|
||||
/// 工厂方法
|
||||
/// </summary>
|
||||
public event Func<IBasicItem, bool> AddFactory;
|
||||
public event Func<IBasicItem, bool> RemoveFactory;
|
||||
public event Func<IBasicItem, bool> DropFactory;
|
||||
// 回调
|
||||
public event Action<IBasicItem> OnAdd;
|
||||
public event Action<IBasicItem> OnRemove;
|
||||
public event Action<IBasicItem> OnSet;
|
||||
public event Action<IBasicItem> OnDrop;
|
||||
public event Action<IBasicItemContainer> OnRebuild;
|
||||
private IHealth _health;
|
||||
public override void OnAwake()
|
||||
{
|
||||
_health = entity.Get<IHealth>();
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
}
|
||||
private void OnSetAlive(bool alive)
|
||||
{
|
||||
if (alive) return;
|
||||
foreach (var x in dictionary.Values.ToArray())
|
||||
{
|
||||
OnRemove?.Invoke(x);
|
||||
Drop(x);
|
||||
}
|
||||
dictionary.Clear();
|
||||
}
|
||||
public virtual bool Add(IBasicItem item)
|
||||
{
|
||||
if (_health.IsAlive is false)
|
||||
{
|
||||
Drop(item);
|
||||
return true;
|
||||
}
|
||||
if (AddFactory?.GetInvocationList().Cast<Func<IBasicItem, bool>>().Any(x => x.Invoke(item)) is false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!dictionary.TryAdd(item.Id, item)) return false;
|
||||
{
|
||||
OnAdd?.Invoke(item);
|
||||
foreach (var x in entity.GetCallbacks<IEntityInventoryCallback>())
|
||||
{
|
||||
x.OnAdd(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IBasicItem[] GetItems() => dictionary.Values.ToArray();
|
||||
public virtual bool Remove(IBasicItem item)
|
||||
{
|
||||
return Remove(item.Id);
|
||||
}
|
||||
|
||||
public virtual bool Remove(int id)
|
||||
{
|
||||
if (!dictionary.TryGetValue(id, out var item)) return false;
|
||||
if (RemoveFactory is not null)
|
||||
if (RemoveFactory.GetInvocationList().Cast<Func<IBasicItem,bool>>().Any(x => x.Invoke(item) is false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dictionary.Remove(id);
|
||||
foreach (var x in entity.GetCallbacks<IEntityInventoryCallback>())
|
||||
{
|
||||
x.OnRemove(item);
|
||||
}
|
||||
OnRemove?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool Remove(Func<IBasicItem, bool> removeFactory)
|
||||
{
|
||||
bool isRemoved = false;
|
||||
foreach (var x in dictionary.Values.ToArray())
|
||||
{
|
||||
if (removeFactory.Invoke(x))
|
||||
{
|
||||
Remove(x.Id);
|
||||
isRemoved = true;
|
||||
}
|
||||
}
|
||||
return isRemoved;
|
||||
}
|
||||
public bool TryGetItem(Func<IBasicItem, bool> func, out IBasicItem item)
|
||||
{
|
||||
return dictionary.Values.TryGetAny(func, out item);
|
||||
}
|
||||
|
||||
public bool Drop(int _Id)
|
||||
{
|
||||
if (!dictionary.TryGetValue(_Id, out var item)) return false;
|
||||
if (!Remove(item)) return false;
|
||||
if (DropFactory != null && DropFactory.GetInvocationList().Cast<Func<IBasicItem, bool>>()
|
||||
.Any(x => x.Invoke(item) is false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Drop(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Drop(IBasicItem item)
|
||||
{
|
||||
OnDrop?.Invoke(item);
|
||||
var prefab = Addressables.LoadAssetAsync<AssetableItem>(item.AddressablePath).WaitForCompletion();
|
||||
var _transform = transform;
|
||||
var position = _transform.position;
|
||||
var rotation = _transform.rotation;
|
||||
if (itemAnchor.TryGetValue(prefab.Name, out var anchor))
|
||||
{
|
||||
position = anchor.transform.position;
|
||||
rotation = anchor.transform.rotation;
|
||||
}
|
||||
var instance = Instantiate(prefab.GetPrefab(), position, rotation);
|
||||
instance.CopyItemsFrom(item);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Inventory
|
||||
{
|
||||
public interface IEntityInventory : IBasicItemContainer
|
||||
{
|
||||
bool UseItem(IBasicItem item);
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public interface IPlayerInventoryWeightable
|
||||
{
|
||||
event Action<double,double> OnWeighted;
|
||||
}
|
||||
[CustomType(typeof(IPlayerInventoryWeightable))]
|
||||
public class InventoryWeightable : EntityComponent,IPlayerInventoryWeightable
|
||||
{
|
||||
[Header(Constant.Header.Data)]
|
||||
public double currentWeight;
|
||||
[Header(Constant.Header.Settings)]
|
||||
public double maxWeight =8;
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
private IBasicItemContainer container;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
container = entity.Get<IBasicItemContainer>();
|
||||
container.AddFactory += AddFactory;
|
||||
container.OnAdd += OnAdd;
|
||||
container.OnRemove += OnRemove;
|
||||
|
||||
var playerEquipContainer = entity.Get<IPlayerEquipContainer>();
|
||||
playerEquipContainer.OnEquip += OnEquip;
|
||||
playerEquipContainer.OnDeEquip += DeEquip;
|
||||
}
|
||||
|
||||
private bool AddFactory(IBasicItem item)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if (!asset.TryGetProperty<ItemWeight>(out var itemWeight)) return true;
|
||||
return currentWeight + itemWeight <= maxWeight;
|
||||
}
|
||||
|
||||
private void OnAdd(IBasicItem item)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if (!asset.TryGetProperty<ItemWeight>(out var itemWeight)) return;
|
||||
currentWeight += itemWeight;
|
||||
InvokeCallback();
|
||||
}
|
||||
private void OnRemove(IBasicItem item)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if (!asset.TryGetProperty<ItemWeight>(out var itemWeight)) return;
|
||||
currentWeight -= itemWeight;
|
||||
InvokeCallback();
|
||||
|
||||
}
|
||||
|
||||
private void DeEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
if (!item.GetAssetable().TryGetProperty<AddInventoryMaxWeight>(out var addWeight)) return;
|
||||
maxWeight -= addWeight.AddWeight;
|
||||
InvokeCallback();
|
||||
}
|
||||
|
||||
private void OnEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
if (!item.GetAssetable().TryGetProperty<AddInventoryMaxWeight>(out var addWeight)) return;
|
||||
maxWeight += addWeight.AddWeight;
|
||||
InvokeCallback();
|
||||
}
|
||||
private void InvokeCallback()
|
||||
{
|
||||
OnWeighted?.Invoke(currentWeight, maxWeight);
|
||||
}
|
||||
public event Action<double,double> OnWeighted;
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITFALL.Player.Inventory;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using static UnityEditor.Progress;
|
||||
using Google.Apis.Sheets.v4.Data;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public interface IPlayerEquipContainer {
|
||||
Action<IEquipmentSlot, IBasicItem> OnEquip { get; set; }
|
||||
Action<IEquipmentSlot, IBasicItem> OnDeEquip { get; set; }
|
||||
bool TryDeEquip<T>(T slot=default) where T : IEquipmentSlot;
|
||||
}
|
||||
/// <summary>
|
||||
/// 玩家装备容器
|
||||
/// 支持,护甲,头盔和背包等
|
||||
/// </summary>
|
||||
[CustomType(typeof(IPlayerEquipContainer))]
|
||||
public class PlayerEquipContainer : EntityComponent, IPlayerEquipContainer
|
||||
{
|
||||
private readonly Dictionary<IEquipmentSlot, IBasicItem> dictionary = new();
|
||||
private IBasicItemContainer inventory;
|
||||
public override void OnAwake()
|
||||
{
|
||||
var health = entity.Get<IHealth>();
|
||||
health.OnSetAlive += OnSetAlive;
|
||||
}
|
||||
|
||||
private void OnSetAlive(bool obj)
|
||||
{
|
||||
if (obj) return;
|
||||
foreach (var x in dictionary.ToArray())
|
||||
{
|
||||
OnDeEquip?.Invoke(x.Key, x.Value);
|
||||
inventory.Add(x.Value);
|
||||
}
|
||||
dictionary.Clear();
|
||||
}
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
inventory = entity.Get<IBasicItemContainer>();
|
||||
var playerInventory = entity.Get<IPlayerInventory>();
|
||||
playerInventory.OnUseItem += TryExecute;
|
||||
}
|
||||
|
||||
public Action<IEquipmentSlot, IBasicItem> OnEquip { get; set; }
|
||||
public Action<IEquipmentSlot, IBasicItem> OnDeEquip { get; set; }
|
||||
|
||||
public bool TryDeEquip<T>(T slot) where T : IEquipmentSlot
|
||||
{
|
||||
if (!dictionary.TryGetValue(slot, out var equipable)) return false;
|
||||
if (inventory.Add(equipable))
|
||||
{
|
||||
DeEquip(slot, equipable);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool Equip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
dictionary.Add(slot, item);
|
||||
OnEquip?.Invoke(slot, item);
|
||||
return true;
|
||||
}
|
||||
private bool DeEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
dictionary.Remove(slot);
|
||||
OnDeEquip?.Invoke(slot, item);
|
||||
return true;
|
||||
}
|
||||
public int Priority => 0;
|
||||
|
||||
public bool TryExecute(IBasicItem value)
|
||||
{
|
||||
var asset = value.GetAssetable();
|
||||
//尝试获取可装备信息
|
||||
if (!asset.TryGetProperty<EquipmentAsSlot>(out var equipable)) return false;
|
||||
//已装备物品
|
||||
if (dictionary.TryGetValue(equipable.slot, out var equipedItem))
|
||||
{
|
||||
//尝试将装配放回背包
|
||||
if (inventory.Add(equipedItem))
|
||||
{
|
||||
//移除已装备物品
|
||||
DeEquip(equipable.slot, value);
|
||||
}
|
||||
}
|
||||
//从库存中移除物品
|
||||
if (inventory.Remove(value))
|
||||
{
|
||||
//装配物品
|
||||
Equip(equipable.slot, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BITKit;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.UIElements;
|
||||
using System.Text;
|
||||
using BITKit.Entities;
|
||||
using System.Linq;
|
||||
using BITFALL.Player.Inventory;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
[CustomType(typeof(IPlayerInventory))]
|
||||
public class PlayerInventory : EntityInventory,ISelectableCallback,IPlayerInventory
|
||||
{
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
entity.RegisterCallback<ISelectableCallback>(this);
|
||||
}
|
||||
/// <summary>咋整啊这个</summary>
|
||||
void ISelectableCallback.OnActive(ISelectable selectable)
|
||||
{
|
||||
var trans = selectable.GetTransform();
|
||||
|
||||
if (trans.TryGetComponentAny<WorldableItem>(out var item))
|
||||
{
|
||||
if (Add(item.Pick()))
|
||||
{
|
||||
item.Picked();
|
||||
}
|
||||
}
|
||||
else if(trans.TryGetComponentAny<IBasicItemContainer>(out _))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ISelectableCallback.OnHover(ISelectable selectable)
|
||||
{
|
||||
}
|
||||
|
||||
void ISelectableCallback.OnInactive(ISelectable selectable)
|
||||
{
|
||||
}
|
||||
public bool TryUseItem(IBasicItem item)
|
||||
{
|
||||
if (OnUseItem is null) return false;
|
||||
if (!OnUseItem.CastAsFunc().Any(func => func.Invoke(item))) return false;
|
||||
Remove(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
public event Func<IBasicItem, bool> OnUseItem;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(PlayerInventory))]
|
||||
public class EntityPlayerInventoryInsepctor : BITInspector<PlayerInventory>
|
||||
{
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
FillDefaultInspector();
|
||||
CreateSubTitle(Constant.Header.Debug);
|
||||
var serializeLabel = root.Create<Label>();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (var x in agent.GetItems())
|
||||
{
|
||||
stringBuilder.AppendLine($"{x.Id}@{x.Name}");
|
||||
}
|
||||
serializeLabel.text=stringBuilder.ToString();
|
||||
return root;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
#if GameDesigner && UNITY
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家背包服务
|
||||
/// </summary>
|
||||
public class PlayerInventoryService : MonoBehaviour
|
||||
{
|
||||
public bool ServerAddItem(IEntity entity,IBasicItem item)
|
||||
{
|
||||
var unityEntity = entity as Entity;
|
||||
//如果获取到entity包括了物品容器(背包组件)
|
||||
//在服务器上处理添加物品的行为
|
||||
if (!unityEntity!.TryGetComponent<IBasicItemContainer>(out var inventory)) return false;
|
||||
if (!inventory.Add(item)) return false;
|
||||
RpcAddItem(entity, item);
|
||||
return true;
|
||||
}
|
||||
public bool RpcAddItem(IEntity entity, IBasicItem item)
|
||||
{
|
||||
var unityEntity = entity as Entity;
|
||||
//在客户端上处理添加物品的行为
|
||||
if (unityEntity!.TryGetComponent<IBasicItemContainer>(out var inventory))
|
||||
{
|
||||
inventory.Add(item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user