18#ifndef INCLUDED_CCMPUNITMOTION
19#define INCLUDED_CCMPUNITMOTION
52#define DISABLE_PATHFINDER 0
196 } m_Type = SHORT_PATH;
247 "<a:help>Provides the unit with the ability to move around the world by itself.</a:help>"
249 "<WalkSpeed>7.0</WalkSpeed>"
250 "<PassabilityClass>default</PassabilityClass>"
252 "<element name='FormationController'>"
253 "<data type='boolean'/>"
255 "<element name='WalkSpeed' a:help='Basic movement speed (in metres per second).'>"
256 "<ref name='positiveDecimal'/>"
259 "<element name='RunMultiplier' a:help='How much faster the unit goes when running (as a multiple of walk speed).'>"
260 "<ref name='positiveDecimal'/>"
263 "<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.'>"
264 "<ref name='positiveDecimal'/>"
266 "<element name='Acceleration' a:help='Acceleration (in metres per second^2).'>"
267 "<ref name='positiveDecimal'/>"
269 "<element name='PassabilityClass' a:help='Identifies the terrain passability class (values are defined in special/pathfinder.xml).'>"
272 "<element name='Weight' a:help='Makes this unit both push harder and harder to push. 10 is considered the base value.'>"
273 "<ref name='positiveDecimal'/>"
276 "<element name='DisablePushing'>"
277 "<data type='boolean'/>"
377 case MT_RenderSubmit:
379 PROFILE(
"UnitMotion::RenderSubmit");
402 case MT_MovementObstructionChanged:
409 case MT_ValueModification:
416 case MT_OwnershipChanged:
421 case MT_Deserialized:
469 if (!cmpPosition || !cmpPosition->IsInWorld())
481 PerformMove(dt, cmpPosition->GetTurnRate(), shortPath, longPath, pos, speed, angle, 0);
514 LOGWARNING(
"Only formation controllers can change their passability class");
576 if (cmpPosition && cmpPosition->IsInWorld())
609 return cmpControllerMotion && cmpControllerMotion->IsMoveRequested();
620 m_Pushing = pushing && cmpUnitMotionManager->IsPushingActivated();
629 m_PassClass = cmpPathfinder->GetPassabilityClass(passClassName);
738 if (!cmpValueModificationManager)
884 bool MoveTo(MoveRequest request);
898 if (path.m_Waypoints.empty())
902 if (goal.DistanceToPoint(pos) <= goal.DistanceToPoint(
CFixedVector2D(path.m_Waypoints.front().x, path.m_Waypoints.front().z)))
920 if (!cmpPosition || !cmpPosition->IsInWorld())
928 bool shortPathHack =
false;
932 if (!pathedTowardsGoal)
969 if (ticketType == Ticket::LONG_PATH)
984 if (cmpPathfinder->CheckMovement(GetObstructionFilter(), pos.X, pos.Y, secondWpt.
x, secondWpt.
z, m_Clearance, m_PassClass))
993 m_FollowKnownImperfectPathCountdown = 0;
995 if (!pathedTowardsGoal)
1005 if (PathingUpdateNeeded(pos))
1010 if (!IncrementFailedMovementsAndMaybeNotify())
1040 state.wasObstructed =
false;
1041 state.wentStraight =
false;
1044 state.needUpdate =
state.cmpPosition->IsInWorld() &&
1057 cmpObstruction->SetMovingFlag(
state.isMoving);
1097 if (
state.wentStraight && !
state.wasObstructed)
1118 ENSURE(cmpObstructionManager);
1127 if (cmpControllerMotion && cmpControllerMotion->IsMoveRequested())
1136 return (targetPos-cmpPosition->GetPosition2D()).CompareLength(
fixed::Zero()) <= 0;
1162 if (pushingPressure)
1165 constexpr int pressureMinThreshold = 10;
1171 static_assert(maxPressure > 0);
1173 uint8_t slowdown = maxPressure - std::min(maxPressure, std::max(0, pushingPressure - pressureMinThreshold));
1184 fixed maxSpeed = basicSpeed;
1186 fixed timeLeft = dt;
1193 if (cmpTargetObstruction)
1194 specificIgnore = cmpTargetObstruction->GetObstruction();
1197 while (timeLeft > zero)
1211 if (turnRate > zero && !offset.
IsZero())
1232 angle += maxRotation * direction;
1239 timeLeft = std::min(maxRotation, maxRotation - absoluteAngleDiff +
m_InstantTurnAngle) / turnRate;
1254 fixed maxdist = accelDist + maxSpeed.
Multiply(timeLeft - accelTime);
1258 if (offsetLength <= maxdist)
1268 if (offsetLength <= accelDist)
1271 timeLeft -= requiredTime;
1276 timeLeft -= accelTime + (offsetLength - accelDist) / maxSpeed;
1297 target = pos + offset;
1330 if (!cmpPosition || !cmpPosition->IsInWorld())
1366 Waypoint next = m_ShortPath.m_Waypoints.back();
1367 CFixedVector2D backUp(pos.X - next.x, pos.Y - next.z);
1369 next.x = pos.X + backUp.X;
1370 next.z = pos.Y + backUp.Y;
1371 m_ShortPath.m_Waypoints.push_back(next);
1383 m_LongPath.m_Waypoints.pop_back();
1415 return cmpPosition && cmpPosition->IsInWorld();
1427 if (!cmpTargetPosition || !cmpTargetPosition->IsInWorld())
1435 out = cmpTargetPosition->GetPosition2D() + offset;
1439 out = cmpTargetPosition->GetPosition2D();
1450 bool needInterpolation = cmpUnitMotion && cmpUnitMotion->IsMoveRequested() && cmpUnitMotionManager->ComputingMotion();
1451 if (needInterpolation)
1481 goal.
x = targetPos.
X;
1482 goal.
z = targetPos.
Y;
1499 if (cmpTargetObstruction)
1500 specificIgnore = cmpTargetObstruction->GetObstruction();
1504 if (specificIgnore.
valid())
1542 if (cmpTargetObstruction)
1543 cmpTargetObstruction->GetObstructionSquare(estimatedTargetShape);
1546 estimatedTargetShape.
x = targetPos.
X;
1547 estimatedTargetShape.
z = targetPos.
Y;
1552 cmpObstruction->GetObstructionSquare(shape);
1563 shape.
x = lastWaypoint.
x;
1564 shape.
z = lastWaypoint.
z;
1568 ENSURE(cmpObstructionManager);
1578 if (cmpObstructionManager->AreShapesInRange(shape, estimatedTargetShape, minRange, maxRange,
false))
1587 if (!cmpPosition || !cmpPosition->IsInWorld())
1605 cmpPosition->TurnTo(angle);
1619 return (range > circleRadius*3);
1628 if (!cmpPosition || !cmpPosition->IsInWorld())
1641 if (cmpTargetObstruction)
1642 cmpTargetObstruction->GetObstructionSquare(targetObstruction);
1644 targetObstruction.
x = targetPosition.
X;
1645 targetObstruction.
z = targetPosition.
Y;
1650 cmpObstruction->GetObstructionSquare(obstruction);
1653 obstruction.
x = pos.
X;
1654 obstruction.
z = pos.
Y;
1658 ENSURE(cmpObstructionManager);
1660 out.x = targetObstruction.
x;
1661 out.z = targetObstruction.
z;
1662 out.hw = targetObstruction.
hw;
1663 out.hh = targetObstruction.
hh;
1664 out.u = targetObstruction.
u;
1665 out.v = targetObstruction.
v;
1676 entity_pos_t distance = cmpObstructionManager->DistanceBetweenShapes(obstruction, targetObstruction);
1697 out.hw = circleRadius + goalDistance;
1702 out.hw = targetObstruction.
hw + goalDistance;
1703 out.hh = targetObstruction.
hh + goalDistance;
1712 circleRadius = std::min(targetObstruction.
hw, targetObstruction.
hh);
1715 out.hw = circleRadius + goalDistance;
1726 out.hw = targetObstruction.
hw + delta;
1727 out.hh = targetObstruction.
hh + delta;
1736#if DISABLE_PATHFINDER
1771 shortPath = !shortPath;
1796 cmpPathfinder->SetDebugPath(from.
X, from.
Y, improvedGoal,
m_PassClass);
1829 LOGWARNING(
"MaxRange must be larger than MinRange; See CCmpUnitMotion.cpp for more information");
1832 if (!cmpPosition || !cmpPosition->IsInWorld())
1850 if (!cmpPosition || !cmpPosition->IsInWorld())
1860 return cmpPathfinder->IsGoalReachable(pos.
X, pos.
Y, goal,
m_PassClass);
1866 bool floating =
false;
1869 floating = cmpPosition->CanFloat();
1872 std::vector<float> waypointCoords;
1873 for (
size_t i = 0; i < path.
m_Waypoints.size(); ++i)
1877 waypointCoords.push_back(x);
1878 waypointCoords.push_back(z);
1880 lines.back().m_Color = color;
1883 float x = cmpPosition->GetPosition2D().X.ToFloat();
1884 float z = cmpPosition->GetPosition2D().Y.ToFloat();
1885 waypointCoords.push_back(x);
1886 waypointCoords.push_back(z);
1888 lines.back().m_Color = color;
#define LOGWARNING(...)
Definition: CLogger.h:36
#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:147
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:187
Helper functions related to geometry algorithms.
T Clamp(T value, T min, T max)
Definition: MathUtil.h:32
u16 pass_class_t
Definition: Pathfinding.h:29
#define PROFILE(name)
Definition: Profile.h:159
void Serializer(S &serialize, const char *name, Args &&... args)
Definition: SerializeTemplates.h:51
Provide specializations for some generic types and containers.
Definition: CCmpUnitMotionManager.h:32
static constexpr int MAX_PRESSURE
Maximum value for pushing pressure.
Definition: CCmpUnitMotionManager.h:41
Definition: CCmpUnitMotion.h:133
bool MoveTo(MoveRequest request)
General handler for MoveTo interface functions.
Definition: CCmpUnitMotion.h:1824
bool m_IsFormationController
Definition: CCmpUnitMotion.h:155
void Init(const CParamNode ¶mNode) override
Definition: CCmpUnitMotion.h:282
fixed m_CurrentSpeed
Definition: CCmpUnitMotion.h:233
bool ComputeGoal(PathGoal &out, const MoveRequest &moveRequest) const
Create a PathGoal from a move request.
Definition: CCmpUnitMotion.h:1622
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:541
CFixedVector2D EstimateFuturePosition(const fixed dt) const override
Definition: CCmpUnitMotion.h:466
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:1612
static std::string GetSchema()
Definition: CCmpUnitMotion.h:244
void SetDebugOverlay(bool enabled) override
Toggle the rendering of debug info.
Definition: CCmpUnitMotion.h:535
fixed GetRunMultiplier() const override
Get the unit template running (i.e.
Definition: CCmpUnitMotion.h:461
bool GetFacePointAfterMove() const override
Definition: CCmpUnitMotion.h:530
fixed GetCurrentSpeed() const override
Get the speed at the end of the current turn.
Definition: CCmpUnitMotion.h:520
fixed m_Acceleration
Definition: CCmpUnitMotion.h:237
void RequestShortPath(const CFixedVector2D &from, const PathGoal &goal, bool extendRange)
Start an asynchronous short path query.
Definition: CCmpUnitMotion.h:1802
bool InShortPathRange(const PathGoal &goal, const CFixedVector2D &pos) const
Definition: CCmpUnitMotion.h:716
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:1461
WaypointPath m_LongPath
Definition: CCmpUnitMotion.h:241
struct CCmpUnitMotion::Ticket m_ExpectedPathTicket
void Deinit() override
Definition: CCmpUnitMotion.h:314
SkipTagAndControlGroupObstructionFilter GetObstructionFilter(const ICmpObstructionManager::tag_t &tag) const
Filter a specific tag on top of the existing control groups.
Definition: CCmpUnitMotion.h:847
bool ComputeTargetPosition(CFixedVector2D &out) const
Definition: CCmpUnitMotion.h:804
fixed GetWalkSpeed() const override
Get the unit template walk speed after modifications.
Definition: CCmpUnitMotion.h:456
void StopMoving() override
Clears the current MoveRequest - the unit will stop and no longer try and move.
Definition: CCmpUnitMotion.h:571
bool IsFormationControllerMoving() const
Definition: CCmpUnitMotion.h:606
fixed m_LastTurnSpeed
Definition: CCmpUnitMotion.h:230
bool ShouldAlternatePathfinder() const
Definition: CCmpUnitMotion.h:711
bool m_Pushing
Definition: CCmpUnitMotion.h:171
void Deserialize(const CParamNode ¶mNode, IDeserializer &deserialize) override
Definition: CCmpUnitMotion.h:360
static void ClassInit(CComponentManager &componentManager)
Definition: CCmpUnitMotion.h:136
std::string m_PassClassName
Definition: CCmpUnitMotion.h:159
entity_pos_t ShortPathSearchRange() const
Definition: CCmpUnitMotion.h:721
fixed m_InstantTurnAngle
Definition: CCmpUnitMotion.h:235
void ComputePathToGoal(const CFixedVector2D &from, const PathGoal &goal)
Compute a path to the given goal from the given position.
Definition: CCmpUnitMotion.h:1734
void RenderPath(const WaypointPath &path, std::vector< SOverlayLine > &lines, CColor color)
Convert a path into a renderable list of lines.
Definition: CCmpUnitMotion.h:1864
fixed m_RunMultiplier
Definition: CCmpUnitMotion.h:166
void SetParticipateInPushing(bool pushing)
Definition: CCmpUnitMotion.h:617
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:1018
fixed m_SpeedMultiplier
Definition: CCmpUnitMotion.h:225
void RenderSubmit(SceneCollector &collector)
Definition: CCmpUnitMotion.h:1893
std::string GetPassabilityClassName() const override
Get the passability class name (as defined in pathfinder.xml)
Definition: CCmpUnitMotion.h:505
struct CCmpUnitMotion::MoveRequest m_MoveRequest
bool IsMoveRequested() const override
Definition: CCmpUnitMotion.h:435
bool ShouldCollideWithMovingUnits() const
Units in 'pushing' mode are marked as 'moving' in the obstruction manager.
Definition: CCmpUnitMotion.h:832
entity_id_t GetGroup() const
Definition: CCmpUnitMotion.h:612
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:1594
void RequestLongPath(const CFixedVector2D &from, const PathGoal &goal)
Start an asynchronous long path query.
Definition: CCmpUnitMotion.h:1785
fixed m_WalkSpeed
Definition: CCmpUnitMotion.h:166
bool m_BlockMovement
Definition: CCmpUnitMotion.h:175
void SetPassabilityClassName(const std::string &passClassName) override
Sets the passability class name (as defined in pathfinder.xml)
Definition: CCmpUnitMotion.h:510
pass_class_t m_PassClass
Definition: CCmpUnitMotion.h:158
void SetAcceleration(fixed acceleration) override
Set the current acceleration.
Definition: CCmpUnitMotion.h:490
bool HandleObstructedMove(bool moved)
React if our move was obstructed.
Definition: CCmpUnitMotion.h:1327
virtual entity_pos_t GetWeight() const
Definition: CCmpUnitMotion.h:495
std::vector< SOverlayLine > m_DebugOverlayShortPathLines
Definition: CCmpUnitMotion.h:151
bool m_DebugOverlayEnabled
Definition: CCmpUnitMotion.h:149
bool PathingUpdateNeeded(const CFixedVector2D &from) const
Returns whether our we need to recompute a path to reach our target.
Definition: CCmpUnitMotion.h:1522
std::vector< SOverlayLine > m_DebugOverlayLongPathLines
Definition: CCmpUnitMotion.h:150
bool IsFormationMember() const
Definition: CCmpUnitMotion.h:596
void SetPassabilityData(const std::string &passClassName)
Definition: CCmpUnitMotion.h:623
void MoveFailed()
Warns other components that our current movement will likely fail (e.g.
Definition: CCmpUnitMotion.h:643
fixed m_Speed
Definition: CCmpUnitMotion.h:227
bool IncrementFailedMovementsAndMaybeNotify()
Increment the number of failed movements and notify other components if required.
Definition: CCmpUnitMotion.h:694
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:551
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:1141
void Move(CCmpUnitMotionManager::MotionState &state, fixed dt)
Definition: CCmpUnitMotion.h:1060
fixed m_TemplateRunMultiplier
Definition: CCmpUnitMotion.h:157
void SetSpeedMultiplier(fixed multiplier) override
Set the current movement speed.
Definition: CCmpUnitMotion.h:445
fixed m_TemplateWeight
Definition: CCmpUnitMotion.h:157
void MoveObstructed()
Warns other components that our current movement was obstructed (i.e.
Definition: CCmpUnitMotion.h:677
bool IsMovingAsFormation() const
Definition: CCmpUnitMotion.h:601
WaypointPath m_ShortPath
Definition: CCmpUnitMotion.h:242
void SerializeCommon(S &serialize)
Definition: CCmpUnitMotion.h:319
bool m_FacePointAfterMove
Definition: CCmpUnitMotion.h:168
void PreMove(CCmpUnitMotionManager::MotionState &state)
Definition: CCmpUnitMotion.h:1036
void Serialize(ISerializer &serialize) override
Definition: CCmpUnitMotion.h:355
void PathResult(u32 ticket, const WaypointPath &path)
Handle the result of an asynchronous path query.
Definition: CCmpUnitMotion.h:908
void MoveSucceeded()
Warns other components that our current movement is likely over (i.e.
Definition: CCmpUnitMotion.h:660
void UpdateMessageSubscriptions()
Definition: CCmpUnitMotion.h:429
fixed m_TemplateAcceleration
Definition: CCmpUnitMotion.h:157
void FaceTowardsPoint(entity_pos_t x, entity_pos_t z) override
Turn to look towards the given point.
Definition: CCmpUnitMotion.h:1584
void SetMemberOfFormation(entity_id_t controller) override
Set/unset the unit as a formation member.
Definition: CCmpUnitMotion.h:557
bool PossiblyAtDestination() const
Returns true if we are possibly at our destination.
Definition: CCmpUnitMotion.h:1112
fixed GetSpeedMultiplier() const override
Returns the ratio of GetSpeed() / GetWalkSpeed().
Definition: CCmpUnitMotion.h:440
void SetFacePointAfterMove(bool facePointAfterMove) override
Set whether the unit will turn to face the target point after finishing moving.
Definition: CCmpUnitMotion.h:525
void HandleMessage(const CMessage &msg, bool global) override
Definition: CCmpUnitMotion.h:373
fixed GetAcceleration() const override
Get the current acceleration.
Definition: CCmpUnitMotion.h:485
entity_pos_t m_Clearance
Definition: CCmpUnitMotion.h:163
fixed m_TemplateWalkSpeed
Definition: CCmpUnitMotion.h:157
void UpdateMovementState(entity_pos_t speed, entity_pos_t meanSpeed)
Update other components on our speed.
Definition: CCmpUnitMotion.h:1312
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:896
u8 m_FailedMovements
Definition: CCmpUnitMotion.h:180
pass_class_t GetPassabilityClass() const override
Get the unit's passability class.
Definition: CCmpUnitMotion.h:500
void OnValueModification()
Definition: CCmpUnitMotion.h:735
entity_pos_t GetUnitClearance() const override
Get the unit clearance (used by the Obstruction component)
Definition: CCmpUnitMotion.h:590
bool ComputeTargetPosition(CFixedVector2D &out, const MoveRequest &moveRequest) const
Computes the current location of our target entity (plus offset).
Definition: CCmpUnitMotion.h:1418
entity_id_t m_FormationController
Definition: CCmpUnitMotion.h:222
fixed GetSpeed() const override
Get the speed at which the unit intends to move.
Definition: CCmpUnitMotion.h:451
ControlGroupMovementObstructionFilter GetObstructionFilter() const
Returns an appropriate obstruction filter for use with path requests.
Definition: CCmpUnitMotion.h:840
u8 m_FollowKnownImperfectPathCountdown
Definition: CCmpUnitMotion.h:189
bool TargetHasValidPosition() const
Definition: CCmpUnitMotion.h:794
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:546
bool IsTargetRangeReachable(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) override
Check if the target is reachable.
Definition: CCmpUnitMotion.h:1847
void PostMove(CCmpUnitMotionManager::MotionState &state, fixed dt)
Definition: CCmpUnitMotion.h:1072
Definition: ComponentManager.h:40
void PostMessage(entity_id_t ent, const CMessage &msg)
Send a message, targeted at a particular entity.
Definition: ComponentManager.cpp:994
void SubscribeToMessageType(MessageTypeId mtid)
Subscribe the current component type to the given message type.
Definition: ComponentManager.cpp:551
void DynamicSubscriptionNonsync(MessageTypeId mtid, IComponent *component, bool enabled)
Subscribe the given component instance to all messages of the given message type.
Definition: ComponentManager.cpp:579
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:120
static constexpr CFixed FromFraction(int n, int d)
Definition: Fixed.h:146
constexpr CFixed Absolute() const
Definition: Fixed.h:315
static CFixed Zero()
Definition: Fixed.h:131
constexpr CFixed Square() const
Multiply the value by itself.
Definition: Fixed.h:333
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:321
constexpr bool IsZero() const
Returns true if the number is precisely 0.
Definition: Fixed.h:209
static constexpr CFixed FromInt(int n)
Definition: Fixed.h:140
static CFixed Pi()
Definition: Fixed.cpp:182
Sent by CCmpUnitMotion during Update if an event happened that might interest other components.
Definition: MessageTypes.h:308
@ LIKELY_FAILURE
Definition: MessageTypes.h:314
@ VERY_OBSTRUCTED
Definition: MessageTypes.h:316
@ LIKELY_SUCCESS
Definition: MessageTypes.h:313
@ OBSTRUCTED
Definition: MessageTypes.h:315
Sent by CCmpPathfinder after async path requests.
Definition: MessageTypes.h:465
WaypointPath path
Definition: MessageTypes.h:475
u32 ticket
Definition: MessageTypes.h:474
Add renderable objects to the scene collector.
Definition: MessageTypes.h:150
SceneCollector & collector
Definition: MessageTypes.h:159
Sent by aura manager when a value of a certain entity's component is changed.
Definition: MessageTypes.h:482
std::wstring component
Definition: MessageTypes.h:494
virtual int GetType() const =0
An entity initialisation parameter node.
Definition: ParamNode.h:151
bool ToBool() const
Parses the content of this node as a boolean ("true" == true, anything else == false)
Definition: ParamNode.cpp:297
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:254
const std::string & ToString() const
Returns the content of this node as an UTF8 string.
Definition: ParamNode.cpp:272
bool IsOk() const
Returns true if this is a valid CParamNode, false if it represents a non-existent node.
Definition: ParamNode.cpp:262
fixed ToFixed() const
Parses the content of this node as a fixed-point number.
Definition: ParamNode.cpp:287
CComponentManager & GetComponentManager() const
Definition: SimContext.cpp:36
A simplified syntax for accessing entity components.
Definition: CmpPtr.h:56
Obstruction test filter that reject shapes in a given control group, and rejects shapes that don't bl...
Definition: ICmpObstructionManager.h:401
Motion interface for entities with complex movement capabilities.
Definition: ICmpUnitMotion.h:35
entity_id_t GetEntityId() const
Definition: IComponent.h:54
const CSimContext & GetSimContext() const
Definition: IComponent.h:58
CEntityHandle GetEntityHandle() const
Definition: IComponent.h:51
CEntityHandle GetSystemEntity() const
Definition: IComponent.h:56
Deserialization interface; see serialization overview.
Definition: IDeserializer.h:35
Serialization interface; see serialization overview.
Definition: ISerializer.h:121
Pathfinder goal.
Definition: PathGoal.h:33
@ SQUARE
Definition: PathGoal.h:39
@ CIRCLE
Definition: PathGoal.h:37
@ INVERTED_CIRCLE
Definition: PathGoal.h:38
@ INVERTED_SQUARE
Definition: PathGoal.h:40
@ POINT
Definition: PathGoal.h:36
fixed DistanceToPoint(CFixedVector2D pos) const
Returns the minimum distance from the point pos to any point on the goal shape.
Definition: PathGoal.cpp:294
CFixedVector2D NearestPointOnGoal(CFixedVector2D pos) const
Returns the coordinates of the point on the goal that is closest to the point pos.
Definition: PathGoal.cpp:327
entity_pos_t z
Definition: PathGoal.h:43
entity_pos_t maxdist
Definition: PathGoal.h:49
entity_pos_t x
Definition: PathGoal.h:43
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:542
#define FALLTHROUGH
Definition: code_annotation.h:414
#define UNUSED(param)
mark a function parameter as unused and avoid the corresponding compiler warning.
Definition: code_annotation.h:40
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:277
constexpr fixed NAVCELL_SIZE
The long-range pathfinder operates primarily over a navigation grid (a uniform-cost 2D passability gr...
Definition: Pathfinding.h:143
constexpr int NAVCELL_SIZE_INT
Definition: Pathfinding.h:144
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:151
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:36
constexpr u8 BACKUP_HACK_DELAY
Units can occasionally get stuck near corners.
Definition: CCmpUnitMotion.h:120
constexpr entity_pos_t SHORT_PATH_MIN_SEARCH_RANGE
Min/Max range to restrict short path queries to.
Definition: CCmpUnitMotion.h:61
constexpr u8 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:105
constexpr u8 ALTERNATE_PATH_TYPE_DELAY
When computing paths but failing to move, we want to occasionally alternate pathfinder systems to avo...
Definition: CCmpUnitMotion.h:111
const CColor OVERLAY_COLOR_LONG_PATH(1, 1, 1, 1)
constexpr u8 KNOWN_IMPERFECT_PATH_RESET_COUNTDOWN
When following a known imperfect path (i.e.
Definition: CCmpUnitMotion.h:96
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:80
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:87
constexpr entity_pos_t SHORT_PATH_MAX_SEARCH_RANGE
Definition: CCmpUnitMotion.h:62
constexpr u8 VERY_OBSTRUCTED_THRESHOLD
After this many failed computations, start sending "VERY_OBSTRUCTED" messages instead.
Definition: CCmpUnitMotion.h:126
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:69
constexpr u8 SHORT_PATH_SEARCH_RANGE_INCREASE_DELAY
Definition: CCmpUnitMotion.h:64
constexpr entity_pos_t SHORT_PATH_SEARCH_RANGE_INCREMENT
Definition: CCmpUnitMotion.h:63
constexpr entity_pos_t LONG_PATH_MIN_DIST
Minimum distance to goal for a long path request.
Definition: CCmpUnitMotion.h:74
constexpr u8 ALTERNATE_PATH_TYPE_EVERY
Definition: CCmpUnitMotion.h:112
const CColor OVERLAY_COLOR_SHORT_PATH(1, 0, 0, 1)
Definition: ShaderDefines.cpp:31
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
u32 entity_id_t
Entity ID type.
Definition: Entity.h:29
#define ENTITY_IS_LOCAL(id)
Definition: Entity.h:59
Definition: CCmpUnitMotionManager.h:45
Definition: CCmpUnitMotion.h:201
entity_id_t m_Entity
Definition: CCmpUnitMotion.h:208
CFixedVector2D m_Position
Definition: CCmpUnitMotion.h:209
entity_pos_t m_MinRange
Definition: CCmpUnitMotion.h:210
entity_pos_t m_MaxRange
Definition: CCmpUnitMotion.h:210
MoveRequest(entity_id_t target, CFixedVector2D offset)
Definition: CCmpUnitMotion.h:218
CFixedVector2D GetOffset() const
Definition: CCmpUnitMotion.h:213
MoveRequest(CFixedVector2D pos, entity_pos_t minRange, entity_pos_t maxRange)
Definition: CCmpUnitMotion.h:216
enum CCmpUnitMotion::MoveRequest::Type m_Type
MoveRequest(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
Definition: CCmpUnitMotion.h:217
Type
Definition: CCmpUnitMotion.h:202
@ ENTITY
Definition: CCmpUnitMotion.h:205
@ NONE
Definition: CCmpUnitMotion.h:203
@ OFFSET
Definition: CCmpUnitMotion.h:206
@ POINT
Definition: CCmpUnitMotion.h:204
Definition: CCmpUnitMotion.h:191
void clear()
Definition: CCmpUnitMotion.h:198
Type
Definition: CCmpUnitMotion.h:193
@ LONG_PATH
Definition: CCmpUnitMotion.h:195
@ SHORT_PATH
Definition: CCmpUnitMotion.h:194
enum CCmpUnitMotion::Ticket::Type m_Type
u32 m_Ticket
Definition: CCmpUnitMotion.h:192
Standard representation for all types of shapes, for use with geometry processing code.
Definition: ICmpObstructionManager.h:67
CFixedVector2D u
Definition: ICmpObstructionManager.h:69
entity_pos_t z
Definition: ICmpObstructionManager.h:68
entity_pos_t hw
Definition: ICmpObstructionManager.h:70
entity_pos_t hh
Definition: ICmpObstructionManager.h:70
entity_pos_t x
Definition: ICmpObstructionManager.h:68
CFixedVector2D v
Definition: ICmpObstructionManager.h:69
External identifiers for shapes.
Definition: ICmpObstructionManager.h:78
bool valid() const
Definition: ICmpObstructionManager.h:81
Line-based overlay, with world-space coordinates, rendered in the world potentially behind other obje...
Definition: Overlay.h:39
Returned path.
Definition: Pathfinding.h:67
std::vector< Waypoint > m_Waypoints
Definition: Pathfinding.h:68
Definition: Pathfinding.h:58
entity_pos_t x
Definition: Pathfinding.h:59
entity_pos_t z
Definition: Pathfinding.h:59
uint8_t u8
Definition: types.h:37
uint32_t u32
Definition: types.h:39
static void out(const wchar_t *fmt,...)
Definition: wdbg_sym.cpp:407
unsigned char uint8_t
Definition: wposix_types.h:51