Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -44,7 +44,8 @@ namespace Server.Engines.Events
|
|||
|
||||
public static void RemoveHueMod(Mobile target)
|
||||
{
|
||||
if (target != null && !target.Deleted) target.SolidHueOverride = -1;
|
||||
if (target?.Deleted == false)
|
||||
target.SolidHueOverride = -1;
|
||||
}
|
||||
|
||||
public static void SolidHueMobile(Mobile target)
|
||||
|
|
@ -67,7 +68,7 @@ namespace Server.Engines.Events
|
|||
|
||||
if (twin.Deleted)
|
||||
return;
|
||||
|
||||
|
||||
foreach (Item item in m_From.Items)
|
||||
if (item.Layer != Layer.Backpack && item.Layer != Layer.Mount && item.Layer != Layer.Bank)
|
||||
m_Items.Add(item);
|
||||
|
|
@ -122,78 +123,80 @@ namespace Server.Engines.Events
|
|||
|
||||
protected override void OnTarget(Mobile from, object targ)
|
||||
{
|
||||
if (targ != null && CheckMobile(from))
|
||||
if (targ == null || !CheckMobile(from))
|
||||
return;
|
||||
|
||||
if (!(targ is Mobile))
|
||||
{
|
||||
if (!(targ is Mobile))
|
||||
from.SendLocalizedMessage(1076781); /* There is little chance of getting candy from that! */
|
||||
return;
|
||||
}
|
||||
|
||||
BaseVendor begged = targ as BaseVendor;
|
||||
|
||||
if (begged?.Deleted != false)
|
||||
{
|
||||
from.SendLocalizedMessage(1076765); /* That doesn't look friendly. */
|
||||
return;
|
||||
}
|
||||
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
|
||||
|
||||
if (CheckMobile(begged))
|
||||
{
|
||||
if (begged.NextTrickOrTreat > now)
|
||||
{
|
||||
from.SendLocalizedMessage(1076781); /* There is little chance of getting candy from that! */
|
||||
from.SendLocalizedMessage(1076767); /* That doesn't appear to have any more candy. */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(targ is BaseVendor) || ((BaseVendor)targ).Deleted)
|
||||
{
|
||||
from.SendLocalizedMessage(1076765); /* That doesn't look friendly. */
|
||||
begged.NextTrickOrTreat = now + TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10));
|
||||
|
||||
if (from.Backpack?.Deleted != false)
|
||||
return;
|
||||
}
|
||||
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
BaseVendor m_Begged = targ as BaseVendor;
|
||||
|
||||
if (CheckMobile(m_Begged))
|
||||
if (Utility.RandomDouble() > .10)
|
||||
{
|
||||
if (m_Begged.NextTrickOrTreat > now)
|
||||
switch (Utility.Random(3))
|
||||
{
|
||||
from.SendLocalizedMessage(1076767); /* That doesn't appear to have any more candy. */
|
||||
return;
|
||||
case 0:
|
||||
begged.Say(1076768);
|
||||
break; /* Oooooh, aren't you cute! */
|
||||
case 1:
|
||||
begged.Say(1076779);
|
||||
break; /* All right...This better not spoil your dinner! */
|
||||
case 2:
|
||||
begged.Say(1076778);
|
||||
break; /* Here you go! Enjoy! */
|
||||
}
|
||||
|
||||
m_Begged.NextTrickOrTreat = now + TimeSpan.FromMinutes(Utility.RandomMinMax(5, 10));
|
||||
|
||||
if (from.Backpack != null && !from.Backpack.Deleted)
|
||||
if (Utility.RandomDouble() <= .01 && from.Skills.Begging.Value >= 100)
|
||||
{
|
||||
if (Utility.RandomDouble() > .10)
|
||||
{
|
||||
switch (Utility.Random(3))
|
||||
{
|
||||
case 0:
|
||||
m_Begged.Say(1076768);
|
||||
break; /* Oooooh, aren't you cute! */
|
||||
case 1:
|
||||
m_Begged.Say(1076779);
|
||||
break; /* All right...This better not spoil your dinner! */
|
||||
case 2:
|
||||
m_Begged.Say(1076778);
|
||||
break; /* Here you go! Enjoy! */
|
||||
}
|
||||
from.AddToBackpack(HolidaySettings.RandomGMBeggerItem);
|
||||
|
||||
if (Utility.RandomDouble() <= .01 && from.Skills.Begging.Value >= 100)
|
||||
{
|
||||
from.AddToBackpack(HolidaySettings.RandomGMBeggerItem);
|
||||
|
||||
from.SendLocalizedMessage(1076777); /* You receive a special treat! */
|
||||
}
|
||||
else
|
||||
{
|
||||
from.AddToBackpack(HolidaySettings.RandomTreat);
|
||||
|
||||
from.SendLocalizedMessage(1076769); /* You receive some candy. */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Begged.Say(1076770); /* TRICK! */
|
||||
|
||||
int action = Utility.Random(4);
|
||||
|
||||
if (action == 0)
|
||||
Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from);
|
||||
else if (action == 1)
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from);
|
||||
else
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from);
|
||||
}
|
||||
from.SendLocalizedMessage(1076777); /* You receive a special treat! */
|
||||
}
|
||||
else
|
||||
{
|
||||
from.AddToBackpack(HolidaySettings.RandomTreat);
|
||||
|
||||
from.SendLocalizedMessage(1076769); /* You receive some candy. */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
begged.Say(1076770); /* TRICK! */
|
||||
|
||||
int action = Utility.Random(4);
|
||||
|
||||
if (action == 0)
|
||||
Timer.DelayCall(OneSecond, OneSecond, 10, Bleeding, from);
|
||||
else if (action == 1)
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), SolidHueMobile, from);
|
||||
else
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2), MakeTwin, from);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -263,7 +266,8 @@ namespace Server.Engines.Events
|
|||
|
||||
public override void OnThink()
|
||||
{
|
||||
if (m_From == null || m_From.Deleted) Delete();
|
||||
if (m_From?.Deleted != false)
|
||||
Delete();
|
||||
}
|
||||
|
||||
public static Item FindCandyTypes(Mobile target)
|
||||
|
|
@ -287,7 +291,7 @@ namespace Server.Engines.Events
|
|||
|
||||
target.SendLocalizedMessage(1113967); /* Your naughty twin steals some of your candy. */
|
||||
|
||||
if (item != null && !item.Deleted)
|
||||
if (item?.Deleted == false)
|
||||
item.Delete();
|
||||
}
|
||||
else
|
||||
|
|
@ -321,4 +325,4 @@ namespace Server.Engines.Events
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Events.Halloween;
|
||||
using Server.Items;
|
||||
|
||||
|
|
@ -41,18 +42,10 @@ namespace Server.Engines.Events
|
|||
Rectangle2D rect = m_PumpkinFields[i];
|
||||
|
||||
int spawncount = rect.Height * rect.Width / 20;
|
||||
int pumpkins = 0;
|
||||
|
||||
foreach (Item item in map.GetItemsInBounds(rect))
|
||||
if (item is HalloweenPumpkin)
|
||||
pumpkins++;
|
||||
int pumpkins = map.GetItemsInBounds(rect).OfType<HalloweenPumpkin>().Count();
|
||||
|
||||
if (spawncount > pumpkins)
|
||||
{
|
||||
Item item = new HalloweenPumpkin();
|
||||
|
||||
item.MoveToWorld(RandomPointIn(rect, map), map);
|
||||
}
|
||||
new HalloweenPumpkin().MoveToWorld(RandomPointIn(rect, map), map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,4 +58,4 @@ namespace Server.Engines.Events
|
|||
return new Point3D(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
public class CreepyCake : Food
|
||||
{
|
||||
[Constructible]
|
||||
public CreepyCake()
|
||||
: base(0x9e9)
|
||||
public CreepyCake() : base(0x9e9, 1)
|
||||
{
|
||||
Hue = 0x3E4;
|
||||
}
|
||||
|
|
@ -35,4 +34,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
public class MrPlainsCookies : Food
|
||||
{
|
||||
[Constructible]
|
||||
public MrPlainsCookies()
|
||||
: base(0x160C)
|
||||
public MrPlainsCookies() : base(0x160C, 1)
|
||||
{
|
||||
Weight = 1.0;
|
||||
FillFactor = 4;
|
||||
|
|
@ -32,4 +31,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ namespace Server.Items.Holiday
|
|||
{
|
||||
get
|
||||
{
|
||||
if (m_Staffer != null) return $"{MaskName} hand painted by {m_Staffer}";
|
||||
|
||||
return MaskName;
|
||||
return m_Staffer != null ? $"{MaskName} hand painted by {m_Staffer}" : MaskName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,10 +87,9 @@ namespace Server.Mobiles
|
|||
|
||||
public virtual void Lifted_Callback(Mobile from)
|
||||
{
|
||||
if (from != null && !from.Deleted && from is PlayerMobile)
|
||||
if (from?.Deleted == false && from is PlayerMobile)
|
||||
{
|
||||
Combatant = from;
|
||||
|
||||
Warmode = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -127,4 +126,4 @@ namespace Server.Mobiles
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace Server.Engines.Events
|
|||
new Rectangle2D(4528,1314,28,20), // Moonglow
|
||||
new Rectangle2D(712,1104,22,30), // Yew
|
||||
new Rectangle2D(5824,1464,6,22), // Fire Dungeon
|
||||
new Rectangle2D(5224,3655,5,14), // T2A
|
||||
new Rectangle2D(5224,3655,5,14) // T2A
|
||||
};
|
||||
|
||||
public static void Initialize()
|
||||
|
|
@ -98,7 +98,7 @@ namespace Server.Engines.Events
|
|||
}
|
||||
}
|
||||
|
||||
if ( player != null && !player.Deleted && ReAnimated.Count < m_TotalZombieLimit )
|
||||
if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit )
|
||||
{
|
||||
Map map = Utility.RandomBool() ? Map.Trammel : Map.Felucca;
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ namespace Server.Engines.Events
|
|||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
writer.Write( ( int )0 );
|
||||
writer.Write( 0 );
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
|
|
@ -175,17 +175,12 @@ namespace Server.Engines.Events
|
|||
|
||||
private PlayerMobile m_DeadPlayer;
|
||||
|
||||
public ZombieSkeleton()
|
||||
: this( null )
|
||||
{
|
||||
}
|
||||
|
||||
public ZombieSkeleton( PlayerMobile player )
|
||||
public ZombieSkeleton(PlayerMobile player = null)
|
||||
: base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 )
|
||||
{
|
||||
m_DeadPlayer = player;
|
||||
|
||||
Name = ( player != null ) ? $"{player.Name}'s {m_Name}" : m_Name;
|
||||
Name = player != null ? $"{player.Name}'s {m_Name}" : m_Name;
|
||||
|
||||
Body = 0x93;
|
||||
BaseSoundID = 0x1c3;
|
||||
|
|
@ -228,7 +223,7 @@ namespace Server.Engines.Events
|
|||
case 2: PackItem( new Torso() ); break;
|
||||
case 3: PackItem( new Bone() ); break;
|
||||
case 4: PackItem( new RibCage() ); break;
|
||||
case 5: if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted ) { PackItem( new PlayerBones( m_DeadPlayer.Name ) ); } break;
|
||||
case 5: if (m_DeadPlayer?.Deleted == false) { PackItem( new PlayerBones( m_DeadPlayer.Name ) ); } break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +243,7 @@ namespace Server.Engines.Events
|
|||
{
|
||||
if ( HalloweenHauntings.ReAnimated != null )
|
||||
{
|
||||
if ( m_DeadPlayer != null && !m_DeadPlayer.Deleted )
|
||||
if (m_DeadPlayer?.Deleted == false)
|
||||
{
|
||||
if ( HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) )
|
||||
HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer );
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@
|
|||
{
|
||||
public class JellyBeans : CandyCane
|
||||
{
|
||||
[Constructible]
|
||||
public JellyBeans()
|
||||
: this(1)
|
||||
{
|
||||
}
|
||||
|
||||
public JellyBeans(int amount)
|
||||
public JellyBeans(int amount = 1)
|
||||
: base(0x468C)
|
||||
{
|
||||
Stackable = true;
|
||||
|
|
@ -35,4 +29,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,7 @@
|
|||
public class Lollipops : CandyCane
|
||||
{
|
||||
[Constructible]
|
||||
public Lollipops()
|
||||
: this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Lollipops(int amount)
|
||||
public Lollipops(int amount = 1)
|
||||
: base(0x468D + Utility.Random(3))
|
||||
{
|
||||
Stackable = true;
|
||||
|
|
@ -35,4 +29,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@
|
|||
public class NougatSwirl : CandyCane
|
||||
{
|
||||
[Constructible]
|
||||
public NougatSwirl() : this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public NougatSwirl(int amount)
|
||||
public NougatSwirl(int amount = 1)
|
||||
: base(0x4690)
|
||||
{
|
||||
Stackable = true;
|
||||
|
|
@ -35,4 +30,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@
|
|||
{
|
||||
public class Taffy : CandyCane
|
||||
{
|
||||
[Constructible]
|
||||
public Taffy()
|
||||
: this(1)
|
||||
{
|
||||
}
|
||||
|
||||
public Taffy(int amount)
|
||||
public Taffy(int amount = 1)
|
||||
: base(0x469D)
|
||||
{
|
||||
Stackable = true;
|
||||
|
|
@ -35,4 +29,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@
|
|||
{
|
||||
public class WrappedCandy : CandyCane
|
||||
{
|
||||
[Constructible]
|
||||
public WrappedCandy()
|
||||
: this(1)
|
||||
{
|
||||
}
|
||||
|
||||
public WrappedCandy(int amount)
|
||||
public WrappedCandy(int amount = 1)
|
||||
: base(0x469e)
|
||||
{
|
||||
Stackable = true;
|
||||
|
|
@ -35,4 +29,4 @@
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue