This commit is contained in:
asayre 2006-08-30 03:24:57 +00:00
parent 4386cbac99
commit 71e80d5949
16 changed files with 63 additions and 103 deletions

View file

@ -22,31 +22,32 @@ namespace Server.Items
private class FlipTarget : Target
{
public FlipTarget() : base( -1, false, TargetFlags.None )
public FlipTarget()
: base( -1, false, TargetFlags.None )
{
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is Item )
if( targeted is Item )
{
Item item = (Item)targeted;
if ( item.Movable == false && from.AccessLevel == AccessLevel.Player )
if( item.Movable == false && from.AccessLevel == AccessLevel.Player )
return;
Type type = targeted.GetType();
Type type = targeted.GetType();
FlipableAttribute[] AttributeArray = (FlipableAttribute[])type.GetCustomAttributes( typeof( FlipableAttribute ), false );
FlipableAttribute [] AttributeArray = (FlipableAttribute []) type.GetCustomAttributes(typeof(FlipableAttribute), false);
if( AttributeArray.Length == 0 )
{
return ;
return;
}
FlipableAttribute fa = AttributeArray[0];
fa.Flip( (Item)targeted);
fa.Flip( (Item)targeted );
}
}
}
@ -67,13 +68,14 @@ namespace Server.Items
public int[] ItemIDs
{
get{ return m_ItemIDs; }
get { return m_ItemIDs; }
}
public FlipableAttribute() : this ( null )
public FlipableAttribute()
: this( null )
{
}
public FlipableAttribute( params int[] itemIDs )
{
m_ItemIDs = itemIDs;
@ -81,12 +83,12 @@ namespace Server.Items
public virtual void Flip( Item item )
{
if ( m_ItemIDs == null )
if( m_ItemIDs == null )
{
try
{
MethodInfo flipMethod = item.GetType().GetMethod( "Flip", Type.EmptyTypes );
if ( flipMethod != null )
if( flipMethod != null )
flipMethod.Invoke( item, new object[0] );
}
catch
@ -97,18 +99,18 @@ namespace Server.Items
else
{
int index = 0;
for ( int i = 0; i < m_ItemIDs.Length; i++ )
for( int i = 0; i < m_ItemIDs.Length; i++ )
{
if ( item.ItemID == m_ItemIDs[i] )
if( item.ItemID == m_ItemIDs[i] )
{
index = i + 1;
break;
}
}
if ( index > m_ItemIDs.Length - 1)
if( index > m_ItemIDs.Length - 1 )
index = 0;
item.ItemID = m_ItemIDs[index];
}
}