Page MenuHomeWildfire Games

UnitAI cleanup - Move logic from Orders to States
AbandonedPublic

Authored by wraitii on May 11 2019, 6:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Sep 23, 7:36 AM
Unknown Object (File)
Tue, Sep 17, 3:01 AM
Unknown Object (File)
Fri, Sep 13, 1:47 PM
Unknown Object (File)
Fri, Sep 13, 1:38 PM
Unknown Object (File)
Fri, Sep 13, 11:51 AM
Unknown Object (File)
Tue, Sep 10, 9:33 AM
Unknown Object (File)
Tue, Sep 10, 2:46 AM
Unknown Object (File)
Sat, Sep 7, 5:28 AM
Subscribers
None

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

Repository
rP 0 A.D. Public Repository
Branch
D13_outtakes
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 7438
Build 12104: Vulcan BuildJenkins
Build 12103: arc lint + arc unit

Event Timeline

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

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

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.

binaries/data/mods/public/simulation/components/UnitAI.js
2546

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

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

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

Abandoning this under the assumption it was superseded by a bunch of things, then bunch of fixes on these things, and so on.

I think we need to do a pass like that for packing though.