Skip to content

Commit

Permalink
fix(mindustry): Some more formation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Jan 16, 2025
1 parent e8b51ce commit 1651b07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import mindustry.entities.units.AIController
import mindustry.gen.Call
import mindustry.gen.Unit as MindustryUnit

class FormationAI(private val context: FormationContext) : AIController(), FormationMember {
class FormationAI(val context: FormationContext) : AIController(), FormationMember {

override var id: Int = -1
override val targetVector = Vec2()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ class FormationListener(instances: InstanceManager) : ImperiumApplication.Listen
unit.controller(ai)
context.members.add(ai)
}
context.strategy.update(context)
if (eligible.isNotEmpty()) {
context.strategy.update(context)
}
}
val anchor = Vec2(player.x(), player.y())
for (member in context.members) {
context.pattern.calculate(
member.targetVector,
context.assignments[member.id] ?: 0,
min(context.slots, context.members.size),
player.unit().hitSize * 2F,
player.unit().hitSize * 1.8F,
)
member.targetVector.add(anchor)
}
Expand Down Expand Up @@ -198,7 +200,8 @@ class FormationListener(instances: InstanceManager) : ImperiumApplication.Listen
leader.type.buildSpeed > 0 == unit.type.buildSpeed > 0 &&
unit != leader &&
(unit.hitSize <= leader.hitSize * 1.5F) &&
(formation || unit.controller() !is FormationAI)
(unit.controller() !is FormationAI ||
(formation && (unit.controller() as FormationAI).context.leader == leader))

enum class FormationPatternEntry(val value: FormationPattern) {
CIRCLE(CircleFormationPattern),
Expand Down

0 comments on commit 1651b07

Please sign in to comment.