OpenClonk
ObjectAddWaypoint Struct Reference

Public Member Functions

 ObjectAddWaypoint (C4Object *obj)
 
bool operator() (int32_t iX, int32_t iY, C4Object *TransferTarget)
 

Detailed Description

Definition at line 228 of file C4Command.cpp.

Constructor & Destructor Documentation

◆ ObjectAddWaypoint()

ObjectAddWaypoint::ObjectAddWaypoint ( C4Object obj)
inlineexplicit

Definition at line 230 of file C4Command.cpp.

230 : cObj(obj) {}

Member Function Documentation

◆ operator()()

bool ObjectAddWaypoint::operator() ( int32_t  iX,
int32_t  iY,
C4Object TransferTarget 
)
inline

Definition at line 231 of file C4Command.cpp.

232  {
233  if (!cObj) return false;
234 
235  // Transfer waypoint
236  if (TransferTarget)
237  return cObj->AddCommand(C4CMD_Transfer,TransferTarget,iX,iY,0,nullptr,false);
238 
239  // Solid offset
240  AdjustSolidOffset(iX,iY,cObj->Shape.Wdt/2,cObj->Shape.Hgt/2);
241 
242  // Standard movement waypoint update interval
243  int32_t iUpdate = 25;
244  // Waypoints before transfer zones are not updated (enforce move to that waypoint)
245  if (cObj->Command && (cObj->Command->Command==C4CMD_Transfer)) iUpdate=0;
246  // Add waypoint
247  assert(cObj->Command);
248  if (!cObj->AddCommand(C4CMD_MoveTo,nullptr,iX,iY,iUpdate,nullptr,false,cObj->Command->Data)) return false;
249 
250  return true;
251  }
bool AdjustSolidOffset(int32_t &rX, int32_t &rY, int32_t iXOff, int32_t iYOff)
Definition: C4Command.cpp:165
@ C4CMD_Transfer
Definition: C4Command.h:44
@ C4CMD_MoveTo
Definition: C4Command.h:30
C4Value Data
Definition: C4Command.h:85
int32_t Command
Definition: C4Command.h:81
bool AddCommand(int32_t iCommand, C4Object *pTarget, C4Value iTx, int32_t iTy=0, int32_t iUpdateInterval=0, C4Object *pTarget2=nullptr, bool fInitEvaluation=true, C4Value iData=C4VNull, bool fAppend=false, int32_t iRetries=0, C4String *szText=nullptr, int32_t iBaseMode=0)
C4Command * Command
Definition: C4Object.h:165
C4Shape Shape
Definition: C4Object.h:146
int32_t Hgt
Definition: C4Rect.h:30
int32_t Wdt
Definition: C4Rect.h:30

References C4Object::AddCommand(), AdjustSolidOffset(), C4CMD_MoveTo, C4CMD_Transfer, C4Command::Command, C4Object::Command, C4Command::Data, C4Rect::Hgt, C4Object::Shape, and C4Rect::Wdt.

Here is the call graph for this function:

The documentation for this struct was generated from the following file: