public void setResourcesToPart(Part part)
{
int len = part.Resources.Count;
if (len == resourceList.Count)//potentially the same resources exist as we are trying to setup
{
bool foundAll = true;
foreach (String name in resourceList.Keys)
{
ResourceListEntry entry = resourceList[name];
if (part.Resources.Contains(name))//go ahead and set them as found; if not all are found we'll delete them anyway...
{
PartResource pr = part.Resources[name];
pr.maxAmount = entry.max;
pr.amount = entry.fill;
}
else
{
foundAll = false;
break;
}
}
if (foundAll)
{
SSTUModInterop.updatePartResourceDisplay(part);
return;
}
}
part.Resources.dict.Clear();
ConfigNode resourceNode;
foreach (String name in resourceList.Keys)
{
ResourceListEntry entry = resourceList[name];
resourceNode = new ConfigNode("RESOURCE");
resourceNode.AddValue("name", name);
resourceNode.AddValue("maxAmount", entry.max);
resourceNode.AddValue("amount", entry.fill);
part.AddResource(resourceNode);
}
SSTUModInterop.updatePartResourceDisplay(part);
}