我正在尝试编写一个函数,使用户应该能够将obj存储到特定位置。当找到它时检查它是否可用,然后插入obj。
public bool AddStorageManual(I3D s, int spot)
{
// find warehouselocation by position in list
foreach (WareHouseLocation wareHouseLocation in locations)
{
for (int i = 0; i < locations.Count; i++)
{
spot = i;
if(locations[i] == null)
{
bool available = wareHouseLocation.hasAvailableVolumeForObject(s);
if (available)
{
wareHouseLocation.storage.Add(s);
}
}
}
}
}
但是我的代码需要一些帮助。
public bool AddStorageManual(I3DStorageObject s, int spot)
{
// find warehouselocation by position in list
WareHouseLocation wareHouseLocation = locations[spot];
bool available = wareHouseLocation.hasAvailableVolumeForObject(s);
if (available)
{
wareHouseLocation.storage.Add(s);
return true;
}
return false;
}