Adds style cop (#109)
This commit is contained in:
parent
3e715bcb60
commit
556a17aba8
1725 changed files with 33831 additions and 38046 deletions
|
|
@ -13,13 +13,13 @@ namespace Server.Engines.Harvest
|
|||
SuccessMessage = message;
|
||||
}
|
||||
|
||||
public Type Type{ get; set; }
|
||||
public Type Type { get; set; }
|
||||
|
||||
public double ReqSkill{ get; set; }
|
||||
public double ReqSkill { get; set; }
|
||||
|
||||
public double Chance{ get; set; }
|
||||
public double Chance { get; set; }
|
||||
|
||||
public TextDefinition SuccessMessage{ get; }
|
||||
public TextDefinition SuccessMessage { get; }
|
||||
|
||||
public void SendSuccessTo(Mobile m)
|
||||
{
|
||||
|
|
|
|||
10
Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs
Normal file
10
Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class FurnitureAttribute : Attribute
|
||||
{
|
||||
public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ namespace Server.Engines.Harvest
|
|||
public class HarvestBank
|
||||
{
|
||||
private int m_Current;
|
||||
private int m_Maximum;
|
||||
private readonly int m_Maximum;
|
||||
private DateTime m_NextRespawn;
|
||||
private HarvestVein m_Vein, m_DefaultVein;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ namespace Server.Engines.Harvest
|
|||
Definition = def;
|
||||
}
|
||||
|
||||
public HarvestDefinition Definition{ get; }
|
||||
public HarvestDefinition Definition { get; }
|
||||
|
||||
public int Current
|
||||
{
|
||||
|
|
@ -56,7 +56,7 @@ namespace Server.Engines.Harvest
|
|||
|
||||
m_Current = m_Maximum;
|
||||
|
||||
if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.RandomDouble());
|
||||
if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights));
|
||||
|
||||
m_Vein = m_DefaultVein;
|
||||
}
|
||||
|
|
@ -74,8 +74,8 @@ namespace Server.Engines.Harvest
|
|||
m_Current = m_Maximum - amount;
|
||||
|
||||
double minutes = min + rnd * (max - min);
|
||||
if (Definition.RaceBonus && from.Race == Race.Elf) //def.RaceBonus = Core.ML
|
||||
minutes *= .75; //25% off the time.
|
||||
if (Definition.RaceBonus && from.Race == Race.Elf) // def.RaceBonus = Core.ML
|
||||
minutes *= .75; // 25% off the time.
|
||||
|
||||
m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes);
|
||||
}
|
||||
|
|
@ -88,4 +88,4 @@ namespace Server.Engines.Harvest
|
|||
m_Current = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Server.Engines.Harvest
|
||||
{
|
||||
public class HarvestDefinition
|
||||
{
|
||||
public int BankWidth{ get; set; }
|
||||
public int BankWidth { get; set; }
|
||||
|
||||
public int BankHeight{ get; set; }
|
||||
public int BankHeight { get; set; }
|
||||
|
||||
public int MinTotal{ get; set; }
|
||||
public int MinTotal { get; set; }
|
||||
|
||||
public int MaxTotal{ get; set; }
|
||||
public int MaxTotal { get; set; }
|
||||
|
||||
public int[] Tiles{ get; set; }
|
||||
public int[] Tiles { get; set; }
|
||||
|
||||
public bool RangedTiles{ get; set; }
|
||||
public bool RangedTiles { get; set; }
|
||||
|
||||
public TimeSpan MinRespawn{ get; set; }
|
||||
public TimeSpan MinRespawn { get; set; }
|
||||
|
||||
public TimeSpan MaxRespawn{ get; set; }
|
||||
public TimeSpan MaxRespawn { get; set; }
|
||||
|
||||
public int MaxRange{ get; set; }
|
||||
public int MaxRange { get; set; }
|
||||
|
||||
public int ConsumedPerHarvest{ get; set; }
|
||||
public int ConsumedPerHarvest { get; set; }
|
||||
|
||||
public int ConsumedPerFeluccaHarvest{ get; set; }
|
||||
public int ConsumedPerFeluccaHarvest { get; set; }
|
||||
|
||||
public bool PlaceAtFeetIfFull{ get; set; }
|
||||
public bool PlaceAtFeetIfFull { get; set; }
|
||||
|
||||
public SkillName Skill{ get; set; }
|
||||
public SkillName Skill { get; set; }
|
||||
|
||||
public int[] EffectActions{ get; set; }
|
||||
public int[] EffectActions { get; set; }
|
||||
|
||||
public int[] EffectCounts{ get; set; }
|
||||
public int[] EffectCounts { get; set; }
|
||||
|
||||
public int[] EffectSounds{ get; set; }
|
||||
public int[] EffectSounds { get; set; }
|
||||
|
||||
public TimeSpan EffectSoundDelay{ get; set; }
|
||||
public TimeSpan EffectSoundDelay { get; set; }
|
||||
|
||||
public TimeSpan EffectDelay{ get; set; }
|
||||
public TimeSpan EffectDelay { get; set; }
|
||||
|
||||
public object NoResourcesMessage{ get; set; }
|
||||
public TextDefinition NoResourcesMessage { get; set; }
|
||||
|
||||
public object OutOfRangeMessage{ get; set; }
|
||||
public TextDefinition OutOfRangeMessage { get; set; }
|
||||
|
||||
public object TimedOutOfRangeMessage{ get; set; }
|
||||
public TextDefinition TimedOutOfRangeMessage { get; set; }
|
||||
|
||||
public object DoubleHarvestMessage{ get; set; }
|
||||
public TextDefinition DoubleHarvestMessage { get; set; }
|
||||
|
||||
public object FailMessage{ get; set; }
|
||||
public TextDefinition FailMessage { get; set; }
|
||||
|
||||
public object PackFullMessage{ get; set; }
|
||||
public TextDefinition PackFullMessage { get; set; }
|
||||
|
||||
public object ToolBrokeMessage{ get; set; }
|
||||
public TextDefinition ToolBrokeMessage { get; set; }
|
||||
|
||||
public HarvestResource[] Resources{ get; set; }
|
||||
public HarvestResource[] Resources { get; set; }
|
||||
|
||||
public HarvestVein[] Veins{ get; set; }
|
||||
private HarvestVein[] m_Veins;
|
||||
|
||||
public BonusHarvestResource[] BonusResources{ get; set; }
|
||||
public HarvestVein[] Veins
|
||||
{
|
||||
get => m_Veins;
|
||||
set
|
||||
{
|
||||
m_Veins = value;
|
||||
VeinWeights = m_Veins.Aggregate<HarvestVein, uint>(0, (current, t) => current + t.VeinChance);
|
||||
}
|
||||
}
|
||||
|
||||
public bool RaceBonus{ get; set; }
|
||||
public BonusHarvestResource[] BonusResources { get; set; }
|
||||
|
||||
public bool RandomizeVeins{ get; set; }
|
||||
public bool RaceBonus { get; set; }
|
||||
|
||||
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks{ get; }
|
||||
public bool RandomizeVeins { get; set; }
|
||||
|
||||
public uint VeinWeights { get; private set; }
|
||||
|
||||
public Dictionary<Map, Dictionary<Point2D, HarvestBank>> Banks { get; }
|
||||
= new Dictionary<Map, Dictionary<Point2D, HarvestBank>>();
|
||||
|
||||
public void SendMessageTo(Mobile from, object message)
|
||||
|
|
@ -100,28 +113,18 @@ namespace Server.Engines.Harvest
|
|||
if (Veins.Length == 1)
|
||||
return Veins[0];
|
||||
|
||||
double randomValue;
|
||||
if (RandomizeVeins) return GetVeinFrom(Utility.Random(1000u));
|
||||
|
||||
if (RandomizeVeins)
|
||||
{
|
||||
randomValue = Utility.RandomDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
Random random = new Random(x * 17 + y * 11 + map.MapID * 3);
|
||||
randomValue = random.NextDouble();
|
||||
}
|
||||
|
||||
return GetVeinFrom(randomValue);
|
||||
// TODO: Introduce pulling primes from a config and writing them if they don't exist to the config
|
||||
using Xoshiro256PlusPlus random = new Xoshiro256PlusPlus((ulong)(x * 17 + y * 11 + map.MapID * 3));
|
||||
return GetVeinFrom(random.Next(VeinWeights));
|
||||
}
|
||||
|
||||
public HarvestVein GetVeinFrom(double randomValue)
|
||||
public HarvestVein GetVeinFrom(uint randomValue)
|
||||
{
|
||||
if (Veins.Length == 1)
|
||||
return Veins[0];
|
||||
|
||||
randomValue *= 100;
|
||||
|
||||
for (int i = 0; i < Veins.Length; ++i)
|
||||
{
|
||||
if (randomValue <= Veins[i].VeinChance)
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ namespace Server.Engines.Harvest
|
|||
SuccessMessage = message;
|
||||
}
|
||||
|
||||
public Type[] Types{ get; set; }
|
||||
public Type[] Types { get; set; }
|
||||
|
||||
public double ReqSkill{ get; set; }
|
||||
public double ReqSkill { get; set; }
|
||||
|
||||
public double MinSkill{ get; set; }
|
||||
public double MinSkill { get; set; }
|
||||
|
||||
public double MaxSkill{ get; set; }
|
||||
public double MaxSkill { get; set; }
|
||||
|
||||
public object SuccessMessage{ get; }
|
||||
public object SuccessMessage { get; }
|
||||
|
||||
public void SendSuccessTo(Mobile m)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
public class HarvestSoundTimer : Timer
|
||||
{
|
||||
private HarvestDefinition m_Definition;
|
||||
private Mobile m_From;
|
||||
private bool m_Last;
|
||||
private HarvestSystem m_System;
|
||||
private object m_ToHarvest, m_Locked;
|
||||
private Item m_Tool;
|
||||
private readonly HarvestDefinition m_Definition;
|
||||
private readonly Mobile m_From;
|
||||
private readonly bool m_Last;
|
||||
private readonly HarvestSystem m_System;
|
||||
private readonly object m_ToHarvest;
|
||||
private readonly object m_Locked;
|
||||
private readonly Item m_Tool;
|
||||
|
||||
public HarvestSoundTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest,
|
||||
object locked, bool last) : base(def.EffectSoundDelay)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
public HarvestSystem() => Definitions = new List<HarvestDefinition>();
|
||||
|
||||
public List<HarvestDefinition> Definitions{ get; }
|
||||
public List<HarvestDefinition> Definitions { get; }
|
||||
|
||||
public virtual bool CheckTool(Mobile from, Item tool)
|
||||
{
|
||||
bool wornOut = tool?.Deleted != false || tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0;
|
||||
bool wornOut = tool?.Deleted != false || (tool as IUsesRemaining)?.UsesRemaining <= 0;
|
||||
|
||||
if (wornOut)
|
||||
from.SendLocalizedMessage(1044038); // You have worn out your tool!
|
||||
|
|
@ -139,7 +139,7 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
else
|
||||
{
|
||||
//The whole harvest system is kludgy and I'm sure this is just adding to it.
|
||||
// The whole harvest system is kludgy and I'm sure this is just adding to it.
|
||||
if (item.Stackable)
|
||||
{
|
||||
int amount = def.ConsumedPerHarvest;
|
||||
|
|
@ -152,11 +152,11 @@ namespace Server.Engines.Harvest
|
|||
bool inFelucca = map == Map.Felucca;
|
||||
|
||||
if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount &&
|
||||
0.1 > Utility.RandomDouble())
|
||||
Utility.RandomDouble() < 0.1)
|
||||
item.Amount = feluccaRacialAmount;
|
||||
else if (inFelucca && bank.Current >= feluccaAmount)
|
||||
item.Amount = feluccaAmount;
|
||||
else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble())
|
||||
else if (eligableForRacialBonus && bank.Current >= racialAmount && Utility.RandomDouble() < 0.1)
|
||||
item.Amount = racialAmount;
|
||||
else
|
||||
item.Amount = amount;
|
||||
|
|
@ -180,8 +180,7 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
Item bonusItem = Construct(bonus.Type, from);
|
||||
|
||||
if (Give(from, bonusItem, true)
|
||||
) //Bonuses always allow placing at feet, even if pack is full irregrdless of def
|
||||
if (Give(from, bonusItem, true)) // Bonuses always allow placing at feet, even if pack is full irregrdless of def
|
||||
bonus.SendSuccessTo(from);
|
||||
else
|
||||
item.Delete();
|
||||
|
|
@ -349,10 +348,10 @@ namespace Server.Engines.Harvest
|
|||
from.Animate(Utility.RandomList(def.EffectActions), 5, 1, true, false, 0);
|
||||
}
|
||||
|
||||
public virtual HarvestDefinition GetDefinition(int tileID)
|
||||
{
|
||||
return Definitions.FirstOrDefault(check => check.Validate(tileID));
|
||||
}
|
||||
public virtual HarvestDefinition GetDefinition() => Definitions.First();
|
||||
|
||||
public virtual HarvestDefinition GetDefinition(int tileID) =>
|
||||
Definitions.FirstOrDefault(check => check.Validate(tileID));
|
||||
|
||||
public virtual void StartHarvesting(Mobile from, Item tool, object toHarvest)
|
||||
{
|
||||
|
|
@ -425,17 +424,3 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface IChopable
|
||||
{
|
||||
void OnChop(Mobile from);
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class FurnitureAttribute : Attribute
|
||||
{
|
||||
public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
public class HarvestTarget : Target
|
||||
{
|
||||
private HarvestSystem m_System;
|
||||
private Item m_Tool;
|
||||
private readonly HarvestSystem m_System;
|
||||
private readonly Item m_Tool;
|
||||
|
||||
public HarvestTarget(Item tool, HarvestSystem system) : base(-1, true, TargetFlags.None)
|
||||
{
|
||||
|
|
@ -47,7 +47,7 @@ namespace Server.Engines.Harvest
|
|||
}
|
||||
}
|
||||
|
||||
if (m_System is Lumberjacking && targeted is IChopable chopable)
|
||||
if (m_System is Lumberjacking && targeted is IChoppable chopable)
|
||||
{
|
||||
chopable.OnChop(from);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
public class HarvestTimer : Timer
|
||||
{
|
||||
private HarvestDefinition m_Definition;
|
||||
private Mobile m_From;
|
||||
private int m_Index, m_Count;
|
||||
private HarvestSystem m_System;
|
||||
private object m_ToHarvest, m_Locked;
|
||||
private Item m_Tool;
|
||||
private readonly HarvestDefinition m_Definition;
|
||||
private readonly Mobile m_From;
|
||||
private int m_Index;
|
||||
private readonly int m_Count;
|
||||
private readonly HarvestSystem m_System;
|
||||
private readonly object m_ToHarvest;
|
||||
private readonly object m_Locked;
|
||||
private readonly Item m_Tool;
|
||||
|
||||
public HarvestTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest,
|
||||
object locked) : base(TimeSpan.Zero, def.EffectDelay)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ namespace Server.Engines.Harvest
|
|||
{
|
||||
public class HarvestVein
|
||||
{
|
||||
public HarvestVein(double veinChance, double chanceToFallback, HarvestResource primaryResource,
|
||||
public HarvestVein(uint veinChance, double chanceToFallback, HarvestResource primaryResource,
|
||||
HarvestResource fallbackResource)
|
||||
{
|
||||
VeinChance = veinChance;
|
||||
|
|
@ -11,12 +11,12 @@ namespace Server.Engines.Harvest
|
|||
FallbackResource = fallbackResource;
|
||||
}
|
||||
|
||||
public double VeinChance{ get; set; }
|
||||
public uint VeinChance { get; set; }
|
||||
|
||||
public double ChanceToFallback{ get; set; }
|
||||
public double ChanceToFallback { get; set; }
|
||||
|
||||
public HarvestResource PrimaryResource{ get; set; }
|
||||
public HarvestResource PrimaryResource { get; set; }
|
||||
|
||||
public HarvestResource FallbackResource{ get; set; }
|
||||
public HarvestResource FallbackResource { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
Projects/Scripts/Engines/Harvest/Core/IChoppable..cs
Normal file
7
Projects/Scripts/Engines/Harvest/Core/IChoppable..cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace Server
|
||||
{
|
||||
public interface IChoppable
|
||||
{
|
||||
void OnChop(Mobile from);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue