Fixes chaos damage bug with the spell system. Fixes various small other bugs. Fixes more merge cast type checks and uses default values.
This commit is contained in:
parent
9542c79ea4
commit
c155c82325
115 changed files with 644 additions and 1041 deletions
|
|
@ -110,9 +110,7 @@ namespace Server.Multis
|
|||
if (m_Owner == null)
|
||||
return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh;
|
||||
|
||||
Account acct = m_Owner.Account as Account;
|
||||
|
||||
if (acct == null)
|
||||
if (!(m_Owner.Account is Account acct))
|
||||
return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh;
|
||||
|
||||
if (acct.AccessLevel >= AccessLevel.GameMaster)
|
||||
|
|
@ -751,17 +749,18 @@ namespace Server.Multis
|
|||
if (!addon.Deleted)
|
||||
{
|
||||
Item deed = null;
|
||||
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
|
||||
bool retainDeedHue = false; // if the items aren't hued but the deed itself is
|
||||
int hue = 0;
|
||||
|
||||
if (addon is IAddon)
|
||||
{
|
||||
deed = ((IAddon)addon).Deed;
|
||||
BaseAddon ba = addon as BaseAddon;
|
||||
|
||||
if (addon is BaseAddon && ((BaseAddon)addon).RetainDeedHue
|
||||
) //There are things that are IAddon which aren't BaseAddon
|
||||
if (addon is IAddon baseAddon)
|
||||
{
|
||||
deed = baseAddon.Deed;
|
||||
|
||||
// There are things that are IAddon which aren't BaseAddon
|
||||
if (ba?.RetainDeedHue == true)
|
||||
{
|
||||
BaseAddon ba = (BaseAddon)addon;
|
||||
retainDeedHue = true;
|
||||
|
||||
for (int i = 0; hue == 0 && i < ba.Components.Count; ++i)
|
||||
|
|
@ -778,16 +777,14 @@ namespace Server.Multis
|
|||
{
|
||||
#region Mondain's Legacy
|
||||
|
||||
if (deed is BaseAddonContainerDeed && addon is BaseAddonContainer)
|
||||
if (deed is BaseAddonContainerDeed containerDeed && addon is BaseAddonContainer c)
|
||||
{
|
||||
BaseAddonContainer c = (BaseAddonContainer)addon;
|
||||
c.DropItemsToGround();
|
||||
|
||||
((BaseAddonContainerDeed)deed).Resource = c.Resource;
|
||||
containerDeed.Resource = c.Resource;
|
||||
}
|
||||
else if (deed is BaseAddonDeed && addon is BaseAddon)
|
||||
else if (deed is BaseAddonDeed addonDeed && ba != null)
|
||||
{
|
||||
((BaseAddonDeed)deed).Resource = ((BaseAddon)addon).Resource;
|
||||
addonDeed.Resource = ba.Resource;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -874,10 +871,10 @@ namespace Server.Multis
|
|||
|
||||
RelocatedEntities.Add(relocEntity);
|
||||
|
||||
if (entity is Item)
|
||||
((Item)entity).Internalize();
|
||||
else
|
||||
((Mobile)entity).Internalize();
|
||||
if (entity is Item item)
|
||||
item.Internalize();
|
||||
else if (entity is Mobile mobile)
|
||||
mobile.Internalize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -889,15 +886,14 @@ namespace Server.Multis
|
|||
Point3D location = new Point3D(relLoc.X + X, relLoc.Y + Y, relLoc.Z + Z);
|
||||
|
||||
IEntity entity = relocEntity.Entity;
|
||||
if (entity is Item)
|
||||
if (entity is Item item)
|
||||
{
|
||||
Item item = (Item)entity;
|
||||
|
||||
if (!item.Deleted)
|
||||
{
|
||||
if (item is IAddon)
|
||||
IAddon addon = item as IAddon;
|
||||
if (addon != null)
|
||||
{
|
||||
if (((IAddon)item).CouldFit(location, Map))
|
||||
if (addon.CouldFit(location, Map))
|
||||
{
|
||||
item.MoveToWorld(location, Map);
|
||||
continue;
|
||||
|
|
@ -939,19 +935,18 @@ namespace Server.Multis
|
|||
|
||||
Item relocateItem = item;
|
||||
|
||||
if (item is StrongBox)
|
||||
relocateItem = ((StrongBox)item).ConvertToStandardContainer();
|
||||
if (item is StrongBox box)
|
||||
relocateItem = box.ConvertToStandardContainer();
|
||||
|
||||
if (item is IAddon)
|
||||
if (addon != null)
|
||||
{
|
||||
Item deed = ((IAddon)item).Deed;
|
||||
Item deed = addon.Deed;
|
||||
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
|
||||
int hue = 0;
|
||||
|
||||
if (item is BaseAddon && ((BaseAddon)item).RetainDeedHue
|
||||
if (item is BaseAddon ba && ba.RetainDeedHue
|
||||
) //There are things that are IAddon which aren't BaseAddon
|
||||
{
|
||||
BaseAddon ba = (BaseAddon)item;
|
||||
retainDeedHue = true;
|
||||
|
||||
for (int i = 0; hue == 0 && i < ba.Components.Count; ++i)
|
||||
|
|
@ -967,17 +962,14 @@ namespace Server.Multis
|
|||
|
||||
if (deed != null)
|
||||
{
|
||||
if (deed is BaseAddonContainerDeed && item is BaseAddonContainer)
|
||||
if (deed is BaseAddonContainerDeed containerDeed && item is BaseAddonContainer c)
|
||||
{
|
||||
BaseAddonContainer c = (BaseAddonContainer)item;
|
||||
c.DropItemsToGround();
|
||||
|
||||
((BaseAddonContainerDeed)deed).Resource = c.Resource;
|
||||
}
|
||||
else if (deed is BaseAddonDeed && item is BaseAddon)
|
||||
{
|
||||
((BaseAddonDeed)deed).Resource = ((BaseAddon)item).Resource;
|
||||
containerDeed.Resource = c.Resource;
|
||||
}
|
||||
else if (deed is BaseAddonDeed addonDeed && item is BaseAddon baseAddon)
|
||||
addonDeed.Resource = baseAddon.Resource;
|
||||
|
||||
if (retainDeedHue)
|
||||
deed.Hue = hue;
|
||||
|
|
@ -1004,17 +996,12 @@ namespace Server.Multis
|
|||
if (((SecureInfo)Secures[i]).Item == item)
|
||||
Secures.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
else if (entity is Mobile mobile && !mobile.Deleted)
|
||||
{
|
||||
Mobile mobile = (Mobile)entity;
|
||||
|
||||
if (!mobile.Deleted)
|
||||
{
|
||||
if (Map.CanFit(location, 16, false, false))
|
||||
mobile.MoveToWorld(location, Map);
|
||||
else
|
||||
InternalizedVendors.Add(mobile);
|
||||
}
|
||||
if (Map.CanFit(location, 16, false, false))
|
||||
mobile.MoveToWorld(location, Map);
|
||||
else
|
||||
InternalizedVendors.Add(mobile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1212,9 +1199,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; i < sector.Multis.Count; ++i)
|
||||
{
|
||||
BaseHouse house = sector.Multis[i] as BaseHouse;
|
||||
|
||||
if (house != null && house.IsInside(loc, height))
|
||||
if (sector.Multis[i] is BaseHouse house && house.IsInside(loc, height))
|
||||
return house;
|
||||
}
|
||||
|
||||
|
|
@ -1254,8 +1239,8 @@ namespace Server.Multis
|
|||
return true;
|
||||
if (item is Runebook)
|
||||
return true;
|
||||
if (item is ISecurable)
|
||||
return HasSecureAccess(from, ((ISecurable)item).Level);
|
||||
if (item is ISecurable securable)
|
||||
return HasSecureAccess(from, securable.Level);
|
||||
if (item is Container)
|
||||
return IsCoOwner(from);
|
||||
if (item.Stackable)
|
||||
|
|
@ -1264,8 +1249,6 @@ namespace Server.Multis
|
|||
return IsFriend(from);
|
||||
if (item is PotionKeg)
|
||||
return IsFriend(from);
|
||||
if (item is BaseBoard)
|
||||
return true;
|
||||
if (item is Dices)
|
||||
return true;
|
||||
if (item is RecallRune)
|
||||
|
|
@ -1276,7 +1259,7 @@ namespace Server.Multis
|
|||
return true;
|
||||
if (item is BaseInstrument)
|
||||
return true;
|
||||
if (item is Dyes || item is DyeTub)
|
||||
if (item is Dyes)
|
||||
return true;
|
||||
if (item is VendorRentalContract)
|
||||
return true;
|
||||
|
|
@ -1358,10 +1341,10 @@ namespace Server.Multis
|
|||
item.Map = Map;
|
||||
|
||||
foreach (IEntity entity in GetHouseEntities())
|
||||
if (entity is Item)
|
||||
((Item)entity).Map = Map;
|
||||
else
|
||||
((Mobile)entity).Map = Map;
|
||||
if (entity is Item item)
|
||||
item.Map = Map;
|
||||
else if (entity is Mobile mobile)
|
||||
mobile.Map = Map;
|
||||
}
|
||||
|
||||
public virtual void ChangeSignType(int itemID)
|
||||
|
|
@ -1408,10 +1391,10 @@ namespace Server.Multis
|
|||
{
|
||||
Point3D newLocation = new Point3D(entity.X + x, entity.Y + y, entity.Z + z);
|
||||
|
||||
if (entity is Item)
|
||||
((Item)entity).Location = newLocation;
|
||||
else
|
||||
((Mobile)entity).Location = newLocation;
|
||||
if (entity is Item item)
|
||||
item.Location = newLocation;
|
||||
else if (entity is Mobile mobile)
|
||||
mobile.Location = newLocation;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1499,7 +1482,7 @@ namespace Server.Multis
|
|||
AddDoor(westDoor, x, y, z);
|
||||
AddDoor(eastDoor, x + 1, y, z);
|
||||
|
||||
return new BaseDoor[2] { westDoor, eastDoor };
|
||||
return new BaseDoor[] { westDoor, eastDoor };
|
||||
}
|
||||
|
||||
public uint CreateKeys(Mobile m)
|
||||
|
|
@ -1544,7 +1527,7 @@ namespace Server.Multis
|
|||
AddDoor(westDoor, x, y, z);
|
||||
AddDoor(eastDoor, x + 1, y, z);
|
||||
|
||||
return new BaseDoor[2] { westDoor, eastDoor };
|
||||
return new BaseDoor[] { westDoor, eastDoor };
|
||||
}
|
||||
|
||||
public BaseDoor MakeDoor(bool wood, DoorFacing facing)
|
||||
|
|
@ -1583,9 +1566,7 @@ namespace Server.Multis
|
|||
|
||||
if (m_Trash == null || m_Trash.Deleted)
|
||||
{
|
||||
m_Trash = new TrashBarrel();
|
||||
|
||||
m_Trash.Movable = false;
|
||||
m_Trash = new TrashBarrel { Movable = false };
|
||||
m_Trash.MoveToWorld(from.Location, from.Map);
|
||||
|
||||
from.SendLocalizedMessage(502121); /* You have a new trash barrel.
|
||||
|
|
@ -1604,25 +1585,16 @@ namespace Server.Multis
|
|||
Sign.MoveToWorld(new Point3D(X + xoff, Y + yoff, Z + zoff), Map);
|
||||
}
|
||||
|
||||
private void SetLockdown(Item i, bool locked)
|
||||
{
|
||||
SetLockdown(i, locked, false);
|
||||
}
|
||||
|
||||
private void SetLockdown(Item i, bool locked, bool checkContains)
|
||||
private void SetLockdown(Item i, bool locked, bool checkContains = false)
|
||||
{
|
||||
if (LockDowns == null)
|
||||
return;
|
||||
|
||||
#region Mondain's Legacy
|
||||
|
||||
if (i is BaseAddonContainer)
|
||||
i.Movable = false;
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
i.Movable = !locked;
|
||||
|
||||
i.IsLockedDown = locked;
|
||||
|
||||
if (locked)
|
||||
|
|
@ -1976,12 +1948,9 @@ namespace Server.Multis
|
|||
{
|
||||
AggressorInfo info = m.Aggressed[i];
|
||||
|
||||
Guild attackerGuild = m.Guild as Guild;
|
||||
Guild defenderGuild = info.Defender.Guild as Guild;
|
||||
|
||||
if (info.Defender.Player && info.Defender.Alive &&
|
||||
DateTime.UtcNow - info.LastCombatTime < HouseRegion.CombatHeatDelay &&
|
||||
(attackerGuild == null || defenderGuild == null ||
|
||||
(!(m.Guild is Guild attackerGuild) || !(info.Defender.Guild is Guild defenderGuild) ||
|
||||
defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild)))
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2063,7 +2032,7 @@ namespace Server.Multis
|
|||
{
|
||||
Container c = info.Item;
|
||||
|
||||
if (!c.Deleted && c is StrongBox && ((StrongBox)c).Owner == from)
|
||||
if (!c.Deleted && c is StrongBox box && box.Owner == from)
|
||||
{
|
||||
from.SendLocalizedMessage(502112); //You already have a strong box
|
||||
return;
|
||||
|
|
@ -2086,10 +2055,7 @@ namespace Server.Multis
|
|||
}
|
||||
}
|
||||
|
||||
StrongBox sb = new StrongBox(from, this);
|
||||
sb.Movable = false;
|
||||
sb.IsLockedDown = false;
|
||||
sb.IsSecure = true;
|
||||
StrongBox sb = new StrongBox(from, this) { Movable = false, IsLockedDown = false, IsSecure = true };
|
||||
Secures.Add(new SecureInfo(sb, SecureLevel.CoOwners));
|
||||
sb.MoveToWorld(from.Location, from.Map);
|
||||
}
|
||||
|
|
@ -2115,7 +2081,7 @@ namespace Server.Multis
|
|||
{
|
||||
from.SendLocalizedMessage(501352); // You may not eject someone who is not in your house!
|
||||
}
|
||||
else if (targ is BaseCreature && ((BaseCreature)targ).NoHouseRestrictions)
|
||||
else if (targ is BaseCreature creature && creature.NoHouseRestrictions)
|
||||
{
|
||||
from.SendLocalizedMessage(501347); // You cannot eject that from the house!
|
||||
}
|
||||
|
|
@ -2196,7 +2162,7 @@ namespace Server.Multis
|
|||
from.SendLocalizedMessage(
|
||||
1062521); // You cannot ban someone from a private house. Revoke their access instead.
|
||||
}
|
||||
else if (targ is BaseCreature && ((BaseCreature)targ).NoHouseRestrictions)
|
||||
else if (targ is BaseCreature bc && bc.NoHouseRestrictions)
|
||||
{
|
||||
from.SendLocalizedMessage(1062040); // You cannot ban that.
|
||||
}
|
||||
|
|
@ -2296,12 +2262,12 @@ namespace Server.Multis
|
|||
{
|
||||
Container c = info.Item;
|
||||
|
||||
if (c is StrongBox && ((StrongBox)c).Owner == targ)
|
||||
if (c is StrongBox box && box.Owner == targ)
|
||||
{
|
||||
c.IsLockedDown = false;
|
||||
c.IsSecure = false;
|
||||
box.IsLockedDown = false;
|
||||
box.IsSecure = false;
|
||||
Secures.Remove(info);
|
||||
c.Destroy();
|
||||
box.Destroy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -2452,9 +2418,8 @@ namespace Server.Multis
|
|||
{
|
||||
Item item = (Item)LockDowns[i];
|
||||
|
||||
if (item is Container && !(item is BaseBoard || item is Aquarium || item is FishBowl))
|
||||
if (item is Container cont && !(cont is BaseBoard || cont is Aquarium || cont is FishBowl))
|
||||
{
|
||||
Container cont = (Container)item;
|
||||
List<Item> children = cont.Items;
|
||||
|
||||
for (int j = 0; j < children.Count; ++j)
|
||||
|
|
@ -2640,9 +2605,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Container c = items[i] as Container;
|
||||
|
||||
if (c != null)
|
||||
if (items[i] is Container c)
|
||||
{
|
||||
c.IsSecure = true;
|
||||
Secures.Add(new SecureInfo(c, SecureLevel.CoOwners));
|
||||
|
|
@ -2888,16 +2851,15 @@ namespace Server.Multis
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
if (!item.Deleted && item is IAddon)
|
||||
if (!item.Deleted && item is IAddon addon)
|
||||
{
|
||||
Item deed = ((IAddon)item).Deed;
|
||||
Item deed = addon.Deed;
|
||||
bool retainDeedHue = false; //if the items aren't hued but the deed itself is
|
||||
int hue = 0;
|
||||
|
||||
if (item is BaseAddon && ((BaseAddon)item).RetainDeedHue
|
||||
if (addon is BaseAddon ba && ba.RetainDeedHue
|
||||
) //There are things that are IAddon which aren't BaseAddon
|
||||
{
|
||||
BaseAddon ba = (BaseAddon)item;
|
||||
retainDeedHue = true;
|
||||
|
||||
for (int j = 0; hue == 0 && j < ba.Components.Count; ++j)
|
||||
|
|
@ -2959,9 +2921,7 @@ namespace Server.Multis
|
|||
|
||||
public static bool HasAccountHouse(Mobile m)
|
||||
{
|
||||
Account a = m.Account as Account;
|
||||
|
||||
if (a == null)
|
||||
if (!(m.Account is Account a))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < a.Length; ++i)
|
||||
|
|
@ -3009,9 +2969,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; keyValue == 0 && i < Doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = Doors[i] as BaseDoor;
|
||||
|
||||
if (door != null)
|
||||
if (Doors[i] is BaseDoor door)
|
||||
keyValue = door.KeyValue;
|
||||
}
|
||||
|
||||
|
|
@ -3026,9 +2984,7 @@ namespace Server.Multis
|
|||
if (Doors != null)
|
||||
for (int i = 0; i < Doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = Doors[i] as BaseDoor;
|
||||
|
||||
if (door != null)
|
||||
if (Doors[i] is BaseDoor door)
|
||||
door.KeyValue = keyValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -3038,9 +2994,7 @@ namespace Server.Multis
|
|||
if (Doors != null)
|
||||
for (int i = 0; i < Doors.Count; ++i)
|
||||
{
|
||||
BaseDoor door = Doors[i] as BaseDoor;
|
||||
|
||||
if (door != null)
|
||||
if (Doors[i] is BaseDoor door)
|
||||
{
|
||||
door.KeyValue = 0;
|
||||
door.Locked = false;
|
||||
|
|
@ -3075,9 +3029,7 @@ namespace Server.Multis
|
|||
if (c == m)
|
||||
return true;
|
||||
|
||||
Account bannedAccount = c.Account as Account;
|
||||
|
||||
if (bannedAccount != null && bannedAccount == theirAccount)
|
||||
if (c.Account is Account bannedAccount && bannedAccount == theirAccount)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -3092,10 +3044,8 @@ namespace Server.Multis
|
|||
if (m.AccessLevel > AccessLevel.Player || IsFriend(m) || Access != null && Access.Contains(m))
|
||||
return true;
|
||||
|
||||
if (m is BaseCreature)
|
||||
if (m is BaseCreature bc)
|
||||
{
|
||||
BaseCreature bc = (BaseCreature)m;
|
||||
|
||||
if (bc.NoHouseRestrictions)
|
||||
return true;
|
||||
|
||||
|
|
@ -3425,57 +3375,43 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from))
|
||||
return;
|
||||
|
||||
if (targeted is Item)
|
||||
if (targeted is Item item)
|
||||
{
|
||||
if (m_Release)
|
||||
{
|
||||
#region Mondain's legacy
|
||||
|
||||
if (targeted is AddonContainerComponent)
|
||||
if (item is AddonContainerComponent component)
|
||||
{
|
||||
AddonContainerComponent component = (AddonContainerComponent)targeted;
|
||||
|
||||
if (component.Addon != null)
|
||||
m_House.Release(from, component.Addon);
|
||||
}
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
{
|
||||
m_House.Release(from, (Item)targeted);
|
||||
m_House.Release(from, item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targeted is VendorRentalContract)
|
||||
if (item is VendorRentalContract)
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
|
||||
1062392); // You must double click the contract in your pack to lock it down.
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 501732); // I cannot lock this down!
|
||||
}
|
||||
else if ((Item)targeted is AddonComponent)
|
||||
else if (item is AddonComponent)
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 501727); // You cannot lock that down!
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 501732); // I cannot lock this down!
|
||||
}
|
||||
else
|
||||
{
|
||||
#region Mondain's legacy
|
||||
|
||||
if (targeted is AddonContainerComponent)
|
||||
if (item is AddonContainerComponent component)
|
||||
{
|
||||
AddonContainerComponent component = (AddonContainerComponent)targeted;
|
||||
|
||||
if (component.Addon != null)
|
||||
m_House.LockDown(from, component.Addon);
|
||||
}
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
{
|
||||
m_House.LockDown(from, (Item)targeted);
|
||||
m_House.LockDown(from, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3513,30 +3449,23 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from))
|
||||
return;
|
||||
|
||||
if (targeted is Item)
|
||||
if (targeted is Item item)
|
||||
{
|
||||
if (m_Release)
|
||||
{
|
||||
#region Mondain's legacy
|
||||
|
||||
if (targeted is AddonContainerComponent)
|
||||
if (item is AddonContainerComponent component)
|
||||
{
|
||||
AddonContainerComponent component = (AddonContainerComponent)targeted;
|
||||
|
||||
if (component.Addon != null)
|
||||
m_House.ReleaseSecure(from, component.Addon);
|
||||
}
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
{
|
||||
m_House.ReleaseSecure(from, (Item)targeted);
|
||||
m_House.ReleaseSecure(from, item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targeted is VendorRentalContract)
|
||||
if (item is VendorRentalContract)
|
||||
{
|
||||
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
|
||||
1062392); // You must double click the contract in your pack to lock it down.
|
||||
|
|
@ -3544,21 +3473,14 @@ namespace Server.Multis
|
|||
}
|
||||
else
|
||||
{
|
||||
#region Mondain's legacy
|
||||
|
||||
if (targeted is AddonContainerComponent)
|
||||
if (item is AddonContainerComponent component)
|
||||
{
|
||||
AddonContainerComponent component = (AddonContainerComponent)targeted;
|
||||
|
||||
if (component.Addon != null)
|
||||
m_House.AddSecure(from, component.Addon);
|
||||
}
|
||||
else
|
||||
|
||||
#endregion
|
||||
|
||||
{
|
||||
m_House.AddSecure(from, (Item)targeted);
|
||||
m_House.AddSecure(from, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3586,8 +3508,8 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from))
|
||||
return;
|
||||
|
||||
if (targeted is Mobile)
|
||||
m_House.Kick(from, (Mobile)targeted);
|
||||
if (targeted is Mobile mobile)
|
||||
m_House.Kick(from, mobile);
|
||||
else
|
||||
from.SendLocalizedMessage(501347); //You cannot eject that from the house!
|
||||
}
|
||||
|
|
@ -3611,12 +3533,12 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from))
|
||||
return;
|
||||
|
||||
if (targeted is Mobile)
|
||||
if (targeted is Mobile mobile)
|
||||
{
|
||||
if (m_Banning)
|
||||
m_House.Ban(from, (Mobile)targeted);
|
||||
m_House.Ban(from, mobile);
|
||||
else
|
||||
m_House.RemoveBan(from, (Mobile)targeted);
|
||||
m_House.RemoveBan(from, mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3641,8 +3563,8 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsFriend(from))
|
||||
return;
|
||||
|
||||
if (targeted is Mobile)
|
||||
m_House.GrantAccess(from, (Mobile)targeted);
|
||||
if (targeted is Mobile mobile)
|
||||
m_House.GrantAccess(from, mobile);
|
||||
else
|
||||
from.SendLocalizedMessage(1060712); // That is not a player.
|
||||
}
|
||||
|
|
@ -3666,12 +3588,12 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsOwner(from))
|
||||
return;
|
||||
|
||||
if (targeted is Mobile)
|
||||
if (targeted is Mobile mobile)
|
||||
{
|
||||
if (m_Add)
|
||||
m_House.AddCoOwner(from, (Mobile)targeted);
|
||||
m_House.AddCoOwner(from, mobile);
|
||||
else
|
||||
m_House.RemoveCoOwner(from, (Mobile)targeted);
|
||||
m_House.RemoveCoOwner(from, mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3698,12 +3620,12 @@ namespace Server.Multis
|
|||
if (!from.Alive || m_House.Deleted || !m_House.IsCoOwner(from))
|
||||
return;
|
||||
|
||||
if (targeted is Mobile)
|
||||
if (targeted is Mobile mobile)
|
||||
{
|
||||
if (m_Add)
|
||||
m_House.AddFriend(from, (Mobile)targeted);
|
||||
m_House.AddFriend(from, mobile);
|
||||
else
|
||||
m_House.RemoveFriend(from, (Mobile)targeted);
|
||||
m_House.RemoveFriend(from, mobile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3725,8 +3647,8 @@ namespace Server.Multis
|
|||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted is Mobile)
|
||||
m_House.BeginConfirmTransfer(from, (Mobile)targeted);
|
||||
if (targeted is Mobile mobile)
|
||||
m_House.BeginConfirmTransfer(from, mobile);
|
||||
else
|
||||
from.SendLocalizedMessage(501384); // Only a player can own a house!
|
||||
}
|
||||
|
|
@ -3759,7 +3681,7 @@ namespace Server.Multis
|
|||
bool isOwned = house.Doors.Contains(item);
|
||||
|
||||
if (!isOwned)
|
||||
isOwned = house is HouseFoundation && ((HouseFoundation)house).IsFixture(item);
|
||||
isOwned = house is HouseFoundation foundation && foundation.IsFixture(item);
|
||||
|
||||
if (!isOwned)
|
||||
isOwned = house.HasLockedDownItem(item);
|
||||
|
|
|
|||
|
|
@ -231,9 +231,7 @@ namespace Server.Multis
|
|||
|
||||
for (int i = 0; i < sector.Multis.Count; i++)
|
||||
{
|
||||
BaseBoat boat = sector.Multis[i] as BaseBoat;
|
||||
|
||||
if (boat != null && boat.Contains(loc.X, loc.Y))
|
||||
if (sector.Multis[i] is BaseBoat boat && boat.Contains(loc.X, loc.Y))
|
||||
return boat;
|
||||
}
|
||||
|
||||
|
|
@ -1521,19 +1519,15 @@ namespace Server.Multis
|
|||
}
|
||||
|
||||
foreach (IEntity e in toMove)
|
||||
if (e is Item)
|
||||
if (e is Item item)
|
||||
{
|
||||
Item item = (Item)e;
|
||||
|
||||
item.NoMoveHS = true;
|
||||
|
||||
if (!(item is TillerMan || item is Hold || item is Plank))
|
||||
item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z);
|
||||
}
|
||||
else if (e is Mobile)
|
||||
else if (e is Mobile m)
|
||||
{
|
||||
Mobile m = (Mobile)e;
|
||||
|
||||
m.NoMoveHS = true;
|
||||
m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z);
|
||||
}
|
||||
|
|
@ -1542,10 +1536,10 @@ namespace Server.Multis
|
|||
Location = new Point3D(X + xOffset, Y + yOffset, Z);
|
||||
|
||||
foreach (IEntity e in toMove)
|
||||
if (e is Item)
|
||||
((Item)e).NoMoveHS = false;
|
||||
else if (e is Mobile)
|
||||
((Mobile)e).NoMoveHS = false;
|
||||
if (e is Item item)
|
||||
item.NoMoveHS = false;
|
||||
else if (e is Mobile mobile)
|
||||
mobile.NoMoveHS = false;
|
||||
|
||||
NoMoveHS = false;
|
||||
}
|
||||
|
|
@ -1567,16 +1561,12 @@ namespace Server.Multis
|
|||
{
|
||||
IEntity e = toMove[i];
|
||||
|
||||
if (e is Item)
|
||||
if (e is Item item)
|
||||
{
|
||||
Item item = (Item)e;
|
||||
|
||||
item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z + zOffset);
|
||||
}
|
||||
else if (e is Mobile)
|
||||
else if (e is Mobile m)
|
||||
{
|
||||
Mobile m = (Mobile)e;
|
||||
|
||||
m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z + zOffset);
|
||||
}
|
||||
}
|
||||
|
|
@ -1595,23 +1585,19 @@ namespace Server.Multis
|
|||
|
||||
MultiComponentList mcl = Components;
|
||||
|
||||
foreach (object o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))
|
||||
foreach (IEntity o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))
|
||||
)
|
||||
{
|
||||
if (o == this || o is TillerMan || o is Hold || o is Plank)
|
||||
continue;
|
||||
|
||||
if (o is Item)
|
||||
if (o is Item item)
|
||||
{
|
||||
Item item = (Item)o;
|
||||
|
||||
if (Contains(item) && item.Visible && item.Z >= Z)
|
||||
list.Add(item);
|
||||
}
|
||||
else if (o is Mobile)
|
||||
else if (o is Mobile m)
|
||||
{
|
||||
Mobile m = (Mobile)o;
|
||||
|
||||
if (Contains(m))
|
||||
list.Add(m);
|
||||
}
|
||||
|
|
@ -1679,16 +1665,12 @@ namespace Server.Multis
|
|||
{
|
||||
IEntity e = toMove[i];
|
||||
|
||||
if (e is Item)
|
||||
if (e is Item item)
|
||||
{
|
||||
Item item = (Item)e;
|
||||
|
||||
item.Location = Rotate(item.Location, count);
|
||||
}
|
||||
else if (e is Mobile)
|
||||
else if (e is Mobile m)
|
||||
{
|
||||
Mobile m = (Mobile)e;
|
||||
|
||||
m.Direction = (m.Direction - old + facing) & Direction.Mask;
|
||||
m.Location = Rotate(m.Location, count);
|
||||
}
|
||||
|
|
@ -1894,10 +1876,8 @@ namespace Server.Multis
|
|||
m_Stream.Write((byte)0xF3);
|
||||
m_Stream.Write((short)0x1);
|
||||
|
||||
if (ent is BaseMulti)
|
||||
if (ent is BaseMulti bm)
|
||||
{
|
||||
BaseMulti bm = (BaseMulti)ent;
|
||||
|
||||
m_Stream.Write((byte)0x02);
|
||||
m_Stream.Write(bm.Serial);
|
||||
// TODO: Mask no longer needed, merge with Item case?
|
||||
|
|
@ -1915,10 +1895,8 @@ namespace Server.Multis
|
|||
m_Stream.Write((short)bm.Hue);
|
||||
m_Stream.Write((byte)bm.GetPacketFlags());
|
||||
}
|
||||
else if (ent is Mobile)
|
||||
else if (ent is Mobile m)
|
||||
{
|
||||
Mobile m = (Mobile)ent;
|
||||
|
||||
m_Stream.Write((byte)0x01);
|
||||
m_Stream.Write(m.Serial);
|
||||
m_Stream.Write((short)m.Body);
|
||||
|
|
@ -1935,10 +1913,8 @@ namespace Server.Multis
|
|||
m_Stream.Write((short)m.Hue);
|
||||
m_Stream.Write((byte)m.GetPacketFlags());
|
||||
}
|
||||
else if (ent is Item)
|
||||
else if (ent is Item item)
|
||||
{
|
||||
Item item = (Item)ent;
|
||||
|
||||
m_Stream.Write((byte)0x00);
|
||||
m_Stream.Write(item.Serial);
|
||||
m_Stream.Write((ushort)(item.ItemID & 0xFFFF));
|
||||
|
|
|
|||
|
|
@ -153,12 +153,10 @@ namespace Server.Multis
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
IPoint3D ip = o as IPoint3D;
|
||||
|
||||
if (ip != null)
|
||||
if (o is IPoint3D ip)
|
||||
{
|
||||
if (ip is Item)
|
||||
ip = ((Item)ip).GetWorldTop();
|
||||
if (ip is Item item)
|
||||
ip = item.GetWorldTop();
|
||||
|
||||
Point3D p = new Point3D(ip);
|
||||
|
||||
|
|
|
|||
|
|
@ -172,12 +172,10 @@ namespace Server.Multis
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
IPoint3D ip = o as IPoint3D;
|
||||
|
||||
if (ip != null)
|
||||
if (o is IPoint3D ip)
|
||||
{
|
||||
if (ip is Item)
|
||||
ip = ((Item)ip).GetWorldTop();
|
||||
if (ip is Item item)
|
||||
ip = item.GetWorldTop();
|
||||
|
||||
Point3D p = new Point3D(ip);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,17 +97,17 @@ namespace Server.Misc
|
|||
|
||||
object surface = map.GetTopSurface(from.Location);
|
||||
|
||||
if (surface is LandTile)
|
||||
if (surface is LandTile tile)
|
||||
{
|
||||
int id = ((LandTile)surface).ID;
|
||||
int id = tile.ID;
|
||||
|
||||
return id >= 168 && id <= 171
|
||||
|| id >= 310 && id <= 311;
|
||||
}
|
||||
|
||||
if (surface is StaticTile)
|
||||
if (surface is StaticTile staticTile)
|
||||
{
|
||||
int id = ((StaticTile)surface).ID;
|
||||
int id = staticTile.ID;
|
||||
|
||||
return id >= 0x1796 && id <= 0x17B2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ namespace Server.Items
|
|||
|
||||
public override bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
if (dropped is MapItem && m_Boat != null && m_Boat.CanCommand(from) && m_Boat.Contains(from))
|
||||
m_Boat.AssociateMap((MapItem)dropped);
|
||||
if (dropped is MapItem item && m_Boat != null && m_Boat.CanCommand(from) && m_Boat.Contains(from))
|
||||
m_Boat.AssociateMap(item);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,15 +80,14 @@ namespace Server.Multis
|
|||
|
||||
int zavg = Map.GetAverageZ(X + xOffset, Y + yOffset);
|
||||
Point3D loc = new Point3D(X + xOffset, Y + yOffset, zavg + zOffset);
|
||||
BaseCreature bc = m as BaseCreature;
|
||||
|
||||
if (bc != null)
|
||||
if (m is BaseCreature bc)
|
||||
{
|
||||
bc.RangeHome = wanderRange;
|
||||
bc.Home = loc;
|
||||
}
|
||||
|
||||
if (m is BaseVendor || m is Banker)
|
||||
if (m is BaseVendor)
|
||||
m.Direction = Direction.South;
|
||||
|
||||
m.MoveToWorld(loc, Map);
|
||||
|
|
|
|||
|
|
@ -235,8 +235,8 @@ namespace Server.Multis
|
|||
|
||||
public int GetInt32(object obj)
|
||||
{
|
||||
if (obj is int)
|
||||
return (int)obj;
|
||||
if (obj is int i)
|
||||
return i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,10 @@ namespace Server.Multis.Deeds
|
|||
|
||||
protected override void OnTarget(Mobile from, object o)
|
||||
{
|
||||
IPoint3D ip = o as IPoint3D;
|
||||
|
||||
if (ip != null)
|
||||
if (o is IPoint3D ip)
|
||||
{
|
||||
if (ip is Item)
|
||||
ip = ((Item)ip).GetWorldTop();
|
||||
if (ip is Item item)
|
||||
ip = item.GetWorldTop();
|
||||
|
||||
Point3D p = new Point3D(ip);
|
||||
|
||||
|
|
@ -139,9 +137,8 @@ namespace Server.Multis.Deeds
|
|||
}
|
||||
else
|
||||
{
|
||||
ArrayList toMove;
|
||||
Point3D center = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);
|
||||
HousePlacementResult res = HousePlacement.Check(from, MultiID, center, out toMove);
|
||||
HousePlacementResult res = HousePlacement.Check(from, MultiID, center, out ArrayList toMove);
|
||||
|
||||
switch (res)
|
||||
{
|
||||
|
|
@ -155,10 +152,10 @@ namespace Server.Multis.Deeds
|
|||
{
|
||||
object o = toMove[i];
|
||||
|
||||
if (o is Mobile)
|
||||
((Mobile)o).Location = house.BanLocation;
|
||||
else if (o is Item)
|
||||
((Item)o).Location = house.BanLocation;
|
||||
if (o is Mobile mobile)
|
||||
mobile.Location = house.BanLocation;
|
||||
else if (o is Item item)
|
||||
item.Location = house.BanLocation;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -538,25 +538,19 @@ namespace Server.Multis
|
|||
{
|
||||
Item fixture = Fixtures[i];
|
||||
|
||||
if (fixture is HouseTeleporter)
|
||||
if (fixture is HouseTeleporter tp)
|
||||
{
|
||||
HouseTeleporter tp = (HouseTeleporter)fixture;
|
||||
|
||||
for (int j = 1; j <= Fixtures.Count; ++j)
|
||||
{
|
||||
HouseTeleporter check = Fixtures[(i + j) % Fixtures.Count] as HouseTeleporter;
|
||||
|
||||
if (check != null && check.ItemID == tp.ItemID)
|
||||
if (Fixtures[(i + j) % Fixtures.Count] is HouseTeleporter check && check.ItemID == tp.ItemID)
|
||||
{
|
||||
tp.Target = check;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fixture is BaseHouseDoor)
|
||||
else if (fixture is BaseHouseDoor door)
|
||||
{
|
||||
BaseHouseDoor door = (BaseHouseDoor)fixture;
|
||||
|
||||
if (door.Link != null)
|
||||
continue;
|
||||
|
||||
|
|
@ -630,9 +624,7 @@ namespace Server.Multis
|
|||
|
||||
for (int j = i + 1; j < Fixtures.Count; ++j)
|
||||
{
|
||||
BaseHouseDoor check = Fixtures[j] as BaseHouseDoor;
|
||||
|
||||
if (check != null && check.Link == null && check.Facing == linkFacing &&
|
||||
if (Fixtures[j] is BaseHouseDoor check && check.Link == null && check.Facing == linkFacing &&
|
||||
check.X - door.X == xOffset && check.Y - door.Y == yOffset && check.Z == door.Z)
|
||||
{
|
||||
check.Link = door;
|
||||
|
|
@ -725,9 +717,7 @@ namespace Server.Multis
|
|||
|
||||
public static void ApplyFoundation(FoundationType type, MultiComponentList mcl)
|
||||
{
|
||||
int east, south, post, corner;
|
||||
|
||||
GetFoundationGraphics(type, out east, out south, out post, out corner);
|
||||
GetFoundationGraphics(type, out int east, out int south, out int post, out int corner);
|
||||
|
||||
int xCenter = mcl.Center.X;
|
||||
int yCenter = mcl.Center.Y;
|
||||
|
|
@ -834,7 +824,8 @@ namespace Server.Multis
|
|||
|
||||
public void BeginCustomize(Mobile m)
|
||||
{
|
||||
if (!m.CheckAlive()) return;
|
||||
if (!m.CheckAlive())
|
||||
return;
|
||||
|
||||
if (SpellHelper.CheckCombat(m))
|
||||
{
|
||||
|
|
@ -1579,6 +1570,7 @@ namespace Server.Multis
|
|||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1706,9 +1698,7 @@ namespace Server.Multis
|
|||
Mobile from = state.Mobile;
|
||||
DesignContext context = DesignContext.Find(from);
|
||||
|
||||
HouseFoundation foundation = World.FindItem(pvSrc.ReadInt32()) as HouseFoundation;
|
||||
|
||||
if (foundation != null && from.Map == foundation.Map && from.InRange(foundation.GetWorldLocation(), 24) &&
|
||||
if (World.FindItem(pvSrc.ReadInt32()) is HouseFoundation foundation && from.Map == foundation.Map && from.InRange(foundation.GetWorldLocation(), 24) &&
|
||||
from.CanSee(foundation))
|
||||
{
|
||||
DesignState stateToSend;
|
||||
|
|
@ -2139,8 +2129,8 @@ namespace Server.Multis
|
|||
|
||||
Table[from] = c;
|
||||
|
||||
if (from is PlayerMobile)
|
||||
((PlayerMobile)from).DesignContext = c;
|
||||
if (from is PlayerMobile pm)
|
||||
pm.DesignContext = c;
|
||||
|
||||
foundation.Customizer = from;
|
||||
|
||||
|
|
@ -2180,11 +2170,8 @@ namespace Server.Multis
|
|||
|
||||
Table.Remove(from);
|
||||
|
||||
if (from is PlayerMobile)
|
||||
((PlayerMobile)from).DesignContext = null;
|
||||
|
||||
if (context == null)
|
||||
return;
|
||||
if (from is PlayerMobile pm)
|
||||
pm.DesignContext = null;
|
||||
|
||||
context.Foundation.Customizer = null;
|
||||
|
||||
|
|
@ -2437,7 +2424,7 @@ namespace Server.Multis
|
|||
|
||||
++planeCount;
|
||||
|
||||
int size = 0;
|
||||
int size;
|
||||
|
||||
if (i == 0)
|
||||
size = width * height * 2;
|
||||
|
|
@ -2573,7 +2560,7 @@ namespace Server.Multis
|
|||
|
||||
while (count > 0)
|
||||
{
|
||||
SendQueueEntry sqe = null;
|
||||
SendQueueEntry sqe;
|
||||
|
||||
lock (m_SendQueueSyncRoot)
|
||||
{
|
||||
|
|
@ -2582,7 +2569,7 @@ namespace Server.Multis
|
|||
|
||||
try
|
||||
{
|
||||
Packet p = null;
|
||||
Packet p;
|
||||
|
||||
lock (sqe.m_Root)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -234,12 +234,10 @@ namespace Server.Items
|
|||
if (!from.CheckAlive() || from.Backpack?.FindItemByType<HousePlacementTool>() == null)
|
||||
return;
|
||||
|
||||
IPoint3D ip = o as IPoint3D;
|
||||
|
||||
if (ip != null)
|
||||
if (o is IPoint3D ip)
|
||||
{
|
||||
if (ip is Item)
|
||||
ip = ((Item)ip).GetWorldTop();
|
||||
if (ip is Item item)
|
||||
ip = item.GetWorldTop();
|
||||
|
||||
Point3D p = new Point3D(ip);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue