Optimizations (from @wolfcomp)

This commit is contained in:
Asriel Camora
2024-03-15 09:49:03 -07:00
parent ea963f9e1b
commit 3223bdcbfb
43 changed files with 691 additions and 354 deletions
+8 -4
View File
@@ -21,6 +21,10 @@ public class Simulator
public ref Effects ActiveEffects => ref state.ActiveEffects;
public ref ActionStates ActionStates => ref state.ActionStates;
private int cost;
private int eff;
private float success;
public bool IsFirstStep => state.StepCount == 0;
public virtual CompletionState CompletionState {
@@ -50,7 +54,7 @@ public class Simulator
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ExecuteUnchecked(ActionType action) =>
action.Base().Use(this);
action.Base().Use(this, ref cost, ref success, ref eff);
private ActionResponse Execute(ActionType action)
{
@@ -58,7 +62,7 @@ public class Simulator
return ActionResponse.SimulationComplete;
var baseAction = action.Base();
if (!baseAction.CanUse(this))
if (!baseAction.CanUse(this, ref cost))
{
if (baseAction.Level > Input.Stats.Level)
return ActionResponse.ActionNotUnlocked;
@@ -66,12 +70,12 @@ public class Simulator
return ActionResponse.ActionNotUnlocked;
if (action is ActionType.CarefulObservation or ActionType.HeartAndSoul && !Input.Stats.IsSpecialist)
return ActionResponse.ActionNotUnlocked;
if (baseAction.CPCost(this) > CP)
if (cost > CP)
return ActionResponse.NotEnoughCP;
return ActionResponse.CannotUseAction;
}
baseAction.Use(this);
baseAction.Use(this, ref cost, ref success, ref eff);
return ActionResponse.UsedAction;
}