Skip to content

Commit

Permalink
Other small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Oct 14, 2023
1 parent aa9bc8d commit f8b2826
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
5 changes: 4 additions & 1 deletion sim/core/energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type energyBar struct {
// [10, 15, 20, 30, 60, 85]
energyDecisionThresholds []int

// Slice with len == maxEnergy with each index corresponding to an amount of energy. Looks like this:
// Slice with len == maxEnergy+1 with each index corresponding to an amount of energy. Looks like this:
// [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, ...]
// Increments by 1 at each value of energyDecisionThresholds.
cumulativeEnergyDecisionThresholds []int
Expand Down Expand Up @@ -72,6 +72,9 @@ func (unit *Unit) EnableEnergyBar(maxEnergy float64, onEnergyGain OnEnergyGain)

// Computes the energy thresholds.
func (eb *energyBar) setupEnergyThresholds() {
if eb.unit == nil {
return
}
if !eb.unit.IsUsingAPL {
return
}
Expand Down
16 changes: 7 additions & 9 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,13 @@ func (unit *Unit) finalize() {
spell.finalize()
}

if unit.HasEnergyBar() {
// For now, restrict this optimization to rogues only. Ferals will require
// some extra logic to handle their ExcessEnergy() calc.
agent := unit.Env.Raid.GetPlayerFromUnit(unit)
if agent != nil && agent.GetCharacter().Class == proto.Class_ClassRogue {
unit.Env.RegisterPostFinalizeEffect(func() {
unit.energyBar.setupEnergyThresholds()
})
}
// For now, restrict this optimization to rogues only. Ferals will require
// some extra logic to handle their ExcessEnergy() calc.
agent := unit.Env.Raid.GetPlayerFromUnit(unit)
if agent != nil && agent.GetCharacter().Class == proto.Class_ClassRogue {
unit.Env.RegisterPostFinalizeEffect(func() {
unit.energyBar.setupEnergyThresholds()
})
}
}

Expand Down

0 comments on commit f8b2826

Please sign in to comment.