Page MenuHomeWildfire Games

UnitAI cleanup - Move logic from Orders to States
Needs ReviewPublic

Authored by wraitii on Sat, May 11, 6:52 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

In preparation for a future patch where UnitMotion will no longer stop on its own (fixing a large number of cases where units get stuck), I need unitAI to handle its own stopping.

However, this highlights that most states don't actually order moving - usually the Order calls "MoveTo..." and the state just assume that.
This seems like putting logic in the wrong place - the State should decide if its want to move, and where, based on its order. This also applies to other state changes that orders where doing (see Unpacking, ungarrisonning).

This diff cleans things up: Orders are now (almost) solely in charge of accepting / refusing the order and that's it.

(This incorporates a resource-returning code repetition cleanup too)

Test Plan

Check out the logic of the change and the idea that Orders shouldn't actually change our UnitAI state.

Diff Detail

Event Timeline

wraitii created this revision.Sat, May 11, 6:52 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/differential/1367/display/redirect

wraitii updated this revision to Diff 8011.Mon, May 13, 9:01 PM
wraitii retitled this revision from UnitAI cleanup - Move logic from Orders to States // Handle motion more explicitly to UnitAI cleanup - Move logic from Orders to States.

Remove Motion-related changes.

This is now solely a cleanup of some orders. I'm wondering how far we should go, most of the "FinishOrder" logic that's currently in orders could be moved to states (or new "CONSIDERING" sub-states I guess), but I'm not sure that's desirable.

wraitii added inline comments.Mon, May 13, 9:03 PM
binaries/data/mods/public/simulation/components/UnitAI.js
2578

Err actually this will infinite-loop if the reason for MoveTo failing is that we can't move (and not that the target doesn't exist). I guess I need to explicitly check for that case.

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/differential/1394/display/redirect

wraitii updated this revision to Diff 8067.Sun, May 19, 4:37 PM

Updated

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/differential/1443/display/redirect