|
22 | 22 | \linebreak |
23 | 23 | \Large{(C) J. Böhmer, March 2018 \linebreak Licensed under CC BY-NC-SA 4.0} |
24 | 24 | \linebreak |
25 | | - \Large{Version 1.0} |
| 25 | + \Large{Version 1.1} |
26 | 26 | \end{center} |
27 | 27 |
|
28 | 28 | \section{Reflection System} |
|
214 | 214 | } |
215 | 215 | \end{verbatim} |
216 | 216 | \end{minipage} |
| 217 | + |
| 218 | + \subsection{Delegates} |
| 219 | + Delegates allow to call variable functions via a type-safe way. |
| 220 | + There are 3 big types of delegates: |
| 221 | + \begin{itemize} |
| 222 | + \item Single-cast Delegates, which can have a single function target, declared with \verb|DECLARE_DELEGATE_| |
| 223 | + \item Multi-cast Delegates, which can have multiple function targets, declared with \verb|DECLARE_MULTICAST_DELEGATE_| |
| 224 | + \item Dynamic Multicasts, which can be serialized, and functions can be found by name, declared with \verb|DECLARE_DYNAMIC_DELEGATE_| or \verb|DECLARE_DYNAMIC_MULTICAST_DELEGATE_| |
| 225 | + \end{itemize} |
| 226 | + All Delegate macros have the syntax: \linebreak \verb|_DELEGATE_<Num>Params(Name,Param1Type,Param2Type,...)| |
| 227 | + or for functions with return value: \linebreak |
| 228 | + \verb|DECLARE_DELEGATE_RetVal(RetValType, Name)| |
| 229 | + |
| 230 | + Code example: |
| 231 | + |
| 232 | + \begin{verbatim} |
| 233 | + DECLARE_MULTICAST_DELEGATE(VoidDelegate) |
| 234 | + DECLARE_DELEGATE_OneParam(IntParamDelegate, int32) |
| 235 | + DECLARE_DELEGATE_TwoParams(MyDelegate, int32, AActor*) |
| 236 | + DECLARE_DELEGATE_RetVal_OneParam(int, Delegate2, uint8) |
| 237 | + void MyFunc; |
| 238 | + void MyFunc2(int32); |
| 239 | + VoidDelegate Del1; |
| 240 | + //Somewhere in func body |
| 241 | + Del1.Add(this, FName("MyFunc")); //Add MyFunc |
| 242 | + Del1.Broadcast(); //Call all bound functions |
| 243 | + IntParamDelegate Del2; |
| 244 | + Del2.Add(this, FName("MyFunc2)); //Bind MyFunc2 |
| 245 | + Del2.ExecuteIfBound(10); //Call MyFunc2 |
| 246 | + \end{verbatim} |
217 | 247 |
|
218 | 248 | \section{Useful Console commands} |
219 | 249 | \begin{itemize} |
|
361 | 391 | case EEnum:Val1: |
362 | 392 | return 1; |
363 | 393 | default: |
364 | | - checkNoEntry(); |
365 | | - } |
| 394 | + checkNoEntry(); } |
366 | 395 | \end{verbatim} |
367 | 396 | \item \textbf{unimplemented():} Use this assertions, on functions that are yet unimplemented or must be overridden to work properly. |
368 | 397 | \begin{verbatim} |
369 | 398 | void Function() { |
370 | 399 | //This func must be overriden to work |
371 | | - unimplemented(); |
372 | | - } |
| 400 | + unimplemented(); } |
373 | 401 | \end{verbatim} |
374 | 402 | \end{itemize} |
375 | 403 |
|
|
384 | 412 | 20, //size of the point |
385 | 413 | FColor(255,0,0), //the color |
386 | 414 | false, //Not persistant |
387 | | - 10.f //10s lifetime |
388 | | - ); |
| 415 | + 10.f //10s lifetime); |
389 | 416 | \end{verbatim} |
390 | 417 | \item \textbf{DrawDebugLine():} Draw a line between to points in the world: |
391 | 418 | \begin{verbatim} |
|
397 | 424 | false, //Not persistant |
398 | 425 | -1, //Infinite lifetime |
399 | 426 | 0, |
400 | | - 10 //Line Thickness |
401 | | - ); |
| 427 | + 10 //Line Thickness); |
402 | 428 | \end{verbatim} |
403 | 429 |
|
404 | 430 | \end{itemize} |
|
0 commit comments