Move mxyz to subclasses

This commit is contained in:
Kurt 2021-05-18 13:04:23 -07:00
parent fbba64c0e6
commit 2d8d3e04fc
4 changed files with 30 additions and 156 deletions

View File

@ -239,161 +239,13 @@ public override int PlayedSeconds
set => General[Trainer1 + 0x25] = (byte)value;
}
public int M
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1238; break;
case GameVersion.Pt: ofs = 0x1280; break;
case GameVersion.HGSS: ofs = 0x1234; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1238; break;
case GameVersion.Pt: ofs = 0x1280; break;
case GameVersion.HGSS: ofs = 0x1234; break;
}
BitConverter.GetBytes((ushort)value).CopyTo(General, ofs);
}
}
public abstract int M { get; set; }
public abstract int X { get; set; }
public abstract int Y { get; set; }
public int X
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1240; break;
case GameVersion.Pt: ofs = 0x1288; break;
case GameVersion.HGSS: ofs = 0x123C; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1240; break;
case GameVersion.Pt: ofs = 0x1288; break;
case GameVersion.HGSS: ofs = 0x123C; break;
}
BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, ofs);
}
}
public int Y
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1244; break;
case GameVersion.Pt: ofs = 0x128C; break;
case GameVersion.HGSS: ofs = 0x1240; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x1244; break;
case GameVersion.Pt: ofs = 0x128C; break;
case GameVersion.HGSS: ofs = 0x1240; break;
}
BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, ofs);
}
}
public int X2
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x25FA; break;
case GameVersion.Pt: ofs = 0x287E; break;
case GameVersion.HGSS: ofs = 0x236E; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x25FA; break;
case GameVersion.Pt: ofs = 0x287E; break;
case GameVersion.HGSS: ofs = 0x236E; break;
}
BitConverter.GetBytes((ushort)value).CopyTo(General, ofs);
}
}
public int Y2
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x25FE; break;
case GameVersion.Pt: ofs = 0x2882; break;
case GameVersion.HGSS: ofs = 0x2372; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x25FE; break;
case GameVersion.Pt: ofs = 0x2882; break;
case GameVersion.HGSS: ofs = 0x2372; break;
}
BitConverter.GetBytes((ushort)value).CopyTo(General, ofs);
}
}
public int Z
{
get
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x2602; break;
case GameVersion.Pt: ofs = 0x2886; break;
case GameVersion.HGSS: ofs = 0x2376; break;
}
return BitConverter.ToUInt16(General, ofs);
}
set
{
int ofs = 0;
switch (Version)
{
case GameVersion.DP: ofs = 0x2602; break;
case GameVersion.Pt: ofs = 0x2886; break;
case GameVersion.HGSS: ofs = 0x2376; break;
}
BitConverter.GetBytes((ushort)value).CopyTo(General, ofs);
}
}
public abstract int X2 { get; set; }
public abstract int Y2 { get; set; }
public abstract int Z { get; set; }
public override uint SecondsToStart { get => BitConverter.ToUInt32(General, AdventureInfo + 0x34); set => BitConverter.GetBytes(value).CopyTo(General, AdventureInfo + 0x34); }
public override uint SecondsToFame { get => BitConverter.ToUInt32(General, AdventureInfo + 0x3C); set => BitConverter.GetBytes(value).CopyTo(General, AdventureInfo + 0x3C); }

View File

@ -139,5 +139,12 @@ private void SetActiveGiftFlags(IReadOnlyList<MysteryGift> gifts)
arr[i] = !gifts[i].Empty;
SetMysteryGiftDPSlotActiveFlags(arr);
}
public override int M { get => BitConverter.ToUInt16(General, 0x1238); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1238); }
public override int X { get => BitConverter.ToUInt16(General, 0x1240); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x1240); }
public override int Y { get => BitConverter.ToUInt16(General, 0x1244); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x1244); }
public override int X2 { get => BitConverter.ToUInt16(General, 0x25FA); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x25FA); }
public override int Y2 { get => BitConverter.ToUInt16(General, 0x25FE); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x25FE); }
public override int Z { get => BitConverter.ToUInt16(General, 0x2602); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2602); }
}
}
}

View File

@ -150,6 +150,13 @@ public override IReadOnlyList<InventoryPouch> Inventory
set => value.SaveAll(General);
}
public override int M { get => BitConverter.ToUInt16(General, 0x1234); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1234); }
public override int X { get => BitConverter.ToUInt16(General, 0x123C); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x123C); }
public override int Y { get => BitConverter.ToUInt16(General, 0x1240); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x1240); }
public override int X2 { get => BitConverter.ToUInt16(General, 0x236E); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x236E); }
public override int Y2 { get => BitConverter.ToUInt16(General, 0x2372); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2372); }
public override int Z { get => BitConverter.ToUInt16(General, 0x2376); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2376); }
public int Badges16
{
get => General[Trainer1 + 0x1F];

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
namespace PKHeX.Core
{
@ -105,5 +106,12 @@ public override IReadOnlyList<InventoryPouch> Inventory
}
set => value.SaveAll(General);
}
public override int M { get => BitConverter.ToUInt16(General, 0x1280); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x1280); }
public override int X { get => BitConverter.ToUInt16(General, 0x1288); set => BitConverter.GetBytes((ushort)(X2 = value)).CopyTo(General, 0x1288); }
public override int Y { get => BitConverter.ToUInt16(General, 0x128C); set => BitConverter.GetBytes((ushort)(Y2 = value)).CopyTo(General, 0x128C); }
public override int X2 { get => BitConverter.ToUInt16(General, 0x287E); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x287E); }
public override int Y2 { get => BitConverter.ToUInt16(General, 0x2882); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2882); }
public override int Z { get => BitConverter.ToUInt16(General, 0x2886); set => BitConverter.GetBytes((ushort)value).CopyTo(General, 0x2886); }
}
}