public static DataChangeEvent Serdes(DataChangeEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new DataChangeEvent(); e.Property = s.EnumU8(nameof(Property), e.Property); e.Mode = s.EnumU8(nameof(Mode), e.Mode); e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3); e.Unk4 = s.UInt8(nameof(Unk4), e.Unk4); e.PartyMemberId = PartyMemberId.SerdesU8(nameof(PartyMemberId), e.PartyMemberId, mapping, s); switch (e.Property) { case ChangeProperty.ReceiveOrRemoveItem: e._value = ItemId.SerdesU16(nameof(ItemId), ItemId.FromUInt32(e._value), AssetType.Item, mapping, s).ToUInt32(); break; default: e._value = s.UInt16(nameof(Value), (ushort)e._value); break; } e.Amount = s.UInt16(nameof(Amount), e.Amount); return(e); }
public static DoorEvent Serdes(DoorEvent e, AssetMapping mapping, ISerializer s, TextId textSourceId) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new DoorEvent(textSourceId); e.PickDifficulty = s.UInt8(nameof(PickDifficulty), e.PickDifficulty); e.Key = ItemId.SerdesU16(nameof(Key), e.Key, AssetType.Item, mapping, s); e.OpenedText = s.UInt8(nameof(OpenedText), e.OpenedText); e.UnlockedText = s.UInt8(nameof(UnlockedText), e.UnlockedText); e.DoorId = DoorId.SerdesU16(nameof(DoorId), e.DoorId, mapping, s); // Usually 100+ return(e); }
public static ChestEvent Serdes(ChestEvent e, AssetMapping mapping, ISerializer s, TextId textSourceId) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new ChestEvent(textSourceId); e.PickDifficulty = s.UInt8(nameof(PickDifficulty), e.PickDifficulty); e.KeyItemId = ItemId.SerdesU16(nameof(KeyItemId), e.KeyItemId, AssetType.Item, mapping, s); e.UnlockedTextId = s.UInt8(nameof(UnlockedTextId), e.UnlockedTextId); e.InitialTextId = s.UInt8(nameof(InitialTextId), e.InitialTextId); e.ChestId = ChestId.SerdesU16(nameof(ChestId), e.ChestId, mapping, s); return(e); }
public static AddRemoveInventoryItemEvent Serdes(AddRemoveInventoryItemEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new AddRemoveInventoryItemEvent(); e.Operation = s.EnumU8(nameof(Operation), e.Operation); e.Amount = s.UInt8(nameof(Amount), e.Amount); e.Unk4 = s.UInt8(nameof(Unk4), e.Unk4); e.Unk5 = s.UInt8(nameof(Unk5), e.Unk5); e.ItemId = ItemId.SerdesU16(nameof(e.ItemId), e.ItemId, AssetType.Item, mapping, s); e.Unk8 = s.UInt16(nameof(Unk8), e.Unk8); return(e); }
public static SimpleChestEvent Serdes(SimpleChestEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new SimpleChestEvent(); e.ChestType = s.EnumU8(nameof(ChestType), e.ChestType); uint padding = s.UInt32(nameof(padding), 0); ApiUtil.Assert(padding == 0); e.ItemId = ItemId.SerdesU16(nameof(e.ItemId), e.ItemId, AssetType.Item, mapping, s); e.Amount = s.UInt16(nameof(Amount), e.Amount); return(e); }
public static AddRemoveInventoryItemEvent Serdes(AddRemoveInventoryItemEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new AddRemoveInventoryItemEvent(); e.Operation = s.EnumU8(nameof(Operation), e.Operation); e.Amount = s.UInt8(nameof(Amount), e.Amount); int zeroes = s.UInt8(null, 0); zeroes += s.UInt8(null, 0); e.ItemId = ItemId.SerdesU16(nameof(e.ItemId), e.ItemId, AssetType.Item, mapping, s); zeroes += s.UInt16(null, 0); s.Assert(zeroes == 0, "AddRemoveInventoryItem: Expected fields 4,5 & 8 to be 0"); return(e); }
public static ChangeItemEvent Serdes(ChangeItemEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new ChangeItemEvent(); e.Operation = s.EnumU8(nameof(Operation), e.Operation); e.Unk3 = s.UInt8(nameof(Unk3), e.Unk3); int zeroed = s.UInt8(null, 0); e.PartyMemberId = PartyMemberId.SerdesU8(nameof(PartyMemberId), e.PartyMemberId, mapping, s); e.ItemId = ItemId.SerdesU16(nameof(ItemId), e.ItemId, AssetType.Item, mapping, s); e.Amount = s.UInt16(nameof(Amount), e.Amount); s.Assert(zeroed == 0, "ChangeItemEvent: Expected byte 4 to be 0"); return(e); }
public static QueryUsedItemEvent Serdes(QueryUsedItemEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new QueryUsedItemEvent(); e.Operation = s.EnumU8(nameof(Operation), e.Operation); e.Immediate = s.UInt8(nameof(Immediate), e.Immediate); int zeroes = s.UInt8(null, 0); zeroes += s.UInt8(null, 0); e.ItemId = ItemId.SerdesU16(nameof(ItemId), e.ItemId, AssetType.Item, mapping, s); // field 8 is the next event id when the condition is false and is deserialised as part of the BranchEventNode that this event should belong to. s.Assert(zeroes == 0, "QueryUsedItemEvent: Expected fields 3,4 to be 0"); return(e); }
public static ChangeUsedItemEvent Serdes(ChangeUsedItemEvent e, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } e ??= new ChangeUsedItemEvent(); int zeroes = s.UInt8(null, 0); zeroes += s.UInt8(null, 0); zeroes += s.UInt8(null, 0); zeroes += s.UInt8(null, 0); zeroes += s.UInt8(null, 0); e.ItemId = ItemId.SerdesU16(nameof(ItemId), e.ItemId, AssetType.Item, mapping, s); zeroes += s.UInt16(null, 0); s.Assert(zeroes == 0, "ChangeUsedItem: Expected all fields other than 6 to be 0"); return(e); }
public static VisitedEvent Serdes(int n, VisitedEvent u, AssetMapping mapping, ISerializer s) { if (s == null) { throw new ArgumentNullException(nameof(s)); } u ??= new VisitedEvent(); s.Begin(); u.Unk0 = s.UInt8(nameof(Unk0), u.Unk0); u.EventSetId = EventSetId.SerdesU16(nameof(EventSetId), u.EventSetId, mapping, s); u.Type = s.EnumU8(nameof(Type), u.Type); switch (u.Type) { case ActionType.AskAboutItem: case ActionType.UseItem: case ActionType.EquipItem: case ActionType.UnequipItem: case ActionType.PickupItem: u._value = ItemId.SerdesU16("Value", ItemId.FromUInt32(u._value), AssetType.Item, mapping, s).ToUInt32(); break; case ActionType.Word: u._value = WordId.SerdesU16("Value", WordId.FromUInt32(u._value), mapping, s).ToUInt32(); break; default: u._value = s.UInt16("Value", (ushort)u._value); break; } if (s.IsCommenting()) { s.Comment(u.ToString()); } s.End(); return(u); }