Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -3,182 +3,182 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Server.Engines.Plants
|
||||
{
|
||||
[Flags]
|
||||
public enum PlantHue
|
||||
{
|
||||
Plain = 0x1 | Crossable | Reproduces,
|
||||
[Flags]
|
||||
public enum PlantHue
|
||||
{
|
||||
Plain = 0x1 | Crossable | Reproduces,
|
||||
|
||||
Red = 0x2 | Crossable | Reproduces,
|
||||
Blue = 0x4 | Crossable | Reproduces,
|
||||
Yellow = 0x8 | Crossable | Reproduces,
|
||||
Red = 0x2 | Crossable | Reproduces,
|
||||
Blue = 0x4 | Crossable | Reproduces,
|
||||
Yellow = 0x8 | Crossable | Reproduces,
|
||||
|
||||
BrightRed = Red | Bright,
|
||||
BrightBlue = Blue | Bright,
|
||||
BrightYellow = Yellow | Bright,
|
||||
BrightRed = Red | Bright,
|
||||
BrightBlue = Blue | Bright,
|
||||
BrightYellow = Yellow | Bright,
|
||||
|
||||
Purple = Red | Blue,
|
||||
Green = Blue | Yellow,
|
||||
Orange = Red | Yellow,
|
||||
Purple = Red | Blue,
|
||||
Green = Blue | Yellow,
|
||||
Orange = Red | Yellow,
|
||||
|
||||
BrightPurple = Purple | Bright,
|
||||
BrightGreen = Green | Bright,
|
||||
BrightOrange = Orange | Bright,
|
||||
BrightPurple = Purple | Bright,
|
||||
BrightGreen = Green | Bright,
|
||||
BrightOrange = Orange | Bright,
|
||||
|
||||
Black = 0x10,
|
||||
White = 0x20,
|
||||
Pink = 0x40,
|
||||
Magenta = 0x80,
|
||||
Aqua = 0x100,
|
||||
FireRed = 0x200,
|
||||
Black = 0x10,
|
||||
White = 0x20,
|
||||
Pink = 0x40,
|
||||
Magenta = 0x80,
|
||||
Aqua = 0x100,
|
||||
FireRed = 0x200,
|
||||
|
||||
None = 0,
|
||||
Reproduces = 0x2000000,
|
||||
Crossable = 0x4000000,
|
||||
Bright = 0x8000000
|
||||
}
|
||||
None = 0,
|
||||
Reproduces = 0x2000000,
|
||||
Crossable = 0x4000000,
|
||||
Bright = 0x8000000
|
||||
}
|
||||
|
||||
public class PlantHueInfo
|
||||
{
|
||||
private static Dictionary<PlantHue, PlantHueInfo> m_Table;
|
||||
public class PlantHueInfo
|
||||
{
|
||||
private static Dictionary<PlantHue, PlantHueInfo> m_Table;
|
||||
|
||||
static PlantHueInfo()
|
||||
{
|
||||
m_Table = new Dictionary<PlantHue, PlantHueInfo>();
|
||||
static PlantHueInfo()
|
||||
{
|
||||
m_Table = new Dictionary<PlantHue, PlantHueInfo>();
|
||||
|
||||
m_Table[PlantHue.Plain] = new PlantHueInfo( 0, 1060813, PlantHue.Plain, 0x835 );
|
||||
m_Table[PlantHue.Red] = new PlantHueInfo( 0x66D, 1060814, PlantHue.Red, 0x24 );
|
||||
m_Table[PlantHue.Blue] = new PlantHueInfo( 0x53D, 1060815, PlantHue.Blue, 0x6 );
|
||||
m_Table[PlantHue.Yellow] = new PlantHueInfo( 0x8A5, 1060818, PlantHue.Yellow, 0x38 );
|
||||
m_Table[PlantHue.BrightRed] = new PlantHueInfo( 0x21, 1060814, PlantHue.BrightRed, 0x21 );
|
||||
m_Table[PlantHue.BrightBlue] = new PlantHueInfo( 0x5, 1060815, PlantHue.BrightBlue, 0x6 );
|
||||
m_Table[PlantHue.BrightYellow] = new PlantHueInfo( 0x38, 1060818, PlantHue.BrightYellow, 0x35 );
|
||||
m_Table[PlantHue.Purple] = new PlantHueInfo( 0xD, 1060816, PlantHue.Purple, 0x10 );
|
||||
m_Table[PlantHue.Green] = new PlantHueInfo( 0x59B, 1060819, PlantHue.Green, 0x42 );
|
||||
m_Table[PlantHue.Orange] = new PlantHueInfo( 0x46F, 1060817, PlantHue.Orange, 0x2E );
|
||||
m_Table[PlantHue.BrightPurple] = new PlantHueInfo( 0x10, 1060816, PlantHue.BrightPurple, 0xD );
|
||||
m_Table[PlantHue.BrightGreen] = new PlantHueInfo( 0x42, 1060819, PlantHue.BrightGreen, 0x3F );
|
||||
m_Table[PlantHue.BrightOrange] = new PlantHueInfo( 0x2B, 1060817, PlantHue.BrightOrange, 0x2B );
|
||||
m_Table[PlantHue.Black] = new PlantHueInfo( 0x455, 1060820, PlantHue.Black, 0 );
|
||||
m_Table[PlantHue.White] = new PlantHueInfo( 0x481, 1060821, PlantHue.White, 0x481 );
|
||||
m_Table[PlantHue.Pink] = new PlantHueInfo( 0x48E, 1061854, PlantHue.Pink );
|
||||
m_Table[PlantHue.Magenta] = new PlantHueInfo( 0x486, 1061852, PlantHue.Magenta );
|
||||
m_Table[PlantHue.Aqua] = new PlantHueInfo( 0x495, 1061853, PlantHue.Aqua );
|
||||
m_Table[PlantHue.FireRed] = new PlantHueInfo( 0x489, 1061855, PlantHue.FireRed );
|
||||
}
|
||||
m_Table[PlantHue.Plain] = new PlantHueInfo(0, 1060813, PlantHue.Plain, 0x835);
|
||||
m_Table[PlantHue.Red] = new PlantHueInfo(0x66D, 1060814, PlantHue.Red, 0x24);
|
||||
m_Table[PlantHue.Blue] = new PlantHueInfo(0x53D, 1060815, PlantHue.Blue, 0x6);
|
||||
m_Table[PlantHue.Yellow] = new PlantHueInfo(0x8A5, 1060818, PlantHue.Yellow, 0x38);
|
||||
m_Table[PlantHue.BrightRed] = new PlantHueInfo(0x21, 1060814, PlantHue.BrightRed, 0x21);
|
||||
m_Table[PlantHue.BrightBlue] = new PlantHueInfo(0x5, 1060815, PlantHue.BrightBlue, 0x6);
|
||||
m_Table[PlantHue.BrightYellow] = new PlantHueInfo(0x38, 1060818, PlantHue.BrightYellow, 0x35);
|
||||
m_Table[PlantHue.Purple] = new PlantHueInfo(0xD, 1060816, PlantHue.Purple, 0x10);
|
||||
m_Table[PlantHue.Green] = new PlantHueInfo(0x59B, 1060819, PlantHue.Green, 0x42);
|
||||
m_Table[PlantHue.Orange] = new PlantHueInfo(0x46F, 1060817, PlantHue.Orange, 0x2E);
|
||||
m_Table[PlantHue.BrightPurple] = new PlantHueInfo(0x10, 1060816, PlantHue.BrightPurple, 0xD);
|
||||
m_Table[PlantHue.BrightGreen] = new PlantHueInfo(0x42, 1060819, PlantHue.BrightGreen, 0x3F);
|
||||
m_Table[PlantHue.BrightOrange] = new PlantHueInfo(0x2B, 1060817, PlantHue.BrightOrange, 0x2B);
|
||||
m_Table[PlantHue.Black] = new PlantHueInfo(0x455, 1060820, PlantHue.Black, 0);
|
||||
m_Table[PlantHue.White] = new PlantHueInfo(0x481, 1060821, PlantHue.White, 0x481);
|
||||
m_Table[PlantHue.Pink] = new PlantHueInfo(0x48E, 1061854, PlantHue.Pink);
|
||||
m_Table[PlantHue.Magenta] = new PlantHueInfo(0x486, 1061852, PlantHue.Magenta);
|
||||
m_Table[PlantHue.Aqua] = new PlantHueInfo(0x495, 1061853, PlantHue.Aqua);
|
||||
m_Table[PlantHue.FireRed] = new PlantHueInfo(0x489, 1061855, PlantHue.FireRed);
|
||||
}
|
||||
|
||||
public static PlantHueInfo GetInfo( PlantHue plantHue )
|
||||
{
|
||||
if (m_Table.TryGetValue( plantHue, out PlantHueInfo info ))
|
||||
return info;
|
||||
return m_Table[PlantHue.Plain];
|
||||
}
|
||||
private PlantHueInfo(int hue, int name, PlantHue plantHue) : this(hue, name, plantHue, hue)
|
||||
{
|
||||
}
|
||||
|
||||
public static PlantHue RandomFirstGeneration()
|
||||
{
|
||||
switch ( Utility.Random( 4 ) )
|
||||
{
|
||||
case 0: return PlantHue.Plain;
|
||||
case 1: return PlantHue.Red;
|
||||
case 2: return PlantHue.Blue;
|
||||
default: return PlantHue.Yellow;
|
||||
}
|
||||
}
|
||||
private PlantHueInfo(int hue, int name, PlantHue plantHue, int gumpHue)
|
||||
{
|
||||
Hue = hue;
|
||||
Name = name;
|
||||
PlantHue = plantHue;
|
||||
GumpHue = gumpHue;
|
||||
}
|
||||
|
||||
public static bool CanReproduce( PlantHue plantHue )
|
||||
{
|
||||
return (plantHue & PlantHue.Reproduces) != PlantHue.None;
|
||||
}
|
||||
public int Hue{ get; }
|
||||
|
||||
public static bool IsCrossable( PlantHue plantHue )
|
||||
{
|
||||
return (plantHue & PlantHue.Crossable) != PlantHue.None;
|
||||
}
|
||||
public int Name{ get; }
|
||||
|
||||
public static bool IsBright( PlantHue plantHue )
|
||||
{
|
||||
return (plantHue & PlantHue.Bright) != PlantHue.None;
|
||||
}
|
||||
public PlantHue PlantHue{ get; }
|
||||
|
||||
public static PlantHue GetNotBright( PlantHue plantHue )
|
||||
{
|
||||
return plantHue & ~PlantHue.Bright;
|
||||
}
|
||||
public int GumpHue{ get; }
|
||||
|
||||
public static bool IsPrimary( PlantHue plantHue )
|
||||
{
|
||||
return plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow;
|
||||
}
|
||||
public static PlantHueInfo GetInfo(PlantHue plantHue)
|
||||
{
|
||||
if (m_Table.TryGetValue(plantHue, out PlantHueInfo info))
|
||||
return info;
|
||||
return m_Table[PlantHue.Plain];
|
||||
}
|
||||
|
||||
public static PlantHue Cross( PlantHue first, PlantHue second )
|
||||
{
|
||||
if ( !IsCrossable( first ) || !IsCrossable( second ) )
|
||||
return PlantHue.None;
|
||||
public static PlantHue RandomFirstGeneration()
|
||||
{
|
||||
switch (Utility.Random(4))
|
||||
{
|
||||
case 0: return PlantHue.Plain;
|
||||
case 1: return PlantHue.Red;
|
||||
case 2: return PlantHue.Blue;
|
||||
default: return PlantHue.Yellow;
|
||||
}
|
||||
}
|
||||
|
||||
if ( Utility.RandomDouble() < 0.01 )
|
||||
return Utility.RandomBool() ? PlantHue.Black : PlantHue.White;
|
||||
public static bool CanReproduce(PlantHue plantHue)
|
||||
{
|
||||
return (plantHue & PlantHue.Reproduces) != PlantHue.None;
|
||||
}
|
||||
|
||||
if ( first == PlantHue.Plain || second == PlantHue.Plain )
|
||||
return PlantHue.Plain;
|
||||
public static bool IsCrossable(PlantHue plantHue)
|
||||
{
|
||||
return (plantHue & PlantHue.Crossable) != PlantHue.None;
|
||||
}
|
||||
|
||||
PlantHue notBrightFirst = GetNotBright( first );
|
||||
PlantHue notBrightSecond = GetNotBright( second );
|
||||
public static bool IsBright(PlantHue plantHue)
|
||||
{
|
||||
return (plantHue & PlantHue.Bright) != PlantHue.None;
|
||||
}
|
||||
|
||||
if ( notBrightFirst == notBrightSecond )
|
||||
return first | PlantHue.Bright;
|
||||
public static PlantHue GetNotBright(PlantHue plantHue)
|
||||
{
|
||||
return plantHue & ~PlantHue.Bright;
|
||||
}
|
||||
|
||||
bool firstPrimary = IsPrimary( notBrightFirst );
|
||||
bool secondPrimary = IsPrimary( notBrightSecond );
|
||||
public static bool IsPrimary(PlantHue plantHue)
|
||||
{
|
||||
return plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow;
|
||||
}
|
||||
|
||||
if ( firstPrimary && secondPrimary )
|
||||
return notBrightFirst | notBrightSecond;
|
||||
public static PlantHue Cross(PlantHue first, PlantHue second)
|
||||
{
|
||||
if (!IsCrossable(first) || !IsCrossable(second))
|
||||
return PlantHue.None;
|
||||
|
||||
if ( firstPrimary && !secondPrimary )
|
||||
return notBrightFirst;
|
||||
if (Utility.RandomDouble() < 0.01)
|
||||
return Utility.RandomBool() ? PlantHue.Black : PlantHue.White;
|
||||
|
||||
if ( !firstPrimary && secondPrimary )
|
||||
return notBrightSecond;
|
||||
if (first == PlantHue.Plain || second == PlantHue.Plain)
|
||||
return PlantHue.Plain;
|
||||
|
||||
return notBrightFirst & notBrightSecond;
|
||||
}
|
||||
PlantHue notBrightFirst = GetNotBright(first);
|
||||
PlantHue notBrightSecond = GetNotBright(second);
|
||||
|
||||
public int Hue { get; }
|
||||
if (notBrightFirst == notBrightSecond)
|
||||
return first | PlantHue.Bright;
|
||||
|
||||
public int Name { get; }
|
||||
bool firstPrimary = IsPrimary(notBrightFirst);
|
||||
bool secondPrimary = IsPrimary(notBrightSecond);
|
||||
|
||||
public PlantHue PlantHue { get; }
|
||||
if (firstPrimary && secondPrimary)
|
||||
return notBrightFirst | notBrightSecond;
|
||||
|
||||
public int GumpHue { get; }
|
||||
if (firstPrimary && !secondPrimary)
|
||||
return notBrightFirst;
|
||||
|
||||
private PlantHueInfo( int hue, int name, PlantHue plantHue ) : this( hue, name, plantHue, hue )
|
||||
{
|
||||
}
|
||||
if (!firstPrimary && secondPrimary)
|
||||
return notBrightSecond;
|
||||
|
||||
private PlantHueInfo( int hue, int name, PlantHue plantHue, int gumpHue )
|
||||
{
|
||||
Hue = hue;
|
||||
Name = name;
|
||||
PlantHue = plantHue;
|
||||
GumpHue = gumpHue;
|
||||
}
|
||||
return notBrightFirst & notBrightSecond;
|
||||
}
|
||||
|
||||
public bool IsCrossable()
|
||||
{
|
||||
return IsCrossable( PlantHue );
|
||||
}
|
||||
public bool IsCrossable()
|
||||
{
|
||||
return IsCrossable(PlantHue);
|
||||
}
|
||||
|
||||
public bool IsBright()
|
||||
{
|
||||
return IsBright( PlantHue );
|
||||
}
|
||||
public bool IsBright()
|
||||
{
|
||||
return IsBright(PlantHue);
|
||||
}
|
||||
|
||||
public PlantHue GetNotBright()
|
||||
{
|
||||
return GetNotBright( PlantHue );
|
||||
}
|
||||
public PlantHue GetNotBright()
|
||||
{
|
||||
return GetNotBright(PlantHue);
|
||||
}
|
||||
|
||||
public bool IsPrimary()
|
||||
{
|
||||
return IsPrimary( PlantHue );
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool IsPrimary()
|
||||
{
|
||||
return IsPrimary(PlantHue);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue