public static void AddToList(List <ResourceAmount> list, ThingDef thingDef, int countToAdd) { for (int index = 0; index < list.Count; ++index) { if (list[index].thingDef == thingDef) { list[index] = new ResourceAmount(list[index].thingDef, list[index].count + countToAdd); return; } } list.Add(new ResourceAmount(thingDef, countToAdd)); }
public static void AddToList( List<ResourceAmount> list, ThingDef thingDef, int countToAdd ) { for( int index = 0; index < list.Count; ++index ) { if( list[ index ].thingDef == thingDef ) { list[ index ] = new ResourceAmount( list[ index ].thingDef, list[ index ].count + countToAdd ); return; } } list.Add( new ResourceAmount( thingDef, countToAdd ) ); }
public bool CountResourcesInHoppers(List <ResourceAmount> resources) { //Log.Message( string.Format( "{0}.CompHopperUser.CountResourcesInHoppers( List<ResourceAmount> )", this.parent.ThingID ) ); if (resources == null) { return(false); } resources.Clear(); foreach (var hopper in FindHoppers()) { foreach (var thing in hopper.GetAllResources(Resources)) { ResourceAmount.AddToList(resources, thing.def, thing.stackCount); } } return(!resources.NullOrEmpty()); }