2021-01-19 07:59:03 -08:00
|
|
|
/* Copyright (C) 2021 Wildfire Games.
|
2010-01-09 11:20:14 -08:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "ICmpUnitMotion.h"
|
|
|
|
|
|
|
|
|
|
#include "simulation2/system/InterfaceScripted.h"
|
2011-06-09 12:44:40 -07:00
|
|
|
#include "simulation2/scripting/ScriptComponent.h"
|
2010-01-09 11:20:14 -08:00
|
|
|
|
|
|
|
|
BEGIN_INTERFACE_WRAPPER(UnitMotion)
|
2021-05-01 01:01:30 -07:00
|
|
|
DEFINE_INTERFACE_METHOD("MoveToPointRange", ICmpUnitMotion, MoveToPointRange)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("MoveToTargetRange", ICmpUnitMotion, MoveToTargetRange)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("MoveToFormationOffset", ICmpUnitMotion, MoveToFormationOffset)
|
2021-06-06 08:25:52 -07:00
|
|
|
DEFINE_INTERFACE_METHOD("SetMemberOfFormation", ICmpUnitMotion, SetMemberOfFormation)
|
2021-05-01 01:01:30 -07:00
|
|
|
DEFINE_INTERFACE_METHOD("IsTargetRangeReachable", ICmpUnitMotion, IsTargetRangeReachable)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("FaceTowardsPoint", ICmpUnitMotion, FaceTowardsPoint)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("StopMoving", ICmpUnitMotion, StopMoving)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetCurrentSpeed", ICmpUnitMotion, GetCurrentSpeed)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("IsMoveRequested", ICmpUnitMotion, IsMoveRequested)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetSpeed", ICmpUnitMotion, GetSpeed)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetWalkSpeed", ICmpUnitMotion, GetWalkSpeed)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetRunMultiplier", ICmpUnitMotion, GetRunMultiplier)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("EstimateFuturePosition", ICmpUnitMotion, EstimateFuturePosition)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("SetSpeedMultiplier", ICmpUnitMotion, SetSpeedMultiplier)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetPassabilityClassName", ICmpUnitMotion, GetPassabilityClassName)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetUnitClearance", ICmpUnitMotion, GetUnitClearance)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("SetFacePointAfterMove", ICmpUnitMotion, SetFacePointAfterMove)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("GetFacePointAfterMove", ICmpUnitMotion, GetFacePointAfterMove)
|
|
|
|
|
DEFINE_INTERFACE_METHOD("SetDebugOverlay", ICmpUnitMotion, SetDebugOverlay)
|
2010-01-09 11:20:14 -08:00
|
|
|
END_INTERFACE_WRAPPER(UnitMotion)
|
2011-06-09 12:44:40 -07:00
|
|
|
|
|
|
|
|
class CCmpUnitMotionScripted : public ICmpUnitMotion
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DEFAULT_SCRIPT_WRAPPER(UnitMotionScripted)
|
|
|
|
|
|
|
|
|
|
virtual bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<bool>("MoveToPointRange", x, z, minRange, maxRange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<bool>("MoveToTargetRange", target, minRange, maxRange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("MoveToFormationOffset", target, x, z);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-06 08:25:52 -07:00
|
|
|
virtual void SetMemberOfFormation(entity_id_t controller)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("SetMemberOfFormation", controller);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-03 05:02:24 -07:00
|
|
|
virtual bool IsTargetRangeReachable(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<bool>("IsTargetRangeReachable", target, minRange, maxRange);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 12:44:40 -07:00
|
|
|
virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("FaceTowardsPoint", x, z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void StopMoving()
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("StopMoving");
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual fixed GetCurrentSpeed() const
|
2012-12-06 11:46:13 -08:00
|
|
|
{
|
|
|
|
|
return m_Script.Call<fixed>("GetCurrentSpeed");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-28 03:51:12 -07:00
|
|
|
virtual bool IsMoveRequested() const
|
2012-08-31 01:20:36 -07:00
|
|
|
{
|
2019-07-28 03:51:12 -07:00
|
|
|
return m_Script.Call<bool>("IsMoveRequested");
|
2012-08-31 01:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
2019-04-19 03:04:50 -07:00
|
|
|
virtual fixed GetSpeed() const
|
2011-06-09 12:44:40 -07:00
|
|
|
{
|
2019-04-19 03:04:50 -07:00
|
|
|
return m_Script.Call<fixed>("GetSpeed");
|
2011-06-09 12:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2019-04-19 03:04:50 -07:00
|
|
|
virtual fixed GetWalkSpeed() const
|
2011-06-09 12:44:40 -07:00
|
|
|
{
|
2019-04-19 03:04:50 -07:00
|
|
|
return m_Script.Call<fixed>("GetWalkSpeed");
|
2011-06-09 12:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
2019-05-13 09:47:51 -07:00
|
|
|
virtual fixed GetRunMultiplier() const
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<fixed>("GetRunMultiplier");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetSpeedMultiplier(fixed multiplier)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("SetSpeedMultiplier", multiplier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual fixed GetSpeedMultiplier() const
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<fixed>("GetSpeedMultiplier");
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 10:59:46 -08:00
|
|
|
virtual CFixedVector2D EstimateFuturePosition(const fixed dt) const
|
2021-01-19 07:59:03 -08:00
|
|
|
{
|
|
|
|
|
return m_Script.Call<CFixedVector2D>("EstimateFuturePosition", dt);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-30 16:52:22 -07:00
|
|
|
virtual void SetFacePointAfterMove(bool facePointAfterMove)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("SetFacePointAfterMove", facePointAfterMove);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-19 03:42:45 -07:00
|
|
|
virtual bool GetFacePointAfterMove() const
|
|
|
|
|
{
|
|
|
|
|
return m_Script.Call<bool>("GetFacePointAfterMove");
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual pass_class_t GetPassabilityClass() const
|
2011-08-06 01:11:05 -07:00
|
|
|
{
|
New long-range pathfinder.
Based on Philip's work located at
http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.
An updated version of docs/pathfinder.pdf describing the changes in
detail will be committed ASAP.
Running update-workspaces is needed after this change.
Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563
This was SVN commit r16751.
2015-06-12 11:58:24 -07:00
|
|
|
return m_Script.Call<pass_class_t>("GetPassabilityClass");
|
2011-08-06 01:11:05 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual std::string GetPassabilityClassName() const
|
2014-05-18 00:59:43 -07:00
|
|
|
{
|
|
|
|
|
return m_Script.Call<std::string>("GetPassabilityClassName");
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-19 18:25:19 -08:00
|
|
|
virtual entity_pos_t GetUnitClearance() const
|
2011-06-09 12:44:40 -07:00
|
|
|
{
|
2015-07-18 01:37:49 -07:00
|
|
|
return m_Script.Call<entity_pos_t>("GetUnitClearance");
|
2011-06-09 12:44:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void SetDebugOverlay(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
m_Script.CallVoid("SetDebugOverlay", enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
REGISTER_COMPONENT_SCRIPT_WRAPPER(UnitMotionScripted)
|