Skip to content

Commit 95fb69b

Browse files
committed
Added delegate section to Poster V1.1
1 parent 5dfbd55 commit 95fb69b

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

CheatSheet_Poster.pdf

1.7 KB
Binary file not shown.

CheatSheet_Poster.tex

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
\linebreak
2323
\Large{(C) J. Böhmer, March 2018 \linebreak Licensed under CC BY-NC-SA 4.0}
2424
\linebreak
25-
\Large{Version 1.0}
25+
\Large{Version 1.1}
2626
\end{center}
2727

2828
\section{Reflection System}
@@ -214,6 +214,36 @@
214214
}
215215
\end{verbatim}
216216
\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}
217247

218248
\section{Useful Console commands}
219249
\begin{itemize}
@@ -361,15 +391,13 @@
361391
case EEnum:Val1:
362392
return 1;
363393
default:
364-
checkNoEntry();
365-
}
394+
checkNoEntry(); }
366395
\end{verbatim}
367396
\item \textbf{unimplemented():} Use this assertions, on functions that are yet unimplemented or must be overridden to work properly.
368397
\begin{verbatim}
369398
void Function() {
370399
//This func must be overriden to work
371-
unimplemented();
372-
}
400+
unimplemented(); }
373401
\end{verbatim}
374402
\end{itemize}
375403

@@ -384,8 +412,7 @@
384412
20, //size of the point
385413
FColor(255,0,0), //the color
386414
false, //Not persistant
387-
10.f //10s lifetime
388-
);
415+
10.f //10s lifetime);
389416
\end{verbatim}
390417
\item \textbf{DrawDebugLine():} Draw a line between to points in the world:
391418
\begin{verbatim}
@@ -397,8 +424,7 @@
397424
false, //Not persistant
398425
-1, //Infinite lifetime
399426
0,
400-
10 //Line Thickness
401-
);
427+
10 //Line Thickness);
402428
\end{verbatim}
403429

404430
\end{itemize}

0 commit comments

Comments
 (0)