Changes properties to use automatic property initializers
This commit is contained in:
parent
f0a48ad431
commit
06fa31a7bf
623 changed files with 13072 additions and 19304 deletions
|
|
@ -7,23 +7,21 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public sealed class RewardType
|
||||
{
|
||||
private int m_Points;
|
||||
private Type[] m_Types;
|
||||
public int Points { get; }
|
||||
|
||||
public int Points => m_Points;
|
||||
public Type[] Types => m_Types;
|
||||
public Type[] Types { get; }
|
||||
|
||||
public RewardType( int points, params Type[] types )
|
||||
{
|
||||
m_Points = points;
|
||||
m_Types = types;
|
||||
Points = points;
|
||||
Types = types;
|
||||
}
|
||||
|
||||
public bool Contains( Type type )
|
||||
{
|
||||
for ( int i = 0; i < m_Types.Length; ++i )
|
||||
for ( int i = 0; i < Types.Length; ++i )
|
||||
{
|
||||
if ( m_Types[i] == type )
|
||||
if ( Types[i] == type )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -33,13 +31,11 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public sealed class RewardItem
|
||||
{
|
||||
private int m_Weight;
|
||||
private ConstructCallback m_Constructor;
|
||||
private int m_Type;
|
||||
public int Weight { get; }
|
||||
|
||||
public int Weight => m_Weight;
|
||||
public ConstructCallback Constructor => m_Constructor;
|
||||
public int Type => m_Type;
|
||||
public ConstructCallback Constructor { get; }
|
||||
|
||||
public int Type { get; }
|
||||
|
||||
public RewardItem( int weight, ConstructCallback constructor ) : this( weight, constructor, 0 )
|
||||
{
|
||||
|
|
@ -47,49 +43,47 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public RewardItem( int weight, ConstructCallback constructor, int type )
|
||||
{
|
||||
m_Weight = weight;
|
||||
m_Constructor = constructor;
|
||||
m_Type = type;
|
||||
Weight = weight;
|
||||
Constructor = constructor;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public Item Construct()
|
||||
{
|
||||
try{ return m_Constructor( m_Type ); }
|
||||
try{ return Constructor( Type ); }
|
||||
catch{ return null; }
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RewardGroup
|
||||
{
|
||||
private int m_Points;
|
||||
private RewardItem[] m_Items;
|
||||
public int Points { get; }
|
||||
|
||||
public int Points => m_Points;
|
||||
public RewardItem[] Items => m_Items;
|
||||
public RewardItem[] Items { get; }
|
||||
|
||||
public RewardGroup( int points, params RewardItem[] items )
|
||||
{
|
||||
m_Points = points;
|
||||
m_Items = items;
|
||||
Points = points;
|
||||
Items = items;
|
||||
}
|
||||
|
||||
public RewardItem AcquireItem()
|
||||
{
|
||||
if ( m_Items.Length == 0 )
|
||||
if ( Items.Length == 0 )
|
||||
return null;
|
||||
if ( m_Items.Length == 1 )
|
||||
return m_Items[0];
|
||||
if ( Items.Length == 1 )
|
||||
return Items[0];
|
||||
|
||||
int totalWeight = 0;
|
||||
|
||||
for ( int i = 0; i < m_Items.Length; ++i )
|
||||
totalWeight += m_Items[i].Weight;
|
||||
for ( int i = 0; i < Items.Length; ++i )
|
||||
totalWeight += Items[i].Weight;
|
||||
|
||||
int randomWeight = Utility.Random( totalWeight );
|
||||
|
||||
for ( int i = 0; i < m_Items.Length; ++i )
|
||||
for ( int i = 0; i < Items.Length; ++i )
|
||||
{
|
||||
RewardItem item = m_Items[i];
|
||||
RewardItem item = Items[i];
|
||||
|
||||
if ( randomWeight < item.Weight )
|
||||
return item;
|
||||
|
|
@ -103,11 +97,7 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public abstract class RewardCalculator
|
||||
{
|
||||
private RewardGroup[] m_Groups;
|
||||
|
||||
public RewardGroup[] Groups{ get => m_Groups;
|
||||
set => m_Groups = value;
|
||||
}
|
||||
public RewardGroup[] Groups { get; set; }
|
||||
|
||||
public abstract int ComputePoints( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type );
|
||||
public abstract int ComputeGold( int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type );
|
||||
|
|
@ -148,15 +138,15 @@ namespace Server.Engines.BulkOrders
|
|||
|
||||
public virtual RewardGroup LookupRewards( int points )
|
||||
{
|
||||
for ( int i = m_Groups.Length - 1; i >= 1; --i )
|
||||
for ( int i = Groups.Length - 1; i >= 1; --i )
|
||||
{
|
||||
RewardGroup group = m_Groups[i];
|
||||
RewardGroup group = Groups[i];
|
||||
|
||||
if ( points >= group.Points )
|
||||
return group;
|
||||
}
|
||||
|
||||
return m_Groups[0];
|
||||
return Groups[0];
|
||||
}
|
||||
|
||||
public virtual int LookupTypePoints( RewardType[] types, Type type )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue