18#ifndef INCLUDED_CCMPUNITMOTION
19#define INCLUDED_CCMPUNITMOTION
64#define DISABLE_PATHFINDER 0
210 std::uint32_t m_Ticket = 0;
214 } m_Type = SHORT_PATH;
265 "<a:help>Provides the unit with the ability to move around the world by itself.</a:help>"
267 "<WalkSpeed>7.0</WalkSpeed>"
268 "<PassabilityClass>default</PassabilityClass>"
270 "<element name='FormationController'>"
271 "<data type='boolean'/>"
273 "<element name='WalkSpeed' a:help='Basic movement speed (in meters per second).'>"
274 "<ref name='positiveDecimal'/>"
277 "<element name='RunMultiplier' a:help='How much faster the unit goes when running (as a multiple of walk speed).'>"
278 "<ref name='positiveDecimal'/>"
281 "<element name='InstantTurnAngle' a:help='Angle we can turn instantly. Any value greater than pi will disable turning times. Avoid zero since it stops the entity every turn.'>"
282 "<ref name='positiveDecimal'/>"
284 "<element name='Acceleration' a:help='Acceleration (in meters per second^2).'>"
285 "<ref name='positiveDecimal'/>"
287 "<element name='PassabilityClass' a:help='Identifies the terrain passability class (values are defined in special/pathfinder.xml).'>"
290 "<element name='Weight' a:help='Makes this unit both push harder and harder to push. 10 is considered the base value.'>"
291 "<ref name='positiveDecimal'/>"
294 "<element name='DisablePushing'>"
295 "<data type='boolean'/>"
395 case MT_RenderSubmit:
397 PROFILE(
"UnitMotion::RenderSubmit");
420 case MT_MovementObstructionChanged:
427 case MT_ValueModification:
434 case MT_OwnershipChanged:
439 case MT_Deserialized:
492 if (!cmpPosition || !cmpPosition->IsInWorld())
504 PerformMove(dt, cmpPosition->GetTurnRate(), shortPath, longPath, pos, speed, angle, 0);
537 LOGWARNING(
"Only formation controllers can change their passability class");
617 if (cmpPosition && cmpPosition->IsInWorld())
645 return cmpControllerMotion && cmpControllerMotion->IsMoveRequested();
656 m_Pushing = pushing && cmpUnitMotionManager->IsPushingActivated();
665 m_PassClass = cmpPathfinder->GetPassabilityClass(passClassName);
775 if (!cmpValueModificationManager)
916 bool MoveTo(MoveRequest request);
930 if (path.m_Waypoints.empty())
934 if (goal.DistanceToPoint(pos) <= goal.DistanceToPoint(
CFixedVector2D(path.m_Waypoints.front().x, path.m_Waypoints.front().z)))
952 if (!cmpPosition || !cmpPosition->IsInWorld())
960 bool shortPathHack =
false;
964 if (!pathedTowardsGoal)
1001 if (ticketType == Ticket::LONG_PATH)
1008 if (m_LongPath.m_Waypoints.size() >= 2)
1010 const Waypoint& firstWpt = m_LongPath.m_Waypoints.back();
1015 const Waypoint& secondWpt = m_LongPath.m_Waypoints[m_LongPath.m_Waypoints.size() - 2];
1016 if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.X, pos.Y, secondWpt.
x, secondWpt.
z, m_Clearance, m_PassClass))
1017 m_LongPath.m_Waypoints.pop_back();
1025 m_FollowKnownImperfectPathCountdown = 0;
1027 if (!pathedTowardsGoal)
1037 if (PathingUpdateNeeded(pos))
1042 if (!IncrementFailedMovementsAndMaybeNotify())
1072 state.wasObstructed =
false;
1073 state.wentStraight =
false;
1076 state.needUpdate =
state.cmpPosition->IsInWorld() &&
1089 cmpObstruction->SetMovingFlag(
state.isMoving);
1137 if (cmpTargetObstruction)
1138 specificIgnore = cmpTargetObstruction->GetObstruction();
1141 if (cmpObstructionManager && cmpObstructionManager->TestUnitLine(
GetObstructionFilter(specificIgnore),
1163 if (
state.wentStraight && !
state.wasObstructed)
1168 if (!
state.wentStraight && needPathUpdate)
1184 ENSURE(cmpObstructionManager);
1189 return cmpObstructionManager->IsInPointRange(
1194 return cmpObstructionManager->IsInTargetRange(
1201 if (cmpControllerMotion && cmpControllerMotion->IsMoveRequested())
1236 if (pushingPressure)
1239 constexpr int pressureMinThreshold = 10;
1245 static_assert(maxPressure > 0);
1247 uint8_t slowdown = maxPressure - std::min(maxPressure, std::max(0, pushingPressure - pressureMinThreshold));
1258 fixed maxSpeed = basicSpeed;
1260 fixed timeLeft = dt;
1267 if (cmpTargetObstruction)
1268 specificIgnore = cmpTargetObstruction->GetObstruction();
1271 while (timeLeft > zero)
1285 if (turnRate > zero && !offset.
IsZero())
1306 angle += maxRotation * direction;
1313 timeLeft = std::min(maxRotation, maxRotation - absoluteAngleDiff +
m_InstantTurnAngle) / turnRate;
1328 fixed maxdist = accelDist + maxSpeed.
Multiply(timeLeft - accelTime);
1332 if (offsetLength <= maxdist)
1342 if (offsetLength <= accelDist)
1345 timeLeft -= requiredTime;
1350 timeLeft -= accelTime + (offsetLength - accelDist) / maxSpeed;
1371 target = pos + offset;
1404 if (!cmpPosition || !cmpPosition->IsInWorld())
1440 Waypoint next = m_ShortPath.m_Waypoints.back();
1441 CFixedVector2D backUp(pos.X - next.x, pos.Y - next.z);
1443 next.x = pos.X + backUp.X;
1444 next.z = pos.Y + backUp.Y;
1445 m_ShortPath.m_Waypoints.push_back(next);
1457 m_LongPath.m_Waypoints.pop_back();
1489 return cmpPosition && cmpPosition->IsInWorld();
1501 if (!cmpTargetPosition || !cmpTargetPosition->IsInWorld())
1509 out = cmpTargetPosition->GetPosition2D() + offset;
1513 out = cmpTargetPosition->GetPosition2D();
1524 bool needInterpolation = cmpUnitMotion && cmpUnitMotion->IsMoveRequested() && cmpUnitMotionManager->ComputingMotion();
1525 if (needInterpolation)
1555 goal.
x = targetPos.
X;
1556 goal.
z = targetPos.
Y;
1573 if (cmpTargetObstruction)
1574 specificIgnore = cmpTargetObstruction->GetObstruction();
1578 if (specificIgnore.
valid())
1616 if (cmpTargetObstruction)
1617 cmpTargetObstruction->GetObstructionSquare(estimatedTargetShape);
1620 estimatedTargetShape.
x = targetPos.
X;
1621 estimatedTargetShape.
z = targetPos.
Y;
1626 cmpObstruction->GetObstructionSquare(shape);
1637 shape.
x = lastWaypoint.
x;
1638 shape.
z = lastWaypoint.
z;
1642 ENSURE(cmpObstructionManager);
1652 if (cmpObstructionManager->AreShapesInRange(shape, estimatedTargetShape, minRange, maxRange,
false))
1661 if (!cmpPosition || !cmpPosition->IsInWorld())
1679 cmpPosition->TurnTo(angle);
1693 return (range > circleRadius*3);
1702 if (!cmpPosition || !cmpPosition->IsInWorld())
1715 if (cmpTargetObstruction)
1716 cmpTargetObstruction->GetObstructionSquare(targetObstruction);
1718 targetObstruction.
x = targetPosition.
X;
1719 targetObstruction.
z = targetPosition.
Y;
1724 cmpObstruction->GetObstructionSquare(obstruction);
1727 obstruction.
x = pos.
X;
1728 obstruction.
z = pos.
Y;
1732 ENSURE(cmpObstructionManager);
1734 out.x = targetObstruction.
x;
1735 out.z = targetObstruction.
z;
1736 out.hw = targetObstruction.
hw;
1737 out.hh = targetObstruction.
hh;
1738 out.u = targetObstruction.
u;
1739 out.v = targetObstruction.
v;
1750 entity_pos_t distance = cmpObstructionManager->DistanceBetweenShapes(obstruction, targetObstruction);
1771 out.hw = circleRadius + goalDistance;
1776 out.hw = targetObstruction.
hw + goalDistance;
1777 out.hh = targetObstruction.
hh + goalDistance;
1786 circleRadius = std::min(targetObstruction.
hw, targetObstruction.
hh);
1789 out.hw = circleRadius + goalDistance;
1800 out.hw = targetObstruction.
hw + delta;
1801 out.hh = targetObstruction.
hh + delta;
1810#if DISABLE_PATHFINDER
1845 shortPath = !shortPath;
1870 cmpPathfinder->SetDebugPath(from.
X, from.
Y, improvedGoal,
m_PassClass);
1903 LOGWARNING(
"MaxRange must be larger than MinRange; See CCmpUnitMotion.cpp for more information");
1906 if (!cmpPosition || !cmpPosition->IsInWorld())
1924 if (!cmpPosition || !cmpPosition->IsInWorld())
1934 return cmpPathfinder->IsGoalReachable(pos.
X, pos.
Y, goal,
m_PassClass);
1939 bool floating =
false;
1942 floating = cmpPosition->CanFloat();
1945 std::vector<float> waypointCoords;
1946 for (
size_t i = 0; i < path.
m_Waypoints.size(); ++i)
1950 waypointCoords.push_back(x);
1951 waypointCoords.push_back(z);
1953 lines.back().m_Color = color;
1956 float x = cmpPosition->GetPosition2D().X.ToFloat();
1957 float z = cmpPosition->GetPosition2D().Y.ToFloat();
1958 waypointCoords.push_back(x);
1959 waypointCoords.push_back(z);
1961 lines.back().m_Color = color;
#define LOGWARNING(fmtstring,...)
Definition: CLogger.h:41
#define DEFAULT_COMPONENT_ALLOCATOR(cname)
Definition: Component.h:39
#define REGISTER_COMPONENT_TYPE(cname)
Definition: Component.h:32
CFixed_15_16 atan2_approx(CFixed_15_16 y, CFixed_15_16 x)
Inaccurate approximation of atan2 over fixed-point numbers.
Definition: Fixed.cpp:149
void sincos_approx(CFixed_15_16 a, CFixed_15_16 &sin_out, CFixed_15_16 &cos_out)
Compute sin(a) and cos(a).
Definition: Fixed.cpp:189
T Clamp(T value, T min, T max)
Definition: MathUtil.h:34
std::uint16_t pass_class_t
Definition: Pathfinding.h:33
#define PROFILE(name)
Definition: Profile.h:157
Helper templates definitions for serializing/deserializing common objects.
void Serializer(S &serialize, const char *name, Args &&... args)
Definition: SerializeTemplates.h:51
Provide specializations for some generic types and containers.
Definition: CCmpUnitMotionManager.h:38
static constexpr int MAX_PRESSURE
Maximum value for pushing pressure.
Definition: CCmpUnitMotionManager.h:47
Definition: CCmpUnitMotion.h:151
bool MoveTo(MoveRequest request)
General handler for MoveTo interface functions.
Definition: CCmpUnitMotion.h:1898
bool m_IsFormationController
Definition: CCmpUnitMotion.h:173
void Init(const CParamNode ¶mNode) override
Definition: CCmpUnitMotion.h:300
fixed m_CurrentSpeed
Definition: CCmpUnitMotion.h:251
void PathResult(std::uint32_t ticket, const WaypointPath &path)
Handle the result of an asynchronous path query.
Definition: CCmpUnitMotion.h:940
bool ComputeGoal(PathGoal &out, const MoveRequest &moveRequest) const
Create a PathGoal from a move request.
Definition: CCmpUnitMotion.h:1696
entity_pos_t GetWeight() const
Definition: CCmpUnitMotion.h:518
bool MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange) override
Attempt to walk into range of a to a given point, or as close as possible.
Definition: CCmpUnitMotion.h:574
CFixedVector2D EstimateFuturePosition(const fixed dt) const override
Definition: CCmpUnitMotion.h:489
bool ShouldTreatTargetAsCircle(entity_pos_t range, entity_pos_t circleRadius) const
Decide whether to approximate the given range from a square target as a circle, rather than as a squa...
Definition: CCmpUnitMotion.h:1686
static std::string GetSchema()
Definition: CCmpUnitMotion.h:262
void SetDebugOverlay(bool enabled) override
Toggle the rendering of debug info.
Definition: CCmpUnitMotion.h:568
fixed GetRunMultiplier() const override
Get the unit template running (i.e.
Definition: CCmpUnitMotion.h:484
bool GetFacePointAfterMove() const override
Definition: CCmpUnitMotion.h:563
fixed GetCurrentSpeed() const override
Get the speed at the end of the current turn.
Definition: CCmpUnitMotion.h:543
fixed m_Acceleration
Definition: CCmpUnitMotion.h:255
void RequestShortPath(const CFixedVector2D &from, const PathGoal &goal, bool extendRange)
Start an asynchronous short path query.
Definition: CCmpUnitMotion.h:1876
std::uint8_t m_FailedMovements
Definition: CCmpUnitMotion.h:198
bool InShortPathRange(const PathGoal &goal, const CFixedVector2D &pos) const
Definition: CCmpUnitMotion.h:752
bool TryGoingStraightToTarget(const CFixedVector2D &from, bool updatePaths)
Attempts to replace the current path with a straight line to the target, if it's close enough and the...
Definition: CCmpUnitMotion.h:1535
WaypointPath m_LongPath
Definition: CCmpUnitMotion.h:259
bool PossiblyAtDestination() const override
Returns true if we are possibly at our destination.
Definition: CCmpUnitMotion.h:1178
struct CCmpUnitMotion::Ticket m_ExpectedPathTicket
void Deinit() override
Definition: CCmpUnitMotion.h:332
SkipTagAndControlGroupObstructionFilter GetObstructionFilter(const ICmpObstructionManager::tag_t &tag) const
Filter a specific tag on top of the existing control groups.
Definition: CCmpUnitMotion.h:879
bool ComputeTargetPosition(CFixedVector2D &out) const
Definition: CCmpUnitMotion.h:836
fixed GetWalkSpeed() const override
Get the unit template walk speed after modifications.
Definition: CCmpUnitMotion.h:479
void StopMoving() override
Clears the current MoveRequest - the unit will stop and no longer try and move.
Definition: CCmpUnitMotion.h:612
bool IsFormationControllerMoving() const
Definition: CCmpUnitMotion.h:642
fixed m_LastTurnSpeed
Definition: CCmpUnitMotion.h:248
bool ShouldAlternatePathfinder() const
Definition: CCmpUnitMotion.h:747
bool m_Pushing
Definition: CCmpUnitMotion.h:189
void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize) override
Definition: CCmpUnitMotion.h:378
static void ClassInit(CComponentManager &componentManager)
Definition: CCmpUnitMotion.h:154
std::string m_PassClassName
Definition: CCmpUnitMotion.h:177
entity_pos_t ShortPathSearchRange() const
Definition: CCmpUnitMotion.h:757
bool IsMovingAsFormation() const override
Definition: CCmpUnitMotion.h:458
fixed m_InstantTurnAngle
Definition: CCmpUnitMotion.h:253
void ComputePathToGoal(const CFixedVector2D &from, const PathGoal &goal)
Compute a path to the given goal from the given position.
Definition: CCmpUnitMotion.h:1808
void RenderPath(const WaypointPath &path, std::vector< SOverlayLine > &lines, CColor color)
Convert a path into a renderable list of lines.
Definition: CCmpUnitMotion.h:1937
fixed m_RunMultiplier
Definition: CCmpUnitMotion.h:184
void SetParticipateInPushing(bool pushing)
Definition: CCmpUnitMotion.h:653
void OnTurnStart()
Check if we are at destination early in the turn, this both lets units react faster and ensure that d...
Definition: CCmpUnitMotion.h:1050
fixed m_SpeedMultiplier
Definition: CCmpUnitMotion.h:243
void RenderSubmit(SceneCollector &collector)
Definition: CCmpUnitMotion.h:1966
std::string GetPassabilityClassName() const override
Get the passability class name (as defined in pathfinder.xml)
Definition: CCmpUnitMotion.h:528
struct CCmpUnitMotion::MoveRequest m_MoveRequest
bool IsMoveRequested() const override
Definition: CCmpUnitMotion.h:453
bool ShouldCollideWithMovingUnits() const
Units in 'pushing' mode are marked as 'moving' in the obstruction manager.
Definition: CCmpUnitMotion.h:864
entity_id_t GetGroup() const
Definition: CCmpUnitMotion.h:648
void FaceTowardsPointFromPos(const CFixedVector2D &pos, entity_pos_t x, entity_pos_t z)
Rotate to face towards the target point, given the current pos.
Definition: CCmpUnitMotion.h:1668
void RequestLongPath(const CFixedVector2D &from, const PathGoal &goal)
Start an asynchronous long path query.
Definition: CCmpUnitMotion.h:1859
fixed m_WalkSpeed
Definition: CCmpUnitMotion.h:184
bool m_BlockMovement
Definition: CCmpUnitMotion.h:193
void SetPassabilityClassName(const std::string &passClassName) override
Sets the passability class name (as defined in pathfinder.xml)
Definition: CCmpUnitMotion.h:533
pass_class_t m_PassClass
Definition: CCmpUnitMotion.h:176
void SetAcceleration(fixed acceleration) override
Set the current acceleration.
Definition: CCmpUnitMotion.h:513
bool HandleObstructedMove(bool moved)
React if our move was obstructed.
Definition: CCmpUnitMotion.h:1401
std::vector< SOverlayLine > m_DebugOverlayShortPathLines
Definition: CCmpUnitMotion.h:169
bool m_DebugOverlayEnabled
Definition: CCmpUnitMotion.h:167
std::optional< CFixedVector2D > GetFormationOffset() const override
Get the current formation offset if this unit is moving as a formation member.
Definition: CCmpUnitMotion.h:595
bool PathingUpdateNeeded(const CFixedVector2D &from) const
Returns whether our we need to recompute a path to reach our target.
Definition: CCmpUnitMotion.h:1596
std::vector< SOverlayLine > m_DebugOverlayLongPathLines
Definition: CCmpUnitMotion.h:168
bool IsFormationMember() const
Definition: CCmpUnitMotion.h:637
void SetPassabilityData(const std::string &passClassName)
Definition: CCmpUnitMotion.h:659
void HandleMessage(const CMessage &msg, bool) override
Definition: CCmpUnitMotion.h:391
void MoveFailed()
Warns other components that our current movement will likely fail (e.g.
Definition: CCmpUnitMotion.h:679
fixed m_Speed
Definition: CCmpUnitMotion.h:245
bool IncrementFailedMovementsAndMaybeNotify()
Increment the number of failed movements and notify other components if required.
Definition: CCmpUnitMotion.h:730
void MoveToFormationOffset(entity_id_t controller, entity_pos_t x, entity_pos_t z) override
Join a formation, and move towards a given offset relative to the formation controller entity.
Definition: CCmpUnitMotion.h:584
bool PerformMove(fixed dt, const fixed &turnRate, WaypointPath &shortPath, WaypointPath &longPath, CFixedVector2D &pos, fixed &speed, entity_angle_t &angle, uint8_t pushingPressure) const
Process the move the unit will do this turn.
Definition: CCmpUnitMotion.h:1215
void Move(CCmpUnitMotionManager::MotionState &state, fixed dt)
Definition: CCmpUnitMotion.h:1092
fixed m_TemplateRunMultiplier
Definition: CCmpUnitMotion.h:175
void SetSpeedMultiplier(fixed multiplier) override
Set the current movement speed.
Definition: CCmpUnitMotion.h:468
fixed m_TemplateWeight
Definition: CCmpUnitMotion.h:175
void MoveObstructed()
Warns other components that our current movement was obstructed (i.e.
Definition: CCmpUnitMotion.h:713
WaypointPath m_ShortPath
Definition: CCmpUnitMotion.h:260
void SerializeCommon(S &serialize)
Definition: CCmpUnitMotion.h:337
bool m_FacePointAfterMove
Definition: CCmpUnitMotion.h:186
void PreMove(CCmpUnitMotionManager::MotionState &state)
Definition: CCmpUnitMotion.h:1068
void Serialize(ISerializer &serialize) override
Definition: CCmpUnitMotion.h:373
void MoveSucceeded()
Warns other components that our current movement is likely over (i.e.
Definition: CCmpUnitMotion.h:696
void UpdateMessageSubscriptions()
Definition: CCmpUnitMotion.h:447
void SetCurrentSpeed(const fixed &speed) override
Set the speed.
Definition: CCmpUnitMotion.h:548
fixed m_TemplateAcceleration
Definition: CCmpUnitMotion.h:175
void FaceTowardsPoint(entity_pos_t x, entity_pos_t z) override
Turn to look towards the given point.
Definition: CCmpUnitMotion.h:1658
void SetMemberOfFormation(entity_id_t controller) override
Set/unset the unit as a formation member.
Definition: CCmpUnitMotion.h:590
fixed GetSpeedMultiplier() const override
Returns the ratio of GetSpeed() / GetWalkSpeed().
Definition: CCmpUnitMotion.h:463
void SetFacePointAfterMove(bool facePointAfterMove) override
Set whether the unit will turn to face the target point after finishing moving.
Definition: CCmpUnitMotion.h:558
fixed GetAcceleration() const override
Get the current acceleration.
Definition: CCmpUnitMotion.h:508
entity_pos_t m_Clearance
Definition: CCmpUnitMotion.h:181
fixed m_TemplateWalkSpeed
Definition: CCmpUnitMotion.h:175
void UpdateMovementState(entity_pos_t speed, entity_pos_t meanSpeed)
Update other components on our speed.
Definition: CCmpUnitMotion.h:1386
bool RejectFartherPaths(const PathGoal &goal, const WaypointPath &path, const CFixedVector2D &pos) const
If path would take us farther away from the goal than pos currently is, return false,...
Definition: CCmpUnitMotion.h:928
pass_class_t GetPassabilityClass() const override
Get the unit's passability class.
Definition: CCmpUnitMotion.h:523
std::uint8_t m_FollowKnownImperfectPathCountdown
Definition: CCmpUnitMotion.h:207
void OnValueModification()
Definition: CCmpUnitMotion.h:772
entity_pos_t GetUnitClearance() const override
Get the unit clearance (used by the Obstruction component)
Definition: CCmpUnitMotion.h:631
bool ComputeTargetPosition(CFixedVector2D &out, const MoveRequest &moveRequest) const
Computes the current location of our target entity (plus offset).
Definition: CCmpUnitMotion.h:1492
entity_id_t m_FormationController
Definition: CCmpUnitMotion.h:240
fixed GetSpeed() const override
Get the speed at which the unit intends to move.
Definition: CCmpUnitMotion.h:474
ControlGroupMovementObstructionFilter GetObstructionFilter() const
Returns an appropriate obstruction filter for use with path requests.
Definition: CCmpUnitMotion.h:872
bool TargetHasValidPosition() const
Definition: CCmpUnitMotion.h:826
bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) override
Attempt to walk into range of a given target entity, or as close as possible.
Definition: CCmpUnitMotion.h:579
bool IsTargetRangeReachable(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) override
Check if the target is reachable.
Definition: CCmpUnitMotion.h:1921
void PostMove(CCmpUnitMotionManager::MotionState &state, fixed dt)
Definition: CCmpUnitMotion.h:1104
Definition: ComponentManager.h:46
void PostMessage(entity_id_t ent, const CMessage &msg)
Send a message, targeted at a particular entity.
Definition: ComponentManager.cpp:1050
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
Definition: ComponentManager.cpp:576
void DynamicSubscriptionNonsync(MessageTypeId mtid, IComponent *component, bool enabled)
Subscribe the given component instance to all messages of the given message type.
Definition: ComponentManager.cpp:616
Definition: FixedVector2D.h:25
fixed X
Definition: FixedVector2D.h:27
int CompareLength(fixed cmp) const
Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument.
Definition: FixedVector2D.h:122
CFixedVector2D Rotate(fixed angle) const
Rotate the vector by the given angle (anticlockwise).
Definition: FixedVector2D.h:241
fixed Length() const
Returns the length of the vector.
Definition: FixedVector2D.h:101
fixed Y
Definition: FixedVector2D.h:27
bool IsZero() const
Definition: FixedVector2D.h:172
void Normalize()
Normalize the vector so that length is close to 1.
Definition: FixedVector2D.h:181
A simple fixed-point number class.
Definition: Fixed.h:129
static constexpr CFixed FromFraction(int n, int d)
Definition: Fixed.h:155
constexpr CFixed Absolute() const
Definition: Fixed.h:325
static CFixed Zero()
Definition: Fixed.h:140
constexpr CFixed Square() const
Multiply the value by itself.
Definition: Fixed.h:343
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:331
constexpr bool IsZero() const
Returns true if the number is precisely 0.
Definition: Fixed.h:218
static constexpr CFixed FromInt(int n)
Definition: Fixed.h:149
static CFixed Pi()
Definition: Fixed.cpp:184
Sent by CCmpUnitMotion during Update if an event happened that might interest other components.
Definition: MessageTypes.h:313
@ LIKELY_FAILURE
Definition: MessageTypes.h:319
@ VERY_OBSTRUCTED
Definition: MessageTypes.h:321
@ LIKELY_SUCCESS
Definition: MessageTypes.h:318
@ OBSTRUCTED
Definition: MessageTypes.h:320
Sent by CCmpPathfinder after async path requests.
Definition: MessageTypes.h:470
WaypointPath path
Definition: MessageTypes.h:480
std::uint32_t ticket
Definition: MessageTypes.h:479
Add renderable objects to the scene collector.
Definition: MessageTypes.h:155
SceneCollector & collector
Definition: MessageTypes.h:164
Sent by aura manager when a value of a certain entity's component is changed.
Definition: MessageTypes.h:487
std::wstring component
Definition: MessageTypes.h:499
virtual int GetType() const =0
An entity initialisation parameter node.
Definition: ParamNode.h:153
bool ToBool() const
Parses the content of this node as a boolean ("true" == true, anything else == false)
Definition: ParamNode.cpp:310
const CParamNode & GetChild(const char *name) const
Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none.
Definition: ParamNode.cpp:267
const std::string & ToString() const
Returns the content of this node as an UTF8 string.
Definition: ParamNode.cpp:285
bool IsOk() const
Returns true if this is a valid CParamNode, false if it represents a non-existent node.
Definition: ParamNode.cpp:275
fixed ToFixed() const
Parses the content of this node as a fixed-point number.
Definition: ParamNode.cpp:300
CComponentManager & GetComponentManager() const
Definition: SimContext.cpp:37
A simplified syntax for accessing entity components.
Definition: CmpPtr.h:58
Obstruction test filter that reject shapes in a given control group, and rejects shapes that don't bl...
Definition: ICmpObstructionManager.h:406
Motion interface for entities with complex movement capabilities.
Definition: ICmpUnitMotion.h:41
entity_id_t GetEntityId() const
Definition: IComponent.h:57
const CSimContext & GetSimContext() const
Definition: IComponent.h:61
CEntityHandle GetEntityHandle() const
Definition: IComponent.h:54
CEntityHandle GetSystemEntity() const
Definition: IComponent.h:59
Deserialization interface; see serialization overview.
Definition: IDeserializer.h:40
Serialization interface; see serialization overview.
Definition: ISerializer.h:126
Pathfinder goal.
Definition: PathGoal.h:34
@ SQUARE
Definition: PathGoal.h:40
@ CIRCLE
Definition: PathGoal.h:38
@ INVERTED_CIRCLE
Definition: PathGoal.h:39
@ INVERTED_SQUARE
Definition: PathGoal.h:41
@ POINT
Definition: PathGoal.h:37
fixed DistanceToPoint(CFixedVector2D pos) const
Returns the minimum distance from the point pos to any point on the goal shape.
Definition: PathGoal.cpp:296
CFixedVector2D NearestPointOnGoal(CFixedVector2D pos) const
Returns the coordinates of the point on the goal that is closest to the point pos.
Definition: PathGoal.cpp:329
entity_pos_t z
Definition: PathGoal.h:44
entity_pos_t maxdist
Definition: PathGoal.h:50
entity_pos_t x
Definition: PathGoal.h:44
This interface accepts renderable objects.
Definition: Scene.h:90
virtual void Submit(CPatch *patch)=0
Submit a terrain patch that is part of the scene.
Similar to ControlGroupMovementObstructionFilter, but also ignoring a specific tag.
Definition: ICmpObstructionManager.h:547
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:222
enum PS::Loader::anonymous_namespace{Loader.cpp}::@26 state
constexpr fixed NAVCELL_SIZE
The long-range pathfinder operates primarily over a navigation grid (a uniform-cost 2D passability gr...
Definition: Pathfinding.h:145
constexpr int NAVCELL_SIZE_INT
Definition: Pathfinding.h:146
void ConstructSquareOnGround(const CSimContext &context, float x, float z, float w, float h, float a, SOverlayLine &overlay, bool floating, float heightOffset=0.25f)
Constructs overlay line as rectangle with given center and dimensions, conforming to terrain.
Definition: Render.cpp:160
void ConstructLineOnGround(const CSimContext &context, const std::vector< float > &xz, SOverlayLine &overlay, bool floating, float heightOffset=0.25f)
Constructs overlay line from given points, conforming to terrain.
Definition: Render.cpp:45
constexpr std::uint8_t SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY
Definition: CCmpUnitMotion.h:76
constexpr entity_pos_t SHORT_PATH_MIN_SEARCH_RANGE
Min/Max range to restrict short path queries to.
Definition: CCmpUnitMotion.h:73
constexpr std::uint8_t ALTERNATE_PATH_TYPE_DELAY
When computing paths but failing to move, we want to occasionally alternate pathfinder systems to avo...
Definition: CCmpUnitMotion.h:123
constexpr std::uint8_t MAX_FAILED_MOVEMENTS
When we fail to move this many turns in a row, inform other components that the move will fail.
Definition: CCmpUnitMotion.h:117
constexpr entity_pos_t DIRECT_PATH_RANGE
If we are this close to our target entity/point, then think about heading for it in a straight line i...
Definition: CCmpUnitMotion.h:92
constexpr entity_pos_t TARGET_UNCERTAINTY_MULTIPLIER
To avoid recomputing paths too often, have some leeway for target range checks based on our distance ...
Definition: CCmpUnitMotion.h:99
constexpr entity_pos_t SHORT_PATH_MAX_SEARCH_RANGE
Definition: CCmpUnitMotion.h:74
constexpr std::uint8_t VERY_OBSTRUCTED_THRESHOLD
After this many failed computations, start sending "VERY_OBSTRUCTED" messages instead.
Definition: CCmpUnitMotion.h:138
constexpr entity_pos_t SHORT_PATH_LONG_WAYPOINT_RANGE
When using the short-pathfinder to rejoin a long-path waypoint, aim for a circle of this radius aroun...
Definition: CCmpUnitMotion.h:81
constexpr std::uint8_t BACKUP_HACK_DELAY
Units can occasionally get stuck near corners.
Definition: CCmpUnitMotion.h:132
constexpr PathColorPalette FORMATION_CONTROLLER_PALETTE
Definition: CCmpUnitMotion.h:147
constexpr std::uint8_t KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN
When following a known imperfect path (i.e.
Definition: CCmpUnitMotion.h:108
constexpr PathColorPalette REGULAR_UNIT_PALETTE
Definition: CCmpUnitMotion.h:146
constexpr std::uint8_t ALTERNATE_PATH_TYPE_EVERY
Definition: CCmpUnitMotion.h:124
constexpr entity_pos_t SHORT_PATH_SEARCH_RANGE_INCREMENT
Definition: CCmpUnitMotion.h:75
constexpr entity_pos_t LONG_PATH_MIN_DIST
Minimum distance to goal for a long path request.
Definition: CCmpUnitMotion.h:86
Definition: ShaderDefines.cpp:43
const entity_id_t INVALID_ENTITY
Invalid entity ID.
Definition: Entity.h:35
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton 'system' components.
Definition: Entity.h:43
std::uint32_t entity_id_t
Entity ID type.
Definition: Entity.h:29
#define ENTITY_IS_LOCAL(id)
Definition: Entity.h:59
Definition: CCmpUnitMotionManager.h:51
Definition: CCmpUnitMotion.h:219
entity_id_t m_Entity
Definition: CCmpUnitMotion.h:226
CFixedVector2D m_Position
Definition: CCmpUnitMotion.h:227
entity_pos_t m_MinRange
Definition: CCmpUnitMotion.h:228
entity_pos_t m_MaxRange
Definition: CCmpUnitMotion.h:228
MoveRequest(entity_id_t target, CFixedVector2D offset)
Definition: CCmpUnitMotion.h:236
CFixedVector2D GetOffset() const
Definition: CCmpUnitMotion.h:231
MoveRequest(CFixedVector2D pos, entity_pos_t minRange, entity_pos_t maxRange)
Definition: CCmpUnitMotion.h:234
enum CCmpUnitMotion::MoveRequest::Type m_Type
MoveRequest(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
Definition: CCmpUnitMotion.h:235
Type
Definition: CCmpUnitMotion.h:220
@ ENTITY
Definition: CCmpUnitMotion.h:223
@ NONE
Definition: CCmpUnitMotion.h:221
@ OFFSET
Definition: CCmpUnitMotion.h:224
@ POINT
Definition: CCmpUnitMotion.h:222
Definition: CCmpUnitMotion.h:209
void clear()
Definition: CCmpUnitMotion.h:216
std::uint32_t m_Ticket
Definition: CCmpUnitMotion.h:210
Type
Definition: CCmpUnitMotion.h:211
@ LONG_PATH
Definition: CCmpUnitMotion.h:213
@ SHORT_PATH
Definition: CCmpUnitMotion.h:212
enum CCmpUnitMotion::Ticket::Type m_Type
Standard representation for all types of shapes, for use with geometry processing code.
Definition: ICmpObstructionManager.h:70
CFixedVector2D u
Definition: ICmpObstructionManager.h:72
entity_pos_t z
Definition: ICmpObstructionManager.h:71
entity_pos_t hw
Definition: ICmpObstructionManager.h:73
entity_pos_t hh
Definition: ICmpObstructionManager.h:73
entity_pos_t x
Definition: ICmpObstructionManager.h:71
CFixedVector2D v
Definition: ICmpObstructionManager.h:72
External identifiers for shapes.
Definition: ICmpObstructionManager.h:81
bool valid() const
Definition: ICmpObstructionManager.h:84
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
Definition: Overlay.h:42
Returned path.
Definition: Pathfinding.h:69
std::vector< Waypoint > m_Waypoints
Definition: Pathfinding.h:70
Definition: Pathfinding.h:60
entity_pos_t x
Definition: Pathfinding.h:61
entity_pos_t z
Definition: Pathfinding.h:61
Definition: CCmpUnitMotion.h:141
CColor longPath
Definition: CCmpUnitMotion.h:142
CColor shortPath
Definition: CCmpUnitMotion.h:143
static void out(const wchar_t *fmt,...)
Definition: wdbg_sym.cpp:407