Fixes several more expression issues and cast type check merges.

This commit is contained in:
Kamron Batman 2018-09-15 23:31:51 -07:00
parent f93c3b992e
commit 9542c79ea4
24 changed files with 106 additions and 145 deletions

View file

@ -242,7 +242,7 @@ namespace Server.Factions
IPooledEnumerable<IEntity> eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs); IPooledEnumerable<IEntity> eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs);
foreach (IEntity obj in eable) foreach (IEntity obj in eable)
if (type.IsAssignableFrom(obj.GetType())) if (type.IsInstanceOfType(obj))
{ {
eable.Free(); eable.Free();
return true; return true;

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Server.Commands; using Server.Commands;
namespace Server.Factions namespace Server.Factions
@ -68,11 +69,7 @@ namespace Server.Factions
private static bool CheckExistance(Point3D loc, Map facet, Type type) private static bool CheckExistance(Point3D loc, Map facet, Type type)
{ {
foreach (Item item in facet.GetItemsInRange(loc, 0)) return facet.GetItemsInRange(loc, 0).Any(type.IsInstanceOfType);
if (type.IsAssignableFrom(item.GetType()))
return true;
return false;
} }
} }
} }

View file

@ -136,7 +136,7 @@ namespace Server.Engines.MLQuests.Objectives
{ {
Type destType = Objective.Destination; Type destType = Objective.Destination;
return destType != null && destType.IsAssignableFrom(type); return destType?.IsAssignableFrom(type) == true;
} }
public override bool IsCompleted() public override bool IsCompleted()

View file

@ -40,7 +40,7 @@ namespace Server.Gumps
targeted is AddonComponent) targeted is AddonComponent)
targeted = ((AddonComponent)targeted).Addon; targeted = ((AddonComponent)targeted).Addon;
if (m_Type.IsAssignableFrom(targeted.GetType())) if (m_Type.IsInstanceOfType(targeted))
{ {
CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString()); CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
m_Property.SetValue(m_Object, targeted, null); m_Property.SetValue(m_Object, targeted, null);

View file

@ -503,12 +503,9 @@ namespace Server
* Bleh. * Bleh.
*/ */
Type[] ifaces = active.FindInterfaces( delegate( Type type, object obj ) Type[] ifaces = active.FindInterfaces((type, obj) => (type.IsGenericType)
{ && (type.GetGenericTypeDefinition() == typeof(IComparable<>))
return ( type.IsGenericType ) && (type.GetGenericArguments()[0].IsAssignableFrom(active)), null );
&& ( type.GetGenericTypeDefinition() == typeof( IComparable<> ) )
&& ( type.GetGenericArguments()[0].IsAssignableFrom( active ) );
}, null );
if ( ifaces.Length > 0 ) if ( ifaces.Length > 0 )
{ {

View file

@ -3552,12 +3552,7 @@ namespace Server.Mobiles
private Item[] m_Items; private Item[] m_Items;
private int m_Page; private int m_Page;
public ItemInsuranceMenuGump(PlayerMobile from, Item[] items) public ItemInsuranceMenuGump(PlayerMobile from, Item[] items, bool[] insure = null, int page = 0)
: this(from, items, null, 0)
{
}
public ItemInsuranceMenuGump(PlayerMobile from, Item[] items, bool[] insure, int page)
: base(25, 50) : base(25, 50)
{ {
m_From = from; m_From = from;

View file

@ -69,10 +69,10 @@ namespace Server.Mobiles
Item artifact = Loot.Construct(type); Item artifact = Loot.Construct(type);
if (artifact is MonsterStatuette && StatueTypes.Length > 0) if (artifact is MonsterStatuette statuette && StatueTypes.Length > 0)
{ {
((MonsterStatuette)artifact).Type = StatueTypes[Utility.Random(StatueTypes.Length)]; statuette.Type = StatueTypes[Utility.Random(StatueTypes.Length)];
((MonsterStatuette)artifact).LootType = LootType.Regular; statuette.LootType = LootType.Regular;
} }
return artifact; return artifact;

View file

@ -111,9 +111,8 @@ namespace Server.Mobiles
e.Handled = true; e.Handled = true;
Mobile from = e.Mobile; Mobile from = e.Mobile;
Guild g = from.Guild as Guild;
if (g == null || g.Type != Type) if (!(from.Guild is Guild g) || g.Type != Type)
{ {
Say(SignupNumber); Say(SignupNumber);
} }
@ -124,7 +123,7 @@ namespace Server.Mobiles
Item twoHanded = from.FindItemOnLayer(Layer.TwoHanded); Item twoHanded = from.FindItemOnLayer(Layer.TwoHanded);
if (pack?.FindItemByType(shield.GetType()) != null || if (pack?.FindItemByType(shield.GetType()) != null ||
twoHanded != null && shield.GetType().IsAssignableFrom(twoHanded.GetType())) twoHanded != null && shield.GetType().IsInstanceOfType(twoHanded))
{ {
Say(1007110); // Why dost thou ask about virtue guards when thou art one? Say(1007110); // Why dost thou ask about virtue guards when thou art one?
shield.Delete(); shield.Delete();

View file

@ -323,8 +323,8 @@ namespace Server.Mobiles
{ {
DamageStore ds = rights[i]; DamageStore ds = rights[i];
if (ds.m_HasRight && ds.m_Mobile is PlayerMobile) if (ds.m_HasRight && ds.m_Mobile is PlayerMobile mobile)
PlayerMobile.ChampionTitleInfo.AwardHarrowerTitle((PlayerMobile)ds.m_Mobile); PlayerMobile.ChampionTitleInfo.AwardHarrowerTitle(mobile);
} }
if (!NoKillAwards) if (!NoKillAwards)

View file

@ -102,8 +102,8 @@ namespace Server.Mobiles
if (m == this || !CanBeHarmful(m)) if (m == this || !CanBeHarmful(m))
continue; continue;
if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || if (m is BaseCreature creature && (creature.Controlled || creature.Summoned ||
((BaseCreature)m).Team != Team)) creature.Team != Team))
targets.Add(m); targets.Add(m);
else if (m.Player) else if (m.Player)
targets.Add(m); targets.Add(m);

View file

@ -94,8 +94,8 @@ namespace Server.Mobiles
if (m == this || !CanBeHarmful(m)) if (m == this || !CanBeHarmful(m))
continue; continue;
if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || if (m is BaseCreature creature && (creature.Controlled || creature.Summoned ||
((BaseCreature)m).Team != Team)) creature.Team != Team))
list.Add(m); list.Add(m);
else if (m.Player) else if (m.Player)
list.Add(m); list.Add(m);

View file

@ -122,58 +122,55 @@ namespace Server.Mobiles
private void DoCounter(Mobile attacker) private void DoCounter(Mobile attacker)
{ {
if (Map == null || attacker is BaseCreature && ((BaseCreature)attacker).BardProvoked) if (Map == null)
return; return;
if (0.2 > Utility.RandomDouble()) if (!(0.2 > Utility.RandomDouble()))
{ return;
/* Counterattack with Hit Poison Area
BaseCreature bc = attacker as BaseCreature;
if (bc?.BardProvoked == true)
return;
/* Counterattack with Hit Poison Area
* 20-25 damage, unresistable * 20-25 damage, unresistable
* Lethal poison, 100% of the time * Lethal poison, 100% of the time
* Particle effect: Type: "2" From: "0x4061A107" To: "0x0" ItemId: "0x36BD" ItemIdName: "explosion" FromLocation: "(296 615, 17)" ToLocation: "(296 615, 17)" Speed: "1" Duration: "10" FixedDirection: "True" Explode: "False" Hue: "0xA6" RenderMode: "0x0" Effect: "0x1F78" ExplodeEffect: "0x1" ExplodeSound: "0x0" Serial: "0x4061A107" Layer: "255" Unknown: "0x0" * Particle effect: Type: "2" From: "0x4061A107" To: "0x0" ItemId: "0x36BD" ItemIdName: "explosion" FromLocation: "(296 615, 17)" ToLocation: "(296 615, 17)" Speed: "1" Duration: "10" FixedDirection: "True" Explode: "False" Hue: "0xA6" RenderMode: "0x0" Effect: "0x1F78" ExplodeEffect: "0x1" ExplodeSound: "0x0" Serial: "0x4061A107" Layer: "255" Unknown: "0x0"
* Doesn't work on provoked monsters * Doesn't work on provoked monsters
*/ */
Mobile target = null; Mobile target = bc?.GetMaster();
if (attacker is BaseCreature) if (target == null || !target.InRange(this, 25))
{ target = attacker;
Mobile m = ((BaseCreature)attacker).GetMaster();
if (m != null) Animate(10, 4, 1, true, false, 0);
target = m;
}
if (target == null || !target.InRange(this, 25)) ArrayList targets = new ArrayList();
target = attacker;
Animate(10, 4, 1, true, false, 0); foreach (Mobile m in target.GetMobilesInRange(8))
{
if (m == this || !CanBeHarmful(m))
continue;
ArrayList targets = new ArrayList(); if (m is BaseCreature creature && (creature.Controlled || creature.Summoned ||
creature.Team != Team))
targets.Add(m);
else if (m.Player)
targets.Add(m);
}
foreach (Mobile m in target.GetMobilesInRange(8)) for (int i = 0; i < targets.Count; ++i)
{ {
if (m == this || !CanBeHarmful(m)) Mobile m = (Mobile)targets[i];
continue;
if (m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || DoHarmful(m);
((BaseCreature)m).Team != Team))
targets.Add(m);
else if (m.Player)
targets.Add(m);
}
for (int i = 0; i < targets.Count; ++i) AOS.Damage(m, this, Utility.RandomMinMax(20, 25), true, 0, 0, 0, 100, 0);
{
Mobile m = (Mobile)targets[i];
DoHarmful(m); m.FixedParticles(0x36BD, 1, 10, 0x1F78, 0xA6, 0, (EffectLayer)255);
m.ApplyPoison(this, Poison.Lethal);
AOS.Damage(m, this, Utility.RandomMinMax(20, 25), true, 0, 0, 0, 100, 0);
m.FixedParticles(0x36BD, 1, 10, 0x1F78, 0xA6, 0, (EffectLayer)255);
m.ApplyPoison(this, Poison.Lethal);
}
} }
} }

View file

@ -149,7 +149,7 @@ namespace Server.Mobiles
bool okay = true; bool okay = true;
foreach (BaseObjective obj in quest.Objectives) foreach (BaseObjective obj in quest.Objectives)
if (obj is EscortObjective && ((EscortObjective)obj).Destination.Contains(reg)) if (obj is EscortObjective objective && objective.Destination.Contains(reg))
{ {
okay = false; // We're already there! okay = false; // We're already there!
break; break;
@ -271,10 +271,10 @@ namespace Server.Mobiles
return false; return false;
} }
if (m is PlayerMobile && ((PlayerMobile)m).LastEscortTime + EscortDelay >= DateTime.UtcNow) if (m is PlayerMobile mobile && mobile.LastEscortTime + EscortDelay >= DateTime.UtcNow)
{ {
int minutes = int minutes =
(int)Math.Ceiling((((PlayerMobile)m).LastEscortTime + EscortDelay - DateTime.UtcNow).TotalMinutes); (int)Math.Ceiling((mobile.LastEscortTime + EscortDelay - DateTime.UtcNow).TotalMinutes);
Say("You must rest {0} minute{1} before we set out on this journey.", minutes, minutes == 1 ? "" : "s"); Say("You must rest {0} minute{1} before we set out on this journey.", minutes, minutes == 1 ? "" : "s");
return false; return false;
@ -284,8 +284,8 @@ namespace Server.Mobiles
{ {
m_LastSeenEscorter = DateTime.UtcNow; m_LastSeenEscorter = DateTime.UtcNow;
if (m is PlayerMobile) if (m is PlayerMobile playerMobile)
((PlayerMobile)m).LastEscortTime = DateTime.UtcNow; playerMobile.LastEscortTime = DateTime.UtcNow;
Say("Lead on! Payment will be made when we arrive in {0}.", Say("Lead on! Payment will be made when we arrive in {0}.",
dest.Name == "Ocllo" && m.Map == Map.Trammel ? "Haven" : dest.Name); dest.Name == "Ocllo" && m.Map == Map.Trammel ? "Haven" : dest.Name);
@ -473,9 +473,7 @@ namespace Server.Mobiles
bool gainedPath = false; bool gainedPath = false;
PlayerMobile pm = escorter as PlayerMobile; if (escorter is PlayerMobile pm)
if (pm != null)
{ {
if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay) if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay)
{ {

View file

@ -1415,9 +1415,8 @@ namespace Server.Mobiles
IBuyItemInfo[] buyinfo = (IBuyItemInfo[])m_ArmorBuyInfo.ToArray(typeof(IBuyItemInfo)); IBuyItemInfo[] buyinfo = (IBuyItemInfo[])m_ArmorBuyInfo.ToArray(typeof(IBuyItemInfo));
if (buyinfo != null) foreach (IBuyItemInfo info in buyinfo)
foreach (IBuyItemInfo info in buyinfo) info.PriceScalar = priceScalar;
info.PriceScalar = priceScalar;
} }
#endregion #endregion

View file

@ -159,7 +159,7 @@ namespace Server.Mobiles
object Obj_Disp = GetDisplayEntity(); object Obj_Disp = GetDisplayEntity();
if (Core.ML && Obj_Disp is Item && !(Obj_Disp as Item).Stackable) if (Core.ML && Obj_Disp is Item item && !item.Stackable)
MaxAmount = Math.Min(20, MaxAmount); MaxAmount = Math.Min(20, MaxAmount);
else else
MaxAmount = Math.Min(999, MaxAmount * 2); MaxAmount = Math.Min(999, MaxAmount * 2);
@ -257,10 +257,10 @@ namespace Server.Mobiles
if (cache) if (cache)
m_Table[key] = obj; m_Table[key] = obj;
if (obj is Item) if (obj is Item item)
AddItem((Item)obj); AddItem(item);
else if (obj is Mobile) else if (obj is Mobile mobile)
m_Mobiles.Add((Mobile)obj); m_Mobiles.Add(mobile);
} }
public override void OnAfterDelete() public override void OnAfterDelete()

View file

@ -23,9 +23,7 @@ namespace Server.Mobiles
{ {
m_Table.TryGetValue( item.GetType(), out int price ); m_Table.TryGetValue( item.GetType(), out int price );
if ( item is BaseArmor ) { if ( item is BaseArmor armor ) {
BaseArmor armor = (BaseArmor)item;
if ( armor.Quality == ArmorQuality.Low ) if ( armor.Quality == ArmorQuality.Low )
price = (int)( price * 0.60 ); price = (int)( price * 0.60 );
else if ( armor.Quality == ArmorQuality.Exceptional ) else if ( armor.Quality == ArmorQuality.Exceptional )
@ -38,9 +36,7 @@ namespace Server.Mobiles
if ( price < 1 ) if ( price < 1 )
price = 1; price = 1;
} }
else if ( item is BaseWeapon ) { else if ( item is BaseWeapon weapon ) {
BaseWeapon weapon = (BaseWeapon)item;
if ( weapon.Quality == WeaponQuality.Low ) if ( weapon.Quality == WeaponQuality.Low )
price = (int)( price * 0.60 ); price = (int)( price * 0.60 );
else if ( weapon.Quality == WeaponQuality.Exceptional ) else if ( weapon.Quality == WeaponQuality.Exceptional )
@ -53,18 +49,16 @@ namespace Server.Mobiles
if ( price < 1 ) if ( price < 1 )
price = 1; price = 1;
} }
else if ( item is BaseBeverage ) { else if ( item is BaseBeverage bev ) {
int price1 = price, price2 = price; int price1 = price, price2 = price;
if ( item is Pitcher ) if ( bev is Pitcher )
{ price1 = 3; price2 = 5; } { price1 = 3; price2 = 5; }
else if ( item is BeverageBottle ) else if ( bev is BeverageBottle )
{ price1 = 3; price2 = 3; } { price1 = 3; price2 = 3; }
else if ( item is Jug ) else if ( bev is Jug )
{ price1 = 6; price2 = 6; } { price1 = 6; price2 = 6; }
BaseBeverage bev = (BaseBeverage)item;
if ( bev.IsEmpty || bev.Content == BeverageType.Milk ) if ( bev.IsEmpty || bev.Content == BeverageType.Milk )
price = price1; price = price1;
else else

View file

@ -466,8 +466,8 @@ namespace Server.Mobiles
protected override void OnTarget(Mobile from, object targeted) protected override void OnTarget(Mobile from, object targeted)
{ {
if (targeted is BaseCreature) if (targeted is BaseCreature creature)
m_Trainer.EndStable(from, (BaseCreature)targeted); m_Trainer.EndStable(from, creature);
else if (targeted == from) else if (targeted == from)
m_Trainer.SayTo(from, 502672); // HA HA HA! Sorry, I am not an inn. m_Trainer.SayTo(from, 502672); // HA HA HA! Sorry, I am not an inn.
else else

View file

@ -97,9 +97,7 @@ namespace Server.Mobiles
public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) public override Item CreateBulkOrder(Mobile from, bool fromContextMenu)
{ {
PlayerMobile pm = from as PlayerMobile; if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
if (pm != null && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{ {
double theirSkill = pm.Skills[SkillName.Blacksmith].Base; double theirSkill = pm.Skills[SkillName.Blacksmith].Base;
@ -131,16 +129,16 @@ namespace Server.Mobiles
public override TimeSpan GetNextBulkOrder(Mobile from) public override TimeSpan GetNextBulkOrder(Mobile from)
{ {
if (from is PlayerMobile) if (from is PlayerMobile mobile)
return ((PlayerMobile)from).NextSmithBulkOrder; return mobile.NextSmithBulkOrder;
return TimeSpan.Zero; return TimeSpan.Zero;
} }
public override void OnSuccessfulBulkOrderReceive(Mobile from) public override void OnSuccessfulBulkOrderReceive(Mobile from)
{ {
if (Core.SE && from is PlayerMobile) if (Core.SE && from is PlayerMobile mobile)
((PlayerMobile)from).NextSmithBulkOrder = TimeSpan.Zero; mobile.NextSmithBulkOrder = TimeSpan.Zero;
} }
#endregion #endregion

View file

@ -73,20 +73,18 @@ namespace Server.Mobiles
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
if (!e.Handled && from is PlayerMobile && from.InRange(Location, 2) && WasNamed(e.Speech)) if (!e.Handled && from is PlayerMobile pm && pm.InRange(Location, 2) && WasNamed(e.Speech))
{ {
PlayerMobile pm = (PlayerMobile)from;
if (e.HasKeyword(0x0004)) // *join* | *member* if (e.HasKeyword(0x0004)) // *join* | *member*
{ {
if (pm.NpcGuild == NpcGuild) if (pm.NpcGuild == NpcGuild)
SayTo(from, 501047); // Thou art already a member of our guild. SayTo(pm, 501047); // Thou art already a member of our guild.
else if (pm.NpcGuild != NpcGuild.None) else if (pm.NpcGuild != NpcGuild.None)
SayTo(from, 501046); // Thou must resign from thy other guild first. SayTo(pm, 501046); // Thou must resign from thy other guild first.
else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow) else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow)
SayTo(from, 501048); // You are too young to join my guild... SayTo(pm, 501048); // You are too young to join my guild...
else if (CheckCustomReqs(pm)) else if (CheckCustomReqs(pm))
SayPriceTo(from); SayPriceTo(pm);
e.Handled = true; e.Handled = true;
} }
@ -94,16 +92,16 @@ namespace Server.Mobiles
{ {
if (pm.NpcGuild != NpcGuild) if (pm.NpcGuild != NpcGuild)
{ {
SayTo(from, 501052); // Thou dost not belong to my guild! SayTo(pm, 501052); // Thou dost not belong to my guild!
} }
else if (pm.NpcGuildJoinTime + QuitAge > DateTime.UtcNow || else if (pm.NpcGuildJoinTime + QuitAge > DateTime.UtcNow ||
pm.NpcGuildGameTime + QuitGameAge > pm.GameTime) pm.NpcGuildGameTime + QuitGameAge > pm.GameTime)
{ {
SayTo(from, 501053); // You just joined my guild! You must wait a week to resign. SayTo(pm, 501053); // You just joined my guild! You must wait a week to resign.
} }
else else
{ {
SayTo(from, 501054); // I accept thy resignation. SayTo(pm, 501054); // I accept thy resignation.
pm.NpcGuild = NpcGuild.None; pm.NpcGuild = NpcGuild.None;
} }
@ -116,25 +114,23 @@ namespace Server.Mobiles
public override bool OnGoldGiven(Mobile from, Gold dropped) public override bool OnGoldGiven(Mobile from, Gold dropped)
{ {
if (from is PlayerMobile && dropped.Amount == JoinCost) if (from is PlayerMobile pm && dropped.Amount == JoinCost)
{ {
PlayerMobile pm = (PlayerMobile)from;
if (pm.NpcGuild == NpcGuild) if (pm.NpcGuild == NpcGuild)
{ {
SayTo(from, 501047); // Thou art already a member of our guild. SayTo(pm, 501047); // Thou art already a member of our guild.
} }
else if (pm.NpcGuild != NpcGuild.None) else if (pm.NpcGuild != NpcGuild.None)
{ {
SayTo(from, 501046); // Thou must resign from thy other guild first. SayTo(pm, 501046); // Thou must resign from thy other guild first.
} }
else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow) else if (pm.GameTime < JoinGameAge || pm.CreationTime + JoinAge > DateTime.UtcNow)
{ {
SayTo(from, 501048); // You are too young to join my guild... SayTo(pm, 501048); // You are too young to join my guild...
} }
else if (CheckCustomReqs(pm)) else if (CheckCustomReqs(pm))
{ {
SayWelcomeTo(from); SayWelcomeTo(pm);
pm.NpcGuild = NpcGuild; pm.NpcGuild = NpcGuild;
pm.NpcGuildJoinTime = DateTime.UtcNow; pm.NpcGuildJoinTime = DateTime.UtcNow;

View file

@ -77,14 +77,12 @@ namespace Server.Mobiles
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
if (!e.Handled && from is PlayerMobile && from.InRange(Location, 2) && e.HasKeyword(0x1F)) // *disguise* if (!e.Handled && from is PlayerMobile pm && pm.InRange(Location, 2) && e.HasKeyword(0x1F)) // *disguise*
{ {
PlayerMobile pm = (PlayerMobile)from;
if (pm.NpcGuild == NpcGuild.ThievesGuild) if (pm.NpcGuild == NpcGuild.ThievesGuild)
SayTo(from, 501839); // That particular item costs 700 gold pieces. SayTo(pm, 501839); // That particular item costs 700 gold pieces.
else else
SayTo(from, 501838); // I don't know what you're talking about. SayTo(pm, 501838); // I don't know what you're talking about.
e.Handled = true; e.Handled = true;
} }
@ -94,13 +92,11 @@ namespace Server.Mobiles
public override bool OnGoldGiven(Mobile from, Gold dropped) public override bool OnGoldGiven(Mobile from, Gold dropped)
{ {
if (from is PlayerMobile && dropped.Amount == 700) if (from is PlayerMobile pm && dropped.Amount == 700)
{ {
PlayerMobile pm = (PlayerMobile)from;
if (pm.NpcGuild == NpcGuild.ThievesGuild) if (pm.NpcGuild == NpcGuild.ThievesGuild)
{ {
from.AddToBackpack(new DisguiseKit()); pm.AddToBackpack(new DisguiseKit());
dropped.Delete(); dropped.Delete();
return true; return true;

View file

@ -69,9 +69,8 @@ namespace Server.Mobiles
public override bool OnDragDrop(Mobile from, Item dropped) public override bool OnDragDrop(Mobile from, Item dropped)
{ {
if (dropped is HouseDeed) if (dropped is HouseDeed deed)
{ {
HouseDeed deed = (HouseDeed)dropped;
int price = ComputePriceFor(deed); int price = ComputePriceFor(deed);
if (price > 0) if (price > 0)
@ -98,9 +97,8 @@ namespace Server.Mobiles
public void Appraise_OnTarget(Mobile from, object obj) public void Appraise_OnTarget(Mobile from, object obj)
{ {
if (obj is HouseDeed) if (obj is HouseDeed deed)
{ {
HouseDeed deed = (HouseDeed)obj;
int price = ComputePriceFor(deed); int price = ComputePriceFor(deed);
if (price > 0) if (price > 0)
@ -126,8 +124,7 @@ namespace Server.Mobiles
{ {
int price = 0; int price = 0;
if (deed is SmallBrickHouseDeed || deed is StonePlasterHouseDeed || deed is FieldStoneHouseDeed || if (deed is SmallBrickHouseDeed || deed is StonePlasterHouseDeed || deed is FieldStoneHouseDeed || deed is WoodHouseDeed || deed is WoodPlasterHouseDeed ||
deed is SmallBrickHouseDeed || deed is WoodHouseDeed || deed is WoodPlasterHouseDeed ||
deed is ThatchedRoofCottageDeed) deed is ThatchedRoofCottageDeed)
price = 43800; price = 43800;
else if (deed is BrickHouseDeed) else if (deed is BrickHouseDeed)

View file

@ -47,9 +47,7 @@ namespace Server.Mobiles
public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) public override Item CreateBulkOrder(Mobile from, bool fromContextMenu)
{ {
PlayerMobile pm = from as PlayerMobile; if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
if (pm != null && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble()))
{ {
double theirSkill = pm.Skills[SkillName.Tailoring].Base; double theirSkill = pm.Skills[SkillName.Tailoring].Base;
@ -81,16 +79,16 @@ namespace Server.Mobiles
public override TimeSpan GetNextBulkOrder(Mobile from) public override TimeSpan GetNextBulkOrder(Mobile from)
{ {
if (from is PlayerMobile) if (from is PlayerMobile mobile)
return ((PlayerMobile)from).NextTailorBulkOrder; return mobile.NextTailorBulkOrder;
return TimeSpan.Zero; return TimeSpan.Zero;
} }
public override void OnSuccessfulBulkOrderReceive(Mobile from) public override void OnSuccessfulBulkOrderReceive(Mobile from)
{ {
if (Core.SE && from is PlayerMobile) if (Core.SE && from is PlayerMobile mobile)
((PlayerMobile)from).NextTailorBulkOrder = TimeSpan.Zero; mobile.NextTailorBulkOrder = TimeSpan.Zero;
} }
#endregion #endregion

View file

@ -1272,7 +1272,7 @@ namespace Server.Items
{ {
Item item = list[i]; Item item = list[i];
if (type.IsAssignableFrom(item.GetType())) if (type.IsInstanceOfType(item))
{ {
int need = amount - consumed; int need = amount - consumed;
int theirAmount = item.Amount; int theirAmount = item.Amount;

View file

@ -425,7 +425,7 @@ namespace Server
do do
{ {
if (regionType.IsAssignableFrom(r.GetType())) if (regionType.IsInstanceOfType(r))
return r; return r;
r = r.Parent; r = r.Parent;