branch sync, Constructable can now have an accesslevel defined.
This commit is contained in:
parent
fede41b710
commit
5d78b17be1
7 changed files with 52 additions and 11 deletions
|
|
@ -157,7 +157,7 @@ namespace Server.Commands
|
|||
{
|
||||
ConstructorInfo ctor = ctors[i];
|
||||
|
||||
if ( !IsConstructable( ctor ) )
|
||||
if ( !IsConstructable( ctor, from.AccessLevel ) )
|
||||
continue;
|
||||
|
||||
ParameterInfo[] paramList = ctor.GetParameters();
|
||||
|
|
@ -345,7 +345,7 @@ namespace Server.Commands
|
|||
{
|
||||
ConstructorInfo ctor = ctors[i];
|
||||
|
||||
if ( !IsConstructable( ctor ) )
|
||||
if ( !IsConstructable( ctor, from.AccessLevel ) )
|
||||
continue;
|
||||
|
||||
if ( !foundCtor )
|
||||
|
|
@ -524,9 +524,14 @@ namespace Server.Commands
|
|||
|
||||
private static Type m_ConstructableType = typeof( ConstructableAttribute );
|
||||
|
||||
public static bool IsConstructable( ConstructorInfo ctor )
|
||||
public static bool IsConstructable( ConstructorInfo ctor, AccessLevel accessLevel )
|
||||
{
|
||||
return ctor.IsDefined( m_ConstructableType, false );
|
||||
object[] attrs = ctor.GetCustomAttributes( m_ConstructableType, false );
|
||||
|
||||
if ( attrs.Length == 0 )
|
||||
return false;
|
||||
|
||||
return accessLevel >= ((ConstructableAttribute)attrs[0]).AccessLevel;
|
||||
}
|
||||
|
||||
private static Type m_EnumType = typeof( Enum );
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.ContextMenus
|
||||
|
|
@ -29,7 +30,7 @@ namespace Server.ContextMenus
|
|||
{
|
||||
if ( targeted is Spellbook )
|
||||
{
|
||||
if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 )
|
||||
if ( from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 && m_Scroll.CheckItemUse( from ) )
|
||||
{
|
||||
Spellbook book = (Spellbook)targeted;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Server.ContextMenus
|
|||
|
||||
public override void OnClick()
|
||||
{
|
||||
if ( m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() )
|
||||
if ( m_Food.Deleted || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse( m_From ) )
|
||||
return;
|
||||
|
||||
m_Food.Eat( m_From );
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ namespace Server.Items
|
|||
if ( from.Alive && this.Movable )
|
||||
list.Add( new ContextMenus.AddToSpellbookEntry() );
|
||||
}
|
||||
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Server
|
||||
|
|
@ -158,8 +156,21 @@ namespace Server
|
|||
[AttributeUsage( AttributeTargets.Constructor )]
|
||||
public class ConstructableAttribute : Attribute
|
||||
{
|
||||
public ConstructableAttribute()
|
||||
private AccessLevel m_AccessLevel;
|
||||
|
||||
public AccessLevel AccessLevel
|
||||
{
|
||||
get { return m_AccessLevel; }
|
||||
set { m_AccessLevel = value; }
|
||||
}
|
||||
|
||||
public ConstructableAttribute() : this( AccessLevel.Player ) //Lowest accesslevel for current functionality (Level determined by access to [add)
|
||||
{
|
||||
}
|
||||
|
||||
public ConstructableAttribute( AccessLevel accessLevel )
|
||||
{
|
||||
m_AccessLevel = accessLevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3346,8 +3346,8 @@ namespace Server
|
|||
}
|
||||
|
||||
public virtual void OnAfterDuped( Item newItem )
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool OnDragLift( Mobile from )
|
||||
{
|
||||
|
|
@ -4289,6 +4289,11 @@ namespace Server
|
|||
((Mobile)m_Parent).OnItemUsed( from, item );
|
||||
}
|
||||
|
||||
public bool CheckItemUse( Mobile from )
|
||||
{
|
||||
return CheckItemUse( from, this );
|
||||
}
|
||||
|
||||
public virtual bool CheckItemUse( Mobile from, Item item )
|
||||
{
|
||||
if ( m_Parent is Item )
|
||||
|
|
@ -4307,6 +4312,13 @@ namespace Server
|
|||
((Mobile)m_Parent).OnItemLifted( from, item );
|
||||
}
|
||||
|
||||
public bool CheckLift( Mobile from )
|
||||
{
|
||||
LRReason reject = LRReason.Inspecific;
|
||||
|
||||
return CheckLift( from, this, ref reject );
|
||||
}
|
||||
|
||||
public virtual bool CheckLift( Mobile from, Item item, ref LRReason reject )
|
||||
{
|
||||
if ( m_Parent is Item )
|
||||
|
|
|
|||
|
|
@ -174,6 +174,17 @@ namespace Server.Items
|
|||
return base.CheckLift( from, item, ref reject );
|
||||
}
|
||||
|
||||
public override bool CheckItemUse( Mobile from, Item item )
|
||||
{
|
||||
if ( item != this && from.AccessLevel < AccessLevel.GameMaster && IsDecoContainer )
|
||||
{
|
||||
from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckItemUse( from, item );
|
||||
}
|
||||
|
||||
public bool CheckHold( Mobile m, Item item, bool message )
|
||||
{
|
||||
return CheckHold( m, item, message, true, 0, 0 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue