This is an attempt at generalising rP23920.
It calls FinishOrder() and clears the order queue of the OG unit, when transforming.
Might be a bit risky, I'm not too sure.
Differential D2923
Reset UnitAI to a default state on transform wraitii on Aug 2 2020, 2:38 PM. Authored by
Details
This is an attempt at generalising rP23920. It calls FinishOrder() and clears the order queue of the OG unit, when transforming. Might be a bit risky, I'm not too sure. Upgrade units.
Diff Detail
Event TimelineComment Actions Successful build - Chance fights ever on the side of the prudent. Linter detected issues: Executing section Source... Executing section JS... | | [NORMAL] ESLintBear (quote-props): | | Unquoted property 'GetTimers' found. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | 41| 41| cmpUnitAI.GetBestAttackAgainst = () => "ranged"; | 42| 42| cmpUnitAI.CheckTargetAttackRange = () => true; | 43| 43| AddMock(ent, IID_Attack, { | 44| |- GetTimers: () => ({ "prepare": 1, "repeat": 10 }), | | 44|+ "GetTimers": () => ({ "prepare": 1, "repeat": 10 }), | 45| 45| }); | 46| 46| // Order | 47| 47| cmpUnitAI.Attack(target); | | [NORMAL] ESLintBear (quote-props): | | Unquoted property 'SwitchToStance' found. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | 50| 50| // Transform | 51| 51| let newEnt = 6; | 52| 52| let mock = AddMock(newEnt, IID_UnitAI, { | 53| |- SwitchToStance: () => {}, | | 53|+ "SwitchToStance": () => {}, | 54| 54| AddOrders: () => {}, | 55| 55| }); | 56| 56| let spy = new Spy(mock, "AddOrders"); | | [NORMAL] ESLintBear (quote-props): | | Unquoted property 'AddOrders' found. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | 51| 51| let newEnt = 6; | 52| 52| let mock = AddMock(newEnt, IID_UnitAI, { | 53| 53| SwitchToStance: () => {}, | 54| |- AddOrders: () => {}, | | 54|+ "AddOrders": () => {}, | 55| 55| }); | 56| 56| let spy = new Spy(mock, "AddOrders"); | 57| 57| Engine.AddEntity = () => newEnt; | | [NORMAL] ESLintBear (key-spacing): | | Missing space before value for key 'data'. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | 62| 62| TS_ASSERT(spy._called); | 63| 63| | 64| 64| TS_ASSERT_UNEVAL_EQUALS(spy._callargs[0][0][0], { | 65| |- "type": "Attack", "data":{ | | 65|+ "type": "Attack", "data": { | 66| 66| "target": target, "force": true, "allowCapture": true, attackType: "ranged" | 67| 67| } | 68| 68| }); | | [NORMAL] ESLintBear (quote-props): | | Unquoted property 'attackType' found. |----| | /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | |++++| /zpool0/trunk/binaries/data/mods/public/simulation/helpers/tests/test_Transform.js | 63| 63| | 64| 64| TS_ASSERT_UNEVAL_EQUALS(spy._callargs[0][0][0], { | 65| 65| "type": "Attack", "data":{ | 66| |- "target": target, "force": true, "allowCapture": true, attackType: "ranged" | | 66|+ "target": target, "force": true, "allowCapture": true, "attackType": "ranged" | 67| 67| } | 68| 68| }); | 69| 69| TS_ASSERT_EQUALS(cmpUnitAI.fsmNextState, "IDLE"); binaries/data/mods/public/simulation/helpers/Transform.js | 236| » » » » for·(let·ent·of·cmpNewObstruction.GetEntitiesDeletedUponConstruction()) | | [NORMAL] ESLintBear (no-shadow): | | 'ent' is already declared in the upper scope. Executing section cli... Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2841/display/redirect Comment Actions Mh, you're not incorrect. It doesn't quite do the same thing, since it doesn't pop the order queue, though. I'm not sure if that triggers a special empty state, I'll look into it. |