Ejemplo n.º 1
0
 public ResourceStack AddResource(ResourceStack resource)
 {
     deltaVolume = maxVolume - currentVolume;
     if (currentVolume + resource.volume <= maxVolume)
     {
         if (items.ContainsKey(resource.type))
         {
             items[resource.type].volume += resource.volume;
         }
         items.Add(resource.type, resource);
         return(null);
     }
     else
     {
         if (items.ContainsKey(resource.type))
         {
             items[resource.type].volume += deltaVolume;
         }
         items.Add(resource.type, new ResourceStack(resource.type, deltaVolume));
         resource.volume -= deltaVolume;
         return(resource);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// How much this stack weighs
 /// </summary>
 public Gram Mass(ResourceStack stack)
 {
     return(stack.volume * Density);
 }