mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 15:15:51 +03:00
Added InventoryDef.GetRecipesContainingThis()
This commit is contained in:
parent
fed6ccdefa
commit
17d7263973
@ -201,5 +201,24 @@ public int LocalBasePrice
|
||||
}
|
||||
|
||||
public string LocalBasePriceFormatted => Utility.FormatPrice( SteamInventory.Currency, LocalPrice / 100.0 );
|
||||
|
||||
InventoryRecipe[] _recContaining;
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of recepies that contain this item
|
||||
/// </summary>
|
||||
public InventoryRecipe[] GetRecipesContainingThis()
|
||||
{
|
||||
if ( _recContaining != null ) return _recContaining;
|
||||
|
||||
var allRec = SteamInventory.Definitions
|
||||
.Select( x => x.GetRecipes() )
|
||||
.Where( x => x != null )
|
||||
.SelectMany( x => x );
|
||||
|
||||
_recContaining = allRec.Where( x => x.ContainsIngredient( this ) ).ToArray();
|
||||
return _recContaining;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -82,5 +82,10 @@ internal static InventoryRecipe FromString( string part, InventoryDef Result )
|
||||
r.Ingredients = parts.Select( x => Ingredient.FromString( x ) ).Where( x => x.DefinitionId != 0 ).ToArray();
|
||||
return r;
|
||||
}
|
||||
|
||||
internal bool ContainsIngredient( InventoryDef inventoryDef )
|
||||
{
|
||||
return Ingredients.Any( x => x.DefinitionId == inventoryDef.Id );
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user