Code cleanup (#188)

This commit is contained in:
Kamron Batman 2020-08-01 08:40:06 -07:00 committed by GitHub
parent df53c16620
commit 010fd9402a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
185 changed files with 1052 additions and 1271 deletions

View file

@ -44,7 +44,7 @@ namespace Server.Items
public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes,
BaseTool tool, CraftItem craftItem, int resHue)
{
Type resourceType = typeRes ?? craftItem.Resources.GetAt(0).ItemType;
Type resourceType = typeRes ?? craftItem.Resources[0].ItemType;
Resource = CraftResources.GetFromType(resourceType);

View file

@ -1,5 +1,3 @@
using System;
namespace Server.Items
{
public class JackOLantern : BaseAddon
@ -15,18 +13,18 @@ namespace Server.Items
{
AddComponent(new AddonComponent(5703), 0, 0, +0);
int hue = 1161;
const int hue = 1161;
// ( 1 > Utility.Random( 5 ) ? 2118 : 1161 );
if (!south)
{
AddComponent(GetComponent(3178, 0000), 0, 0, -1);
AddComponent(GetComponent(3178, 0), 0, 0, -1);
AddComponent(GetComponent(3883, hue), 0, 0, +1);
AddComponent(GetComponent(3862, hue), 0, 0, +0);
}
else
{
AddComponent(GetComponent(3179, 0000), 0, 0, +0);
AddComponent(GetComponent(3179, 0), 0, 0, +0);
AddComponent(GetComponent(3885, hue), 0, 0, -1);
AddComponent(GetComponent(3871, hue), 0, 0, +0);
}
@ -39,15 +37,12 @@ namespace Server.Items
public override bool ShareHue => false;
private AddonComponent GetComponent(int itemID, int hue)
{
AddonComponent ac = new AddonComponent(itemID);
ac.Hue = hue;
ac.Name = "jack-o-lantern";
return ac;
}
private static AddonComponent GetComponent(int itemID, int hue) =>
new AddonComponent(itemID)
{
Hue = hue,
Name = "jack-o-lantern"
};
public override void Serialize(IGenericWriter writer)
{
@ -62,21 +57,31 @@ namespace Server.Items
int version = reader.ReadByte();
if (version == 0)
Timer.DelayCall(TimeSpan.Zero, () =>
{
for (int i = 0; i < Components.Count; ++i)
if (Components[i] is AddonComponent ac && ac.Hue == 2118)
ac.Hue = 1161;
});
if (version <= 1)
Timer.DelayCall(TimeSpan.Zero, () =>
Timer.DelayCall(Fix, version);
}
private void Fix(int version)
{
for (int i = 0; i < Components.Count; ++i)
{
var ac = Components[i];
switch (version)
{
for (int i = 0; i < Components.Count; ++i)
if (Components[i] is AddonComponent ac)
ac.Name = "jack-o-lantern";
});
case 1:
{
ac.Name = "jack-o-lantern";
goto case 0;
}
case 0:
{
if (ac.Hue == 2118)
ac.Hue = 1161;
break;
}
}
}
}
}
}

View file

@ -38,7 +38,7 @@ namespace Server.Items
SendLocalizedMessageTo(from, 500803); // You feel as though you've slept for days!
}
Timer.DelayCall(TimeSpan.FromHours(2.0), () => ReleaseUseLock_Callback(from, random));
Timer.DelayCall(TimeSpan.FromHours(2.0), ReleaseUseLock_Callback, from, random);
}
}
@ -168,4 +168,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}