RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

New construct methods for Loot

Kamron

Knight
New construct methods for Loot

I have added to the construct methods in Loot.cs and I think they would be a great addition to the distro.


[code:1] public static Item Construct( Type type, object[] args ) //One item type with a parameter list
{
try { return Activator.CreateInstance( type, args ) as Item; }
catch { return null; }
}
public static Item Construct( Type[] types, object[] args ) //Set of item types, sharing the same parameter list
{
if ( types.Length > 0 )
{
int item = Utility.Random( types.Length - 1 );
try { return Activator.CreateInstance( types[item], args ) as Item; }
catch { return null; }
}

return null;
}
public static Item Construct( Type[] types, object[][] args ) //Set of item types, with their own parameter list
{
if ( types.Length > 0 )
{
int item = Utility.Random( types.Length - 1 );
try { return Activator.CreateInstance( types[item], new object[]{ args[item] } ) as Item; }
catch{ return null; }
}

return null;
}[/code:1]

For those who want to know how to install this. Open loot.cs and go to where it says [code:1]#region Construction methods [/code:1] and that code under that line.
 
Top