diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 1e588a4327..de89baa80b 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -1370,10 +1370,11 @@ UnitAI.prototype.UnitFsmSpec = { // Don't use the logic from unitMotion, as SetInPosition // has already given us a custom rotation // (or we failed to move and thus don't care.) + let facePointAfterMove = this.GetFacePointAfterMove(); this.SetFacePointAfterMove(false); this.StopMoving(); - // Reset default behaviour (TODO: actually get the previuos behaviour). - this.SetFacePointAfterMove(true); + // Reset previous behaviour. + this.SetFacePointAfterMove(facePointAfterMove); }, // Occurs when the unit has reached its destination and the controller @@ -6335,6 +6336,12 @@ UnitAI.prototype.SetFacePointAfterMove = function(val) cmpMotion.SetFacePointAfterMove(val); }; +UnitAI.prototype.GetFacePointAfterMove = function() +{ + let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); + return cmpUnitMotion && cmpUnitMotion.GetFacePointAfterMove(); +} + UnitAI.prototype.AttackEntitiesByPreference = function(ents) { if (!ents.length) diff --git a/source/simulation2/components/CCmpUnitMotion.cpp b/source/simulation2/components/CCmpUnitMotion.cpp index 3fb0289a1e..a6b8a5f27a 100644 --- a/source/simulation2/components/CCmpUnitMotion.cpp +++ b/source/simulation2/components/CCmpUnitMotion.cpp @@ -414,6 +414,11 @@ public: m_FacePointAfterMove = facePointAfterMove; } + virtual bool GetFacePointAfterMove() const + { + return m_FacePointAfterMove; + } + virtual void SetDebugOverlay(bool enabled) { m_DebugOverlayEnabled = enabled; diff --git a/source/simulation2/components/ICmpUnitMotion.cpp b/source/simulation2/components/ICmpUnitMotion.cpp index bf49a100a8..08931d83c0 100644 --- a/source/simulation2/components/ICmpUnitMotion.cpp +++ b/source/simulation2/components/ICmpUnitMotion.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -37,6 +37,7 @@ DEFINE_INTERFACE_METHOD_1("SetSpeedMultiplier", void, ICmpUnitMotion, SetSpeedMu DEFINE_INTERFACE_METHOD_CONST_0("GetPassabilityClassName", std::string, ICmpUnitMotion, GetPassabilityClassName) DEFINE_INTERFACE_METHOD_CONST_0("GetUnitClearance", entity_pos_t, ICmpUnitMotion, GetUnitClearance) DEFINE_INTERFACE_METHOD_1("SetFacePointAfterMove", void, ICmpUnitMotion, SetFacePointAfterMove, bool) +DEFINE_INTERFACE_METHOD_CONST_0("GetFacePointAfterMove", bool, ICmpUnitMotion, GetFacePointAfterMove) DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpUnitMotion, SetDebugOverlay, bool) END_INTERFACE_WRAPPER(UnitMotion) @@ -110,6 +111,11 @@ public: m_Script.CallVoid("SetFacePointAfterMove", facePointAfterMove); } + virtual bool GetFacePointAfterMove() const + { + return m_Script.Call("GetFacePointAfterMove"); + } + virtual pass_class_t GetPassabilityClass() const { return m_Script.Call("GetPassabilityClass"); diff --git a/source/simulation2/components/ICmpUnitMotion.h b/source/simulation2/components/ICmpUnitMotion.h index 5c6a76ef81..fbf544bb89 100644 --- a/source/simulation2/components/ICmpUnitMotion.h +++ b/source/simulation2/components/ICmpUnitMotion.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -112,6 +112,8 @@ public: */ virtual void SetFacePointAfterMove(bool facePointAfterMove) = 0; + virtual bool GetFacePointAfterMove() const = 0; + /** * Get the unit's passability class. */