コード例 #1
0
ファイル: RunScriptEvent.cs プロジェクト: Metibor/ualbion
 public static RunScriptEvent Serdes(RunScriptEvent e, ISerializer s)
 {
     e ??= new RunScriptEvent();
     s.Begin();
     e.Unk1 = s.UInt8(nameof(Unk1), e.Unk1);
     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.Unk6 = s.UInt16(nameof(Unk6), e.Unk6);
     e.Unk8 = s.UInt16(nameof(Unk8), e.Unk8);
     s.End();
     return(e);
 }
コード例 #2
0
ファイル: RunScriptEvent.cs プロジェクト: vsafonkin/ualbion
 public static RunScriptEvent Serdes(RunScriptEvent e, ISerializer s)
 {
     if (s == null)
     {
         throw new ArgumentNullException(nameof(s));
     }
     e ??= new RunScriptEvent();
     e.Unk1 = s.UInt8(nameof(Unk1), e.Unk1);
     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.Unk6 = s.UInt16(nameof(Unk6), e.Unk6);
     e.Unk8 = s.UInt16(nameof(Unk8), e.Unk8);
     return(e);
 }
コード例 #3
0
        public static IEventNode Load(BinaryReader br, int id)
        {
            var initialPosition = br.BaseStream.Position;
            var type            = (MapEventType)br.ReadByte(); // +0

            EventNode result;

            switch (type) // Individual parsers handle byte range [1,9]
            {
            case MapEventType.Action: result = ActionEvent.Load(br, id, type); break;

            case MapEventType.AskSurrender: result = AskSurrenderEvent.Load(br, id, type); break;

            case MapEventType.ChangeIcon: result = ChangeIconEvent.Load(br, id, type); break;

            case MapEventType.ChangeUsedItem: result = ChangeUsedItemEvent.Load(br, id, type); break;

            case MapEventType.Chest: result = OpenChestEvent.Load(br, id, type); break;

            case MapEventType.CloneAutomap: result = CloneAutomapEvent.Load(br, id, type); break;

            case MapEventType.CreateTransport: result = CreateTransportEvent.Load(br, id, type); break;

            case MapEventType.DataChange: result = DataChangeEvent.Load(br, id, type); break;

            case MapEventType.DoScript: result = DoScriptEvent.Load(br, id); break;

            case MapEventType.Door: result = DoorEvent.Load(br, id, type); break;

            case MapEventType.Encounter: result = EncounterEvent.Load(br, id, type); break;

            case MapEventType.EndDialogue: result = EndDialogueEvent.Load(br, id, type); break;

            case MapEventType.Execute: result = ExecuteEvent.Load(br, id, type); break;

            case MapEventType.MapExit: result = TeleportEvent.Load(br, id, type); break;

            case MapEventType.Modify: result = ModifyEvent.Load(br, id, type); break;

            case MapEventType.Offset: result = OffsetEvent.Load(br, id, type); break;

            case MapEventType.Pause: result = PauseEvent.Load(br, id, type); break;

            case MapEventType.PlaceAction: result = PlaceActionEvent.Load(br, id, type); break;

            case MapEventType.PlayAnimation: result = PlayAnimationEvent.Load(br, id, type); break;

            case MapEventType.Query: result = QueryEvent.Load(br, id, type); break;

            case MapEventType.RemovePartyMember: result = RemovePartyMemberEvent.Load(br, id, type); break;

            case MapEventType.Script: result = RunScriptEvent.Load(br, id, type); break;

            case MapEventType.Signal: result = SignalEvent.Load(br, id, type); break;

            case MapEventType.SimpleChest: result = SimpleChestEvent.Load(br, id, type); break;

            case MapEventType.Sound: result = SoundEvent.Load(br, id, type); break;

            case MapEventType.Spinner: result = SpinnerEvent.Load(br, id, type); break;

            case MapEventType.StartDialogue: result = StartDialogueEvent.Load(br, id, type); break;

            case MapEventType.Text: result = TextEvent.Load(br, id, type); break;

            case MapEventType.Trap: result = TrapEvent.Load(br, id, type); break;

            case MapEventType.UnkFF: result = DummyMapEvent.Load(br, id, type); break;

            case MapEventType.Wipe: result = WipeEvent.Load(br, id, type); break;

            default: throw new ArgumentOutOfRangeException();
            }

            long expectedPosition = initialPosition + 10;
            long actualPosition   = br.BaseStream.Position;

            Debug.Assert(expectedPosition == actualPosition,
                         $"Expected to have read {expectedPosition - initialPosition} bytes, but {actualPosition - initialPosition} have been read.");

            result.NextEventId = br.ReadUInt16(); // +A
            if (result.NextEventId == 0xffff)
            {
                result.NextEventId = null;
            }

            return(result);
        }