Optimizations (from @wolfcomp)
This commit is contained in:
+8
-4
@@ -41,7 +41,10 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
private bool CouldUseAction(ActionType action, BaseAction baseAction, bool strict)
|
||||
#pragma warning restore MA0051 // Method is too long
|
||||
{
|
||||
if (CalculateSuccessRate(baseAction.SuccessRate(this)) != 1)
|
||||
var success = 0f;
|
||||
int cost = 0, eff = 0;
|
||||
baseAction.SuccessRate(this, ref success);
|
||||
if (Math.Abs(CalculateSuccessRate(success) - 1) > float.Epsilon)
|
||||
return false;
|
||||
|
||||
// don't allow quality moves at max quality
|
||||
@@ -52,7 +55,7 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
{
|
||||
// always use Trained Eye if it's available
|
||||
if (action == ActionType.TrainedEye)
|
||||
return baseAction.CouldUse(this);
|
||||
return baseAction.CouldUse(this, ref cost);
|
||||
|
||||
// don't allow quality moves under Muscle Memory for difficult crafts
|
||||
if (Input.Recipe.ClassJobLevel == 90 &&
|
||||
@@ -85,7 +88,8 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
|
||||
if (baseAction.IncreasesProgress)
|
||||
{
|
||||
var progressIncrease = CalculateProgressGain(baseAction.Efficiency(this));
|
||||
baseAction.Efficiency(this, ref eff);
|
||||
var progressIncrease = CalculateProgressGain(eff);
|
||||
var wouldFinish = Progress + progressIncrease >= Input.Recipe.MaxProgress;
|
||||
|
||||
if (wouldFinish)
|
||||
@@ -129,7 +133,7 @@ internal sealed class Simulator : SimulatorNoRandom
|
||||
return false;
|
||||
}
|
||||
|
||||
return baseAction.CouldUse(this);
|
||||
return baseAction.CouldUse(this, ref cost);
|
||||
}
|
||||
|
||||
// https://github.com/alostsock/crafty/blob/cffbd0cad8bab3cef9f52a3e3d5da4f5e3781842/crafty/src/craft_state.rs#L137
|
||||
|
||||
Reference in New Issue
Block a user