More cast conversion fixes

This commit is contained in:
Kamron Batman 2018-09-06 18:07:42 -07:00
parent 3f45bd57b9
commit aba9452161
46 changed files with 359 additions and 506 deletions

View file

@ -60,9 +60,7 @@ namespace Server.Items
public override void OnAfterDuped( Item newItem )
{
DawnsMusicBox box = newItem as DawnsMusicBox;
if ( box == null )
if ( !(newItem is DawnsMusicBox box) )
return;
box.m_Tracks = new List<MusicName>();

View file

@ -76,7 +76,7 @@ namespace Server.Items
base.Serialize( writer );
writer.WriteEncodedInt( (int) 1 ); // version
writer.Write( (int) m_Music );
}
@ -85,7 +85,7 @@ namespace Server.Items
base.Deserialize( reader );
int version = reader.ReadEncodedInt();
switch ( version )
{
case 1:
@ -94,19 +94,19 @@ namespace Server.Items
break;
}
}
if ( version == 0 ) // Music wasn't serialized in version 0, pick a new track of random rarity
{
DawnsMusicRarity rarity;
double rand = Utility.RandomDouble();
if ( rand < 0.025 )
rarity = DawnsMusicRarity.Rare;
else if ( rand < 0.225 )
rarity = DawnsMusicRarity.Uncommon;
else
rarity = DawnsMusicRarity.Common;
m_Music = DawnsMusicBox.RandomTrack( rarity );
}
}
@ -125,9 +125,7 @@ namespace Server.Items
if ( m_Gear == null || m_Gear.Deleted )
return;
DawnsMusicBox box = targeted as DawnsMusicBox;
if ( box != null )
if ( targeted is DawnsMusicBox box )
{
if ( !box.Tracks.Contains( m_Gear.Music ) )
{

View file

@ -198,9 +198,7 @@ namespace Server.Items
if ( Items[i] is EnhancedBandage )
continue;
Bandage bandage = Items[i] as Bandage;
if ( bandage != null )
if ( Items[i] is Bandage bandage )
{
Item enhanced;

View file

@ -50,10 +50,8 @@ namespace Server.Items
{
base.OnRemoved( parent );
if ( parent is Mobile )
if ( parent is Mobile m )
{
Mobile m = (Mobile) parent;
AnimalForm.RemoveContext( m, true );
}
}
@ -62,11 +60,11 @@ namespace Server.Items
{
if ( type == typeof( Squirrel ) )
return m.Talisman is SquirrelFormTalisman;
else if ( type == typeof( Ferret ) )
if ( type == typeof( Ferret ) )
return m.Talisman is FerretFormTalisman;
else if ( type == typeof( CuSidhe ) )
if ( type == typeof( CuSidhe ) )
return m.Talisman is CuSidheFormTalisman;
else if ( type == typeof( Reptalon ) )
if ( type == typeof( Reptalon ) )
return m.Talisman is ReptalonFormTalisman;
return true;

View file

@ -24,15 +24,14 @@ namespace Server.Items
if ( m_Bonus == 0 )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = null;
}
else if ( m_SkillMod == null && Parent is Mobile )
else if ( m_SkillMod == null && Parent is Mobile mobile )
{
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
else if ( m_SkillMod != null )
{
@ -45,13 +44,12 @@ namespace Server.Items
{
base.OnAdded( parent );
if ( m_Bonus != 0 && parent is Mobile )
if ( m_Bonus != 0 && parent is Mobile mobile )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
}
@ -59,8 +57,7 @@ namespace Server.Items
{
base.OnRemoved( parent );
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = null;
}
@ -118,13 +115,12 @@ namespace Server.Items
}
}
if ( m_Bonus != 0 && Parent is Mobile )
if ( m_Bonus != 0 && Parent is Mobile mobile )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Blacksmith, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
if ( Hue == 0 )

View file

@ -159,15 +159,14 @@ namespace Server.Items
if ( m_Bonus == 0 )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = null;
}
else if ( m_SkillMod == null && Parent is Mobile )
else if ( m_SkillMod == null && Parent is Mobile mobile )
{
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
else if ( m_SkillMod != null )
{
@ -180,13 +179,12 @@ namespace Server.Items
{
base.OnAdded( parent );
if ( m_Bonus != 0 && parent is Mobile )
if ( m_Bonus != 0 && parent is Mobile mobile )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
}
@ -194,8 +192,7 @@ namespace Server.Items
{
base.OnRemoved( parent );
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = null;
}
@ -243,13 +240,12 @@ namespace Server.Items
}
}
if ( m_Bonus != 0 && Parent is Mobile )
if ( m_Bonus != 0 && Parent is Mobile mobile )
{
if ( m_SkillMod != null )
m_SkillMod.Remove();
m_SkillMod?.Remove();
m_SkillMod = new DefaultSkillMod( SkillName.Mining, true, m_Bonus );
((Mobile)Parent).AddSkillMod( m_SkillMod );
mobile.AddSkillMod( m_SkillMod );
}
}
}