Remove ref passing, but keep devirtualizations

This commit is contained in:
Asriel Camora
2024-03-16 13:24:26 -07:00
parent 3223bdcbfb
commit ec77f1d021
48 changed files with 411 additions and 787 deletions
+13 -23
View File
@@ -1,36 +1,26 @@
namespace Craftimizer.Simulator.Actions;
internal abstract class BaseComboAction<A, B> : BaseComboAction where A : BaseAction, new() where B : BaseAction, new()
internal abstract class BaseComboAction<A, B>(
ActionType actionTypeA, ActionType actionTypeB,
int? baseCPCost = null) :
BaseComboAction(
actionTypeA, actionTypeB,
ActionA, ActionB,
baseCPCost
) where A : BaseAction, new() where B : BaseAction, new()
{
protected static readonly A ActionA = new();
protected static readonly B ActionB = new();
protected BaseComboAction()
{
Level = ActionB.Level;
ActionId = ActionB.ActionId;
IncreasesProgress = ActionA.IncreasesProgress || ActionB.IncreasesProgress;
IncreasesQuality = ActionA.IncreasesQuality || ActionB.IncreasesQuality;
}
public override void CPCost(Simulator s, ref int cost)
{
var costTmp = 0;
ActionA.CPCost(s, ref costTmp);
cost += costTmp;
ActionB.CPCost(s, ref costTmp);
cost += costTmp;
}
public override bool IsPossible(Simulator s) => ActionA.IsPossible(s) && ActionB.IsPossible(s);
public override bool CouldUse(Simulator s, ref int cost) =>
BaseCouldUse(s, ref cost) && VerifyDurability2(s, ActionA.DurabilityCost);
public override bool CouldUse(Simulator s) =>
BaseCouldUse(s) && VerifyDurability2(s, ActionA.DurabilityCost);
public override void Use(Simulator s, ref int cost, ref float success, ref int eff)
public override void Use(Simulator s)
{
ActionA.Use(s, ref cost, ref success, ref eff);
ActionB.Use(s, ref cost, ref success, ref eff);
ActionA.Use(s);
ActionB.Use(s);
}
public override string GetTooltip(Simulator s, bool addUsability) =>