You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

namespace ET
{
public static class ResourceOperate
{
public static bool RootOutResource(Unit unit, long resourcePointId)
{
ResourcePointComponent resComp = unit.GetComponent<ResourcePointComponent>();
if (resComp == null)
{
return false;
}
if (!resComp.Children.ContainsKey(resourcePointId))
{
return false;
}
ResourcePoint res = resComp.GetChild<ResourcePoint>(resourcePointId);
// 能否铲除
if (res.Config.RootOut == (int)ResourcesPointRootOutEnum.NO)
{
return false;
}
// TODO: 处理人有正在采集这个资源的情况
// 铲除后是否给于幼苗
if (res.Config.SaplingItemId > 0)
{
unit.GetComponent<StoreComponent>().Add(res.Config.SaplingItemId, 1);
}
res.Dispose();
return true;
}
public static ResourcePoint CreateResource(Unit unit, int configId, float posX, float posY, long resourceId = 0)
{
ResourcePointComponent resComp = unit.GetComponent<ResourcePointComponent>();
if (resComp == null)
{
return null;
}
var res =resComp.CreateResourceByConfigId(unit,configId, posX, posY, resourceId);
return res;
}
}
}