Exemplo n.º 1
0
 public static QueryPartyEvent Serdes(QueryPartyEvent e, ISerializer s, QueryType subType)
 {
     e ??= new QueryPartyEvent();
     s.Begin();
     e.QueryType     = subType;
     e.Operation     = s.EnumU8(nameof(Operation), e.Operation);
     e.Immediate     = s.UInt8(nameof(Immediate), e.Immediate);
     e.Unk4          = s.UInt8(nameof(Unk4), e.Unk4);
     e.Unk5          = s.UInt8(nameof(Unk5), e.Unk5);
     e.PartyMemberId = s.TransformEnumU8(nameof(PartyMemberId), e.PartyMemberId, StoreIncrementedNullZero <PartyCharacterId> .Instance);
     s.UInt8("pad", 0);
     s.End();
     return(e);
 }
Exemplo n.º 2
0
        public static IQueryEvent Serdes(IQueryEvent genericEvent, ISerializer s, AssetType textType, ushort textSourceId)
        {
            var subType = s.EnumU8("SubType", genericEvent?.QueryType ?? QueryType.IsScriptDebugModeActive);

            switch (subType)
            {
            case QueryType.InventoryHasItem:
            case QueryType.UsedItemId:
                return(QueryItemEvent.Serdes((QueryItemEvent)genericEvent, s, subType));

            case QueryType.ChosenVerb:
                return(QueryVerbEvent.Serdes((QueryVerbEvent)genericEvent, s));

            case QueryType.IsPartyMemberConscious:
            case QueryType.IsPartyMemberLeader:
            case QueryType.HasPartyMember:
                return(QueryPartyEvent.Serdes((QueryPartyEvent)genericEvent, s, subType));

            case QueryType.PreviousActionResult: break;

            case QueryType.Ticker: break;

            case QueryType.CurrentMapId: break;

            case QueryType.TriggerType: break;

            case QueryType.PromptPlayer:
                return(PromptPlayerEvent.Serdes((PromptPlayerEvent)genericEvent, s, textType, textSourceId));

            case QueryType.PromptPlayerNumeric:
                return(PromptPlayerNumericEvent.Serdes((PromptPlayerNumericEvent)genericEvent, s));
            }

            var e = (QueryEvent)genericEvent ?? new QueryEvent {
                QueryType = subType
            };

            s.Begin();
            e.Operation = s.EnumU8(nameof(Operation), e.Operation);
            e.Immediate = s.UInt8(nameof(Immediate), e.Immediate);
            e.Unk4      = s.UInt8(nameof(Unk4), e.Unk4);
            e.Unk5      = s.UInt8(nameof(Unk5), e.Unk5);
            e.Argument  = s.UInt16(nameof(Argument), e.Argument);

            ApiUtil.Assert(e.Unk4 == 0);
            ApiUtil.Assert(e.Unk5 == 0);

            s.End();
            return(e);
        }