|
| 1 | +using Arrowgene.Ddon.Shared.Entity.Structure; |
1 | 2 | using System; |
2 | 3 | using System.Collections.Generic; |
3 | 4 | using System.Linq; |
@@ -281,4 +282,67 @@ public enum QuestResultCommand : ushort |
281 | 282 | /// </summary> |
282 | 283 | SetQuestLayoutEnemyBodyPose = 134, // 0x00634820 (cQuestProcess* this, s32 stageNo, s32 groupNo, s32 setNo, s32 poseId) |
283 | 284 | } |
| 285 | + |
| 286 | + public static class QuestResultCommandExtension |
| 287 | + { |
| 288 | + public static readonly Dictionary<QuestResultCommand, (QuestFlagType Type, QuestFlagAction Action)> gFlagStateChangeCommands = new() |
| 289 | + { |
| 290 | + [QuestResultCommand.QstLayoutFlagOn] = (QuestFlagType.QstLayout, QuestFlagAction.Set), |
| 291 | + [QuestResultCommand.QstLayoutFlagOff] = (QuestFlagType.QstLayout, QuestFlagAction.Clear), |
| 292 | + [QuestResultCommand.WorldManageLayoutFlagOn] = (QuestFlagType.WorldManageLayout, QuestFlagAction.Set), |
| 293 | + [QuestResultCommand.WorldManageLayoutFlagOff] = (QuestFlagType.WorldManageLayout, QuestFlagAction.Clear), |
| 294 | + [QuestResultCommand.WorldManageQuestFlagOn] = (QuestFlagType.WorldManageQuest, QuestFlagAction.Set), |
| 295 | + [QuestResultCommand.WorldManageQuestFlagOff] = (QuestFlagType.WorldManageQuest, QuestFlagAction.Clear), |
| 296 | + [QuestResultCommand.MyQstFlagOn] = (QuestFlagType.MyQst, QuestFlagAction.Set), |
| 297 | + [QuestResultCommand.MyQstFlagOff] = (QuestFlagType.MyQst, QuestFlagAction.Clear), |
| 298 | + [QuestResultCommand.LotOn] = (QuestFlagType.Lot, QuestFlagAction.Set), |
| 299 | + [QuestResultCommand.LotOff] = (QuestFlagType.Lot, QuestFlagAction.Clear), |
| 300 | + }; |
| 301 | + |
| 302 | + public static bool IsFlagStateChangeCommand(this QuestResultCommand commandId) |
| 303 | + { |
| 304 | + return gFlagStateChangeCommands.ContainsKey(commandId); |
| 305 | + } |
| 306 | + |
| 307 | + public static (QuestFlagType Type, QuestFlagAction Action) GetFlagStateChangeProperties(this QuestResultCommand commandId) |
| 308 | + { |
| 309 | + if (!gFlagStateChangeCommands.ContainsKey(commandId)) |
| 310 | + { |
| 311 | + return (QuestFlagType.None, QuestFlagAction.None); |
| 312 | + } |
| 313 | + return gFlagStateChangeCommands[commandId]; |
| 314 | + } |
| 315 | + |
| 316 | + public static QuestFlag ToQuestFlag(CDataQuestCommand questCommand) |
| 317 | + { |
| 318 | + QuestResultCommand cmd = (QuestResultCommand) questCommand.Command; |
| 319 | + if (!cmd.IsFlagStateChangeCommand()) |
| 320 | + { |
| 321 | + return null; |
| 322 | + } |
| 323 | + |
| 324 | + var props = cmd.GetFlagStateChangeProperties(); |
| 325 | + var questFlag = new QuestFlag() |
| 326 | + { |
| 327 | + Type = props.Type, |
| 328 | + Action = props.Action, |
| 329 | + Value = questCommand.Param01, |
| 330 | + PreventReplay = false, |
| 331 | + }; |
| 332 | + |
| 333 | + switch (props.Type) |
| 334 | + { |
| 335 | + case QuestFlagType.WorldManageLayout: |
| 336 | + case QuestFlagType.WorldManageQuest: |
| 337 | + questFlag.QuestId = questCommand.Param02; |
| 338 | + break; |
| 339 | + case QuestFlagType.Lot: |
| 340 | + questFlag.stageInfo = Stage.StageInfoFromStageNo((uint)questCommand.Param01); |
| 341 | + questFlag.Value = questCommand.Param02; |
| 342 | + break; |
| 343 | + } |
| 344 | + |
| 345 | + return questFlag; |
| 346 | + } |
| 347 | + } |
284 | 348 | } |
0 commit comments