Esempio n. 1
0
 public static QueryVerbEvent Serdes(QueryVerbEvent e, ISerializer s)
 {
     e ??= new QueryVerbEvent();
     s.Begin();
     e.Unk2 = s.UInt8(nameof(Unk2), e.Unk2);
     e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3);
     e.Unk4 = s.UInt8(nameof(Unk4), e.Unk4);
     e.Unk5 = s.UInt8(nameof(Unk5), e.Unk5);
     e.Verb = s.EnumU16(nameof(Verb), e.Verb);
     s.End();
     return(e);
 }
Esempio 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);
        }
Esempio n. 3
0
        public static BranchNode Load(BinaryReader br, int id)
        {
            var e = new QueryVerbEvent
            {
                SubType  = QueryType.ChosenVerb,
                Unk2     = br.ReadByte(),   // 2
                Unk3     = br.ReadByte(),   // 3
                Unk4     = br.ReadByte(),   // 4
                Unk5     = br.ReadByte(),   // 5
                Argument = br.ReadUInt16(), // 6
            };

            ushort?falseEventId = br.ReadUInt16();  // 8

            if (falseEventId == 0xffff)
            {
                falseEventId = null;
            }

            return(new BranchNode(id, e, falseEventId));
        }
Esempio n. 4
0
        public static BranchNode Load(BinaryReader br, int id, MapEventType type)
        {
            var subType = (QueryType)br.ReadByte(); // 1

            switch (subType)
            {
            case QueryType.InventoryHasItem:
            case QueryType.UsedItemId:
                return(QueryItemEvent.Load(br, id, subType));

            case QueryType.ChosenVerb:
                return(QueryVerbEvent.Load(br, id));

            case QueryType.PreviousActionResult:
            case QueryType.Ticker:
            case QueryType.CurrentMapId:
            case QueryType.PromptPlayer:
            case QueryType.TriggerType:
            default:
                break;
            }

            var e = new QueryEvent
            {
                SubType  = subType,
                Unk2     = br.ReadByte(),   // 2
                Unk3     = br.ReadByte(),   // 3
                Unk4     = br.ReadByte(),   // 4
                Unk5     = br.ReadByte(),   // 5
                Argument = br.ReadUInt16(), // 6
            };

            ushort?falseEventId = br.ReadUInt16();  // 8

            if (falseEventId == 0xffff)
            {
                falseEventId = null;
            }
            return(new BranchNode(id, e, falseEventId));
        }