Pass large structs byref instead
This commit is contained in:
@@ -10,7 +10,7 @@ public abstract class BaseComboAction : BaseAction
|
||||
protected bool BaseCanUse(Simulator s) =>
|
||||
base.CanUse(s);
|
||||
|
||||
private static bool VerifyDurability2(int durabilityA, int durability, Effects effects)
|
||||
private static bool VerifyDurability2(int durabilityA, int durability, in Effects effects)
|
||||
{
|
||||
var wasteNots = effects.HasEffect(EffectType.WasteNot) || effects.HasEffect(EffectType.WasteNot2);
|
||||
// -A
|
||||
@@ -23,13 +23,10 @@ public abstract class BaseComboAction : BaseAction
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool VerifyDurability2(SimulationState s, int durabilityA) =>
|
||||
VerifyDurability2(durabilityA, s.Durability, s.ActiveEffects);
|
||||
|
||||
public static bool VerifyDurability2(Simulator s, int durabilityA) =>
|
||||
VerifyDurability2(durabilityA, s.Durability, s.ActiveEffects);
|
||||
|
||||
public static bool VerifyDurability3(int durabilityA, int durabilityB, int durability, Effects effects)
|
||||
public static bool VerifyDurability3(int durabilityA, int durabilityB, int durability, in Effects effects)
|
||||
{
|
||||
var wasteNots = Math.Max(effects.GetDuration(EffectType.WasteNot), effects.GetDuration(EffectType.WasteNot2));
|
||||
var manips = effects.HasEffect(EffectType.Manipulation);
|
||||
@@ -56,7 +53,4 @@ public abstract class BaseComboAction : BaseAction
|
||||
|
||||
public static bool VerifyDurability3(Simulator s, int durabilityA, int durabilityB) =>
|
||||
VerifyDurability3(durabilityA, durabilityB, s.Durability, s.ActiveEffects);
|
||||
|
||||
public static bool VerifyDurability3(SimulationState s, int durabilityA, int durabilityB) =>
|
||||
VerifyDurability3(durabilityA, durabilityB, s.Durability, s.ActiveEffects);
|
||||
}
|
||||
|
||||
@@ -35,17 +35,17 @@ public class Simulator
|
||||
|
||||
public IEnumerable<ActionType> AvailableActions => ActionUtils.AvailableActions(this);
|
||||
|
||||
public Simulator(SimulationState state)
|
||||
public Simulator(in SimulationState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
|
||||
public void SetState(SimulationState state)
|
||||
public void SetState(in SimulationState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
|
||||
public (ActionResponse Response, SimulationState NewState) Execute(SimulationState state, ActionType action)
|
||||
public (ActionResponse Response, SimulationState NewState) Execute(in SimulationState state, ActionType action)
|
||||
{
|
||||
State = state;
|
||||
return (Execute(action), State);
|
||||
@@ -75,7 +75,7 @@ public class Simulator
|
||||
return ActionResponse.UsedAction;
|
||||
}
|
||||
|
||||
public (ActionResponse Response, SimulationState NewState, int FailedActionIdx) ExecuteMultiple(SimulationState state, IEnumerable<ActionType> actions)
|
||||
public (ActionResponse Response, SimulationState NewState, int FailedActionIdx) ExecuteMultiple(in SimulationState state, IEnumerable<ActionType> actions)
|
||||
{
|
||||
State = state;
|
||||
var i = 0;
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace Craftimizer.Simulator;
|
||||
|
||||
public class SimulatorNoRandom : Simulator
|
||||
{
|
||||
public SimulatorNoRandom(SimulationState state) : base(state)
|
||||
public SimulatorNoRandom(in SimulationState state) : base(state)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user