Sets a default parameter for OnHit. More casting cleanup.
This commit is contained in:
parent
74f498c1c8
commit
d6c0bf2d4c
96 changed files with 350 additions and 579 deletions
|
|
@ -102,15 +102,10 @@ namespace Server
|
|||
{
|
||||
object[] objs = mi.GetCustomAttributes( typeof( CallPriorityAttribute ), true );
|
||||
|
||||
if ( objs == null )
|
||||
return 0;
|
||||
|
||||
if ( objs.Length == 0 )
|
||||
return 0;
|
||||
|
||||
CallPriorityAttribute attr = objs[0] as CallPriorityAttribute;
|
||||
|
||||
if ( attr == null )
|
||||
if ( !(objs[0] is CallPriorityAttribute attr) )
|
||||
return 0;
|
||||
|
||||
return attr.Priority;
|
||||
|
|
|
|||
|
|
@ -171,12 +171,10 @@ namespace Server.Commands
|
|||
{
|
||||
if ( obj == this )
|
||||
return 0;
|
||||
else if ( obj == null )
|
||||
if ( obj == null )
|
||||
return 1;
|
||||
|
||||
CommandEntry e = obj as CommandEntry;
|
||||
|
||||
if ( e == null )
|
||||
if ( !(obj is CommandEntry e) )
|
||||
throw new ArgumentException();
|
||||
|
||||
return m_Command.CompareTo( e.m_Command );
|
||||
|
|
@ -204,7 +202,7 @@ namespace Server.Commands
|
|||
char[] array = value.ToCharArray();
|
||||
List<string> list = new List<string>();
|
||||
|
||||
int start = 0, end = 0;
|
||||
int start = 0;
|
||||
|
||||
while ( start < array.Length )
|
||||
{
|
||||
|
|
@ -213,7 +211,7 @@ namespace Server.Commands
|
|||
if ( c == '"' )
|
||||
{
|
||||
++start;
|
||||
end = start;
|
||||
int end = start;
|
||||
|
||||
while ( end < array.Length )
|
||||
{
|
||||
|
|
@ -229,7 +227,7 @@ namespace Server.Commands
|
|||
}
|
||||
else if ( c != ' ' )
|
||||
{
|
||||
end = start;
|
||||
int end = start;
|
||||
|
||||
while ( end < array.Length )
|
||||
{
|
||||
|
|
@ -308,8 +306,7 @@ namespace Server.Commands
|
|||
args = new string[0];
|
||||
}
|
||||
|
||||
CommandEntry entry = null;
|
||||
m_Entries.TryGetValue( command, out entry );
|
||||
m_Entries.TryGetValue( command, out CommandEntry entry );
|
||||
|
||||
if ( entry != null )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -219,8 +219,8 @@ namespace Server
|
|||
|
||||
public static void SendTargetEffect( IEntity target, int itemID, int speed, int duration, int hue, int renderMode )
|
||||
{
|
||||
if ( target is Mobile )
|
||||
((Mobile)target).ProcessDelta();
|
||||
if ( target is Mobile mobile )
|
||||
mobile.ProcessDelta();
|
||||
|
||||
SendPacket( target.Location, target.Map, new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );
|
||||
}
|
||||
|
|
@ -237,8 +237,8 @@ namespace Server
|
|||
|
||||
public static void SendTargetParticles( IEntity target, int itemID, int speed, int duration, int hue, int renderMode, int effect, EffectLayer layer, int unknown )
|
||||
{
|
||||
if ( target is Mobile )
|
||||
((Mobile)target).ProcessDelta();
|
||||
if ( target is Mobile mobile )
|
||||
mobile.ProcessDelta();
|
||||
|
||||
Map map = target.Map;
|
||||
|
||||
|
|
@ -280,11 +280,11 @@ namespace Server
|
|||
|
||||
public static void SendMovingEffect( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode )
|
||||
{
|
||||
if ( from is Mobile )
|
||||
((Mobile)from).ProcessDelta();
|
||||
if ( from is Mobile mobile )
|
||||
mobile.ProcessDelta();
|
||||
|
||||
if ( to is Mobile )
|
||||
((Mobile)to).ProcessDelta();
|
||||
if ( to is Mobile mobile1 )
|
||||
mobile1.ProcessDelta();
|
||||
|
||||
SendPacket( from.Location, from.Map, new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
|
||||
}
|
||||
|
|
@ -306,11 +306,11 @@ namespace Server
|
|||
|
||||
public static void SendMovingParticles( IEntity from, IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, EffectLayer layer, int unknown )
|
||||
{
|
||||
if ( from is Mobile )
|
||||
((Mobile)from).ProcessDelta();
|
||||
if ( from is Mobile mobile )
|
||||
mobile.ProcessDelta();
|
||||
|
||||
if ( to is Mobile )
|
||||
((Mobile)to).ProcessDelta();
|
||||
if ( to is Mobile mobile1 )
|
||||
mobile1.ProcessDelta();
|
||||
|
||||
Map map = from.Map;
|
||||
|
||||
|
|
@ -382,4 +382,4 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ namespace Server
|
|||
|
||||
public int CompareTo( object other )
|
||||
{
|
||||
if ( other is Point2D )
|
||||
return this.CompareTo( (Point2D) other );
|
||||
else if ( other == null )
|
||||
if ( other is Point2D d )
|
||||
return this.CompareTo( d );
|
||||
if ( other == null )
|
||||
return -1;
|
||||
|
||||
throw new ArgumentException();
|
||||
|
|
@ -108,7 +108,7 @@ namespace Server
|
|||
|
||||
public override bool Equals( object o )
|
||||
{
|
||||
if ( o == null || !(o is IPoint2D) ) return false;
|
||||
if ( !(o is IPoint2D) ) return false;
|
||||
|
||||
IPoint2D p = (IPoint2D)o;
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ namespace Server
|
|||
|
||||
public override bool Equals( object o )
|
||||
{
|
||||
if ( o == null || !( o is IPoint3D ) )
|
||||
if ( !(o is IPoint3D) )
|
||||
return false;
|
||||
|
||||
IPoint3D p = (IPoint3D) o;
|
||||
|
|
@ -367,9 +367,9 @@ namespace Server
|
|||
|
||||
public int CompareTo( object other )
|
||||
{
|
||||
if ( other is Point3D )
|
||||
return this.CompareTo( (Point3D) other );
|
||||
else if ( other == null )
|
||||
if ( other is Point3D d )
|
||||
return this.CompareTo( d );
|
||||
if ( other == null )
|
||||
return -1;
|
||||
|
||||
throw new ArgumentException();
|
||||
|
|
@ -635,4 +635,4 @@ namespace Server
|
|||
&& ( p.Z < m_End.m_Z );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1544,11 +1544,8 @@ namespace Server
|
|||
|
||||
public virtual bool OnDragDrop( Mobile from, Item dropped )
|
||||
{
|
||||
bool success = false;
|
||||
if ( Parent is Container )
|
||||
success = ((Container)Parent).OnStackAttempt( from, this, dropped );
|
||||
else
|
||||
success = StackWith( from, dropped );
|
||||
bool success = Parent is Container container && container.OnStackAttempt( from, this, dropped ) ||
|
||||
StackWith( from, dropped );
|
||||
|
||||
if ( success && Spawner != null )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2620,7 +2620,7 @@ namespace Server
|
|||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
m_Callback?.Invoke( @from, targeted );
|
||||
m_Callback?.Invoke( from, targeted );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2647,7 +2647,7 @@ namespace Server
|
|||
|
||||
protected override void OnTarget( Mobile from, object targeted )
|
||||
{
|
||||
m_Callback?.Invoke( @from, targeted, m_State );
|
||||
m_Callback?.Invoke( from, targeted, m_State );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2674,7 +2674,7 @@ namespace Server
|
|||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
m_Callback?.Invoke(@from, targeted, m_State);
|
||||
m_Callback?.Invoke(from, targeted, m_State);
|
||||
}
|
||||
}
|
||||
public Target BeginTarget<T>(int range, bool allowGround, TargetFlags flags, TargetStateCallback<T> callback, T state)
|
||||
|
|
@ -4359,6 +4359,7 @@ namespace Server
|
|||
Console.WriteLine( "Warning: 0x{0:X}: Item must have a zero paramater constructor to be separated from a stack. '{1}'.", oldItem.Serial.Value, oldItem.GetType().Name );
|
||||
return null;
|
||||
}
|
||||
|
||||
item.Visible = oldItem.Visible;
|
||||
item.Movable = oldItem.Movable;
|
||||
item.LootType = oldItem.LootType;
|
||||
|
|
@ -4376,13 +4377,13 @@ namespace Server
|
|||
oldItem.Amount = amount;
|
||||
oldItem.OnAfterDuped( item );
|
||||
|
||||
if ( oldItem.Parent is Mobile )
|
||||
if ( oldItem.Parent is Mobile parentMobile )
|
||||
{
|
||||
((Mobile)oldItem.Parent).AddItem( item );
|
||||
parentMobile.AddItem( item );
|
||||
}
|
||||
else if ( oldItem.Parent is Item )
|
||||
else if ( oldItem.Parent is Item parentItem )
|
||||
{
|
||||
((Item)oldItem.Parent).AddItem( item );
|
||||
parentItem.AddItem( item );
|
||||
}
|
||||
|
||||
item.Delta( ItemDelta.Update );
|
||||
|
|
@ -4581,8 +4582,8 @@ namespace Server
|
|||
if (item.HandlesOnSpeech)
|
||||
list.Add( item );
|
||||
|
||||
if (item is Container)
|
||||
AddSpeechItemsFrom(list, (Container)item);
|
||||
if (item is Container container)
|
||||
AddSpeechItemsFrom(list, container);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -6543,14 +6544,10 @@ namespace Server
|
|||
IPooledEnumerable<IEntity> eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
|
||||
|
||||
foreach ( IEntity o in eable ) {
|
||||
if ( o is Mobile ) {
|
||||
Mobile m = (Mobile)o;
|
||||
|
||||
if ( o is Mobile m ) {
|
||||
if ( m != this && Utility.InUpdateRange( m_Location, m.m_Location ) )
|
||||
ns.Send( m.RemovePacket );
|
||||
} else if ( o is Item ) {
|
||||
Item item = (Item)o;
|
||||
|
||||
} else if ( o is Item item ) {
|
||||
if ( InRange( item.Location, item.GetUpdateRange( this ) ) )
|
||||
ns.Send( item.RemovePacket );
|
||||
}
|
||||
|
|
@ -6583,14 +6580,17 @@ namespace Server
|
|||
}
|
||||
|
||||
public bool SendHuePicker( HuePicker p, bool throwOnOffline ) {
|
||||
if ( m_NetState != null ) {
|
||||
p.SendTo( m_NetState );
|
||||
if (m_NetState != null)
|
||||
{
|
||||
p.SendTo(m_NetState);
|
||||
return true;
|
||||
} else if ( throwOnOffline ) {
|
||||
throw new MobileNotConnectedException( this, "Hue picker could not be sent." );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( throwOnOffline ) {
|
||||
throw new MobileNotConnectedException( this, "Hue picker could not be sent." );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Gump FindGump( Type type ) {
|
||||
|
|
@ -6598,7 +6598,7 @@ namespace Server
|
|||
|
||||
if ( ns != null ) {
|
||||
foreach ( Gump gump in ns.Gumps ) {
|
||||
if ( type.IsAssignableFrom( gump.GetType() ) ) {
|
||||
if ( type.IsInstanceOfType( gump ) ) {
|
||||
return gump;
|
||||
}
|
||||
}
|
||||
|
|
@ -10108,9 +10108,7 @@ namespace Server
|
|||
|
||||
if ( sendStam || sendMana )
|
||||
{
|
||||
IParty ip = m_Party as IParty;
|
||||
|
||||
if (ip != null)
|
||||
if (m_Party is IParty ip)
|
||||
{
|
||||
if ( sendStam )
|
||||
ip.OnStamChanged( this );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue