2011-06-09 21:44:40 +02:00
|
|
|
/* Copyright (C) 2011 Wildfire Games.
|
2010-01-09 20:20:14 +01: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 21:44:40 +02:00
|
|
|
#include "simulation2/scripting/ScriptComponent.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
|
|
|
|
BEGIN_INTERFACE_WRAPPER(UnitMotion)
|
2010-07-18 17:19:49 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_4("MoveToPointRange", bool, ICmpUnitMotion, MoveToPointRange, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t)
|
2012-12-02 18:25:23 +01:00
|
|
|
DEFINE_INTERFACE_METHOD_4("IsInPointRange", bool, ICmpUnitMotion, IsInPointRange, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t)
|
2010-11-30 13:31:54 +01:00
|
|
|
DEFINE_INTERFACE_METHOD_3("IsInTargetRange", bool, ICmpUnitMotion, IsInTargetRange, entity_id_t, entity_pos_t, entity_pos_t)
|
|
|
|
DEFINE_INTERFACE_METHOD_3("MoveToTargetRange", bool, ICmpUnitMotion, MoveToTargetRange, entity_id_t, entity_pos_t, entity_pos_t)
|
2010-09-03 11:55:14 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_3("MoveToFormationOffset", void, ICmpUnitMotion, MoveToFormationOffset, entity_id_t, entity_pos_t, entity_pos_t)
|
2011-06-09 21:44:40 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_2("FaceTowardsPoint", void, ICmpUnitMotion, FaceTowardsPoint, entity_pos_t, entity_pos_t)
|
2010-07-18 17:19:49 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_0("StopMoving", void, ICmpUnitMotion, StopMoving)
|
2012-12-06 20:46:13 +01:00
|
|
|
DEFINE_INTERFACE_METHOD_0("GetCurrentSpeed", fixed, ICmpUnitMotion, GetCurrentSpeed)
|
2010-07-20 10:45:09 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_1("SetSpeed", void, ICmpUnitMotion, SetSpeed, fixed)
|
2012-08-31 10:20:36 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_0("IsMoving", bool, ICmpUnitMotion, IsMoving)
|
2010-07-20 10:45:09 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_0("GetWalkSpeed", fixed, ICmpUnitMotion, GetWalkSpeed)
|
|
|
|
DEFINE_INTERFACE_METHOD_0("GetRunSpeed", fixed, ICmpUnitMotion, GetRunSpeed)
|
2014-05-18 09:59:43 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_0("GetPassabilityClassName", std::string, ICmpUnitMotion, GetPassabilityClassName)
|
|
|
|
DEFINE_INTERFACE_METHOD_1("SetPassabilityClassName", void, ICmpUnitMotion, SetPassabilityClassName, std::string)
|
2013-10-01 01:52:22 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_1("SetFacePointAfterMove", void, ICmpUnitMotion, SetFacePointAfterMove, bool)
|
2010-09-03 11:55:14 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_1("SetUnitRadius", void, ICmpUnitMotion, SetUnitRadius, fixed)
|
2010-04-30 01:36:05 +02:00
|
|
|
DEFINE_INTERFACE_METHOD_1("SetDebugOverlay", void, ICmpUnitMotion, SetDebugOverlay, bool)
|
2010-01-09 20:20:14 +01:00
|
|
|
END_INTERFACE_WRAPPER(UnitMotion)
|
2011-06-09 21:44:40 +02: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);
|
|
|
|
}
|
|
|
|
|
2012-12-02 18:25:23 +01:00
|
|
|
virtual bool IsInPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange)
|
|
|
|
{
|
|
|
|
return m_Script.Call<bool>("IsInPointRange", x, z, minRange, maxRange);
|
|
|
|
}
|
|
|
|
|
2011-06-09 21:44:40 +02:00
|
|
|
virtual bool IsInTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
|
|
|
|
{
|
|
|
|
return m_Script.Call<bool>("IsInTargetRange", target, 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void FaceTowardsPoint(entity_pos_t x, entity_pos_t z)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("FaceTowardsPoint", x, z);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void StopMoving()
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("StopMoving");
|
|
|
|
}
|
|
|
|
|
2012-12-06 20:46:13 +01:00
|
|
|
virtual fixed GetCurrentSpeed()
|
|
|
|
{
|
|
|
|
return m_Script.Call<fixed>("GetCurrentSpeed");
|
|
|
|
}
|
|
|
|
|
2011-06-09 21:44:40 +02:00
|
|
|
virtual void SetSpeed(fixed speed)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("SetSpeed", speed);
|
|
|
|
}
|
|
|
|
|
2012-08-31 10:20:36 +02:00
|
|
|
virtual bool IsMoving()
|
|
|
|
{
|
|
|
|
return m_Script.Call<bool>("IsMoving");
|
|
|
|
}
|
|
|
|
|
2011-06-09 21:44:40 +02:00
|
|
|
virtual fixed GetWalkSpeed()
|
|
|
|
{
|
|
|
|
return m_Script.Call<fixed>("GetWalkSpeed");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual fixed GetRunSpeed()
|
|
|
|
{
|
|
|
|
return m_Script.Call<fixed>("GetRunSpeed");
|
|
|
|
}
|
|
|
|
|
2013-10-01 01:52:22 +02:00
|
|
|
virtual void SetFacePointAfterMove(bool facePointAfterMove)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("SetFacePointAfterMove", facePointAfterMove);
|
|
|
|
}
|
|
|
|
|
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 20:58:24 +02:00
|
|
|
virtual pass_class_t GetPassabilityClass()
|
2011-08-06 10:11:05 +02: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 20:58:24 +02:00
|
|
|
return m_Script.Call<pass_class_t>("GetPassabilityClass");
|
2011-08-06 10:11:05 +02:00
|
|
|
}
|
|
|
|
|
2014-05-18 09:59:43 +02:00
|
|
|
virtual std::string GetPassabilityClassName()
|
|
|
|
{
|
|
|
|
return m_Script.Call<std::string>("GetPassabilityClassName");
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetPassabilityClassName(std::string passClassName)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("SetPassabilityClassName", passClassName);
|
|
|
|
}
|
|
|
|
|
2011-06-09 21:44:40 +02:00
|
|
|
virtual void SetUnitRadius(fixed radius)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("SetUnitRadius", radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetDebugOverlay(bool enabled)
|
|
|
|
{
|
|
|
|
m_Script.CallVoid("SetDebugOverlay", enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_COMPONENT_SCRIPT_WRAPPER(UnitMotionScripted)
|