|
28 | 28 | import com.vizor.unreal.util.Tuple; |
29 | 29 |
|
30 | 30 | import java.util.ArrayList; |
| 31 | +import java.util.Arrays; |
31 | 32 | import java.util.HashMap; |
32 | 33 | import java.util.List; |
33 | 34 | import java.util.Map; |
@@ -151,19 +152,32 @@ private List<Tuple<CppDelegate, CppField>> genDelegates() |
151 | 152 | final CppArgument statusArg = new CppArgument(plain("FGrpcStatus", Struct), "Status"); |
152 | 153 |
|
153 | 154 | return requestsResponses.entrySet().stream() |
154 | | - .map(e -> { |
| 155 | + .flatMap(e -> { |
155 | 156 | final CppArgument responseArg = e.getValue().reduce(($, rsp) -> new CppArgument(rsp.makeRef(), "Response")); |
| 157 | + final CppType dynamicEventType = plain(eventTypePrefix + e.getKey() + service.name() + "_Dynamic", Struct); |
156 | 158 | final CppType eventType = plain(eventTypePrefix + e.getKey() + service.name(), Struct); |
157 | 159 |
|
158 | | - return Tuple.of( |
159 | | - new CppDelegate(eventType, asList(dispatcherArg, responseArg, statusArg)), |
160 | | - new CppField(eventType, eventPrefix + e.getKey()) |
161 | | - ); |
| 160 | + ArrayList<Tuple<CppDelegate, CppField>> array = new ArrayList<>(); |
| 161 | + array.add(Tuple.of( |
| 162 | + new CppDelegate(dynamicEventType, asList(dispatcherArg, responseArg, statusArg), true), |
| 163 | + new CppField(dynamicEventType, eventPrefix + e.getKey() + "Dynamic") |
| 164 | + )); |
| 165 | + |
| 166 | + CppField field = new CppField(eventType, eventPrefix + e.getKey()); |
| 167 | + field.enableAnnotations(false); |
| 168 | + array.add(Tuple.of( |
| 169 | + new CppDelegate(eventType, asList(dispatcherArg, responseArg, statusArg), false), |
| 170 | + field |
| 171 | + )); |
| 172 | + return array.stream(); |
162 | 173 | }) |
163 | 174 | .peek(t -> { |
164 | | - // should add an UE-specific annotations to these events |
165 | | - t.second().addAnnotation(BlueprintAssignable); |
166 | | - t.second().addAnnotation(Category, rpcResponsesCategory + service.name()); |
| 175 | + // should add an UE-specific annotations to these events if it's a dynamic event |
| 176 | + if (t.first().isDynamic()) |
| 177 | + { |
| 178 | + t.second().addAnnotation(BlueprintAssignable); |
| 179 | + t.second().addAnnotation(Category, rpcResponsesCategory + service.name()); |
| 180 | + } |
167 | 181 | }) |
168 | 182 | .collect(toList()); |
169 | 183 | } |
@@ -206,25 +220,36 @@ private CppFunction genUpdate() |
206 | 220 | "'{'", |
207 | 221 | " {1} ResponseWithStatus;", |
208 | 222 | " while ({0}.Dequeue(ResponseWithStatus))", |
| 223 | + " '{'", |
209 | 224 | " {2}.Broadcast(", |
210 | 225 | " this,", |
211 | 226 | " ResponseWithStatus.Response,", |
212 | 227 | " ResponseWithStatus.Status", |
213 | 228 | " );", |
| 229 | + " {3}.Broadcast(", |
| 230 | + " this,", |
| 231 | + " ResponseWithStatus.Response,", |
| 232 | + " ResponseWithStatus.Status", |
| 233 | + " );", |
| 234 | + " '}'", |
214 | 235 | "'}'" |
215 | 236 | )); |
216 | 237 |
|
217 | 238 | final StringBuilder sb = new StringBuilder(supressSuperString(updateFunctionName)); |
218 | 239 | for (int i = 0; i < conduits.size(); i++) |
219 | 240 | { |
220 | | - final Tuple<CppDelegate, CppField> delegate = delegates.get(i); |
| 241 | + // Each conduit is "paired" to 2 delegates |
| 242 | + final Tuple<CppDelegate, CppField> delegate = delegates.get(i * 2); |
| 243 | + final Tuple<CppDelegate, CppField> delegate2 = delegates.get(i * 2 + 1); |
221 | 244 | final CppField conduit = conduits.get(i); |
222 | 245 |
|
223 | 246 | final String dequeue = delegate.reduce((d, f) -> { |
224 | | - final List<CppType> genericParams = conduit.getType().getGenericParams(); |
225 | | - final CppType requestWithContext = genericParams.get(1); |
226 | | - |
227 | | - return format(dequeuePattern, conduit.getName(), requestWithContext.toString(), f.getName()); |
| 247 | + return delegate2.reduce((d2, f2) -> { |
| 248 | + final List<CppType> genericParams = conduit.getType().getGenericParams(); |
| 249 | + final CppType requestWithContext = genericParams.get(1); |
| 250 | + |
| 251 | + return format(dequeuePattern, conduit.getName(), requestWithContext.toString(), f2.getName(), f.getName()); |
| 252 | + }); |
228 | 253 | }); |
229 | 254 |
|
230 | 255 | sb.append(dequeue).append(lineSeparator()).append(lineSeparator()); |
|
0 commit comments