using System.Collections;
using System.Collections.Generic;
using BITKit;
using BITKit.Entities;
using UnityEngine;
#if GameDesigner && UNITY
namespace BITFALL
{
///
/// 玩家背包服务
///
public class PlayerInventoryService : MonoBehaviour
{
public bool ServerAddItem(IEntity entity,IBasicItem item)
{
var unityEntity = entity as Entity;
//如果获取到entity包括了物品容器(背包组件)
//在服务器上处理添加物品的行为
if (!unityEntity!.TryGetComponent(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(out var inventory))
{
inventory.Add(item);
return true;
}
return false;
}
}
}
#endif