public void WriteUberState(UberState uberState) { //UbserStateController.m_currentStateValueStore.m_groupMap IntPtr groups = (IntPtr)UberStateController.Read <ulong>(Program, 0xb8, 0x40, 0x18); //.Count int groupCount = Program.Read <int>(groups, 0x20); //.Values groups = (IntPtr)Program.Read <ulong>(groups, 0x18); byte[] groupsData = Program.Read(groups + 0x20, groupCount * 0x18); for (int i = 0; i < groupCount; i++) { //.Values[i].m_id.m_id IntPtr group = (IntPtr)BitConverter.ToUInt64(groupsData, 0x10 + (i * 0x18)); byte[] groupData = Program.Read(group + 0x18, 48); long groupID = Program.Read <int>((IntPtr)BitConverter.ToUInt64(groupData, 0), 0x10); if (groupID != uberState.GroupID) { continue; } //.Values[i].m_objectStateMap IntPtr map = (IntPtr)BitConverter.ToUInt64(groupData, 8); //.Values[i].m_objectStateMap.Count int mapCount = Program.Read <int>(map, 0x20); if (mapCount > 0 && (uberState.IsObjectType)) { map = (IntPtr)Program.Read <ulong>(map, 0x18); byte[] data = Program.Read(map + 0x20, mapCount * 0x18); for (int j = 0; j < mapCount; j++) { //.Values[i].m_objectStateMap.Keys[j] long id = BitConverter.ToInt32(data, j * 0x18); if (id != uberState.ID) { continue; } if (uberState.Type == UberStateType.SavePedestalUberState) { // uberState.Value.Byte = Program.Read<byte>((IntPtr)BitConverter.ToUInt64(data, 0x10 + (j * 0x18)), 0x11); Program.Write <byte>((IntPtr)BitConverter.ToUInt64(data, 0x10 + (j * 0x18)), uberState.Value.Byte, 0x11); } else { //playerUberStateDescriptor } } } //.Values[i].m_boolStateMap map = (IntPtr)BitConverter.ToUInt64(groupData, 16); //.Values[i].m_boolStateMap.Count mapCount = Program.Read <int>(map, 0x20); if (mapCount > 0 && (uberState.IsBoolType)) { map = (IntPtr)Program.Read <ulong>(map, 0x18); byte[] data = Program.Read(map + 0x20, mapCount * 0x18); for (int j = 0; j < mapCount; j++) { //.Values[i].m_boolStateMap.Keys[j] long id = BitConverter.ToInt32(data, j * 0x18); if (id != uberState.ID) { continue; } // uberState.Value.Bool = data[0x10 + (j * 0x18)] != 0; Program.Write <byte>(map + 0x20, uberState.Value.Byte, 0x10 + (j * 0x18)); } } //.Values[i].m_floatStateMap map = (IntPtr)BitConverter.ToUInt64(groupData, 24); //.Values[i].m_floatStateMap.Count mapCount = Program.Read <int>(map, 0x20); if (mapCount > 0 && (uberState.IsFloatType)) { map = (IntPtr)Program.Read <ulong>(map, 0x18); byte[] data = Program.Read(map + 0x20, mapCount * 0x18); for (int j = 0; j < mapCount; j++) { //.Values[i].m_floatStateMap.Keys[j] long id = BitConverter.ToInt32(data, j * 0x18); if (id != uberState.ID) { continue; } // uberState.Value.Float = BitConverter.ToSingle(data, 0x10 + (j * 0x18)); Program.Write <float>(map + 0x20, uberState.Value.Float, 0x10 + (j * 0x18)); } } //.Values[i].m_intStateMap map = (IntPtr)BitConverter.ToUInt64(groupData, 32); //.Values[i].m_intStateMap.Count mapCount = Program.Read <int>(map, 0x20); if (mapCount > 0 && (uberState.IsIntType)) { map = (IntPtr)Program.Read <ulong>(map, 0x18); byte[] data = Program.Read(map + 0x20, mapCount * 0x18); for (int j = 0; j < mapCount; j++) { //.Values[i].m_intStateMap.Keys[j] long id = BitConverter.ToInt32(data, j * 0x18); if (id != uberState.ID) { continue; } // uberState.Value.Int = BitConverter.ToInt32(data, 0x10 + (j * 0x18)); Program.Write <Int32>(map + 0x20, uberState.Value.Int, 0x10 + (j * 0x18)); } } //.Values[i].m_byteStateMap map = (IntPtr)BitConverter.ToUInt64(groupData, 40); //.Values[i].m_byteStateMap.Count mapCount = Program.Read <int>(map, 0x20); if (mapCount > 0 && (uberState.IsByteType)) { map = (IntPtr)Program.Read <ulong>(map, 0x18); byte[] data = Program.Read(map + 0x20, mapCount * 0x18); for (int j = 0; j < mapCount; j++) { //.Values[i].m_byteStateMap.Keys[j] long id = BitConverter.ToInt32(data, j * 0x18); if (id != uberState.ID) { continue; } // uberState.Value.Byte = data[0x10 + (j * 0x18)]; Program.Write <byte>(map + 0x20, uberState.Value.Byte, 0x10 + (j * 0x18)); } } } }
private void PopulateUberStates() { uberIDLookup = new Dictionary <long, UberState>(); //UberStateCollection.Instance.m_descriptorsArray IntPtr descriptors = (IntPtr)UberStateCollection.Read <ulong>(Program, 0xb8, 0x10, 0x20); //.Count int descriptorsCount = Program.Read <int>(descriptors, 0x18); byte[] data = Program.Read(descriptors + 0x20, descriptorsCount * 0x8); for (int i = 0; i < descriptorsCount; i++) { //.m_descriptorsArray[i] IntPtr descriptor = (IntPtr)BitConverter.ToUInt64(data, i * 0x8); UberStateType type = UberStateType.SerializedBooleanUberState; Enum.TryParse <UberStateType>(Program.ReadAscii(descriptor, 0x0, 0x10, 0x0), out type); int groupOffset = 0x38; switch (type) { case UberStateType.SerializedByteUberState: case UberStateType.SerializedIntUberState: case UberStateType.SavePedestalUberState: groupOffset = 0x30; break; case UberStateType.PlayerUberStateDescriptor: groupOffset = 0x40; break; case UberStateType.CountUberState: case UberStateType.BooleanUberState: case UberStateType.ByteUberState: case UberStateType.IntUberState: case UberStateType.ConditionUberState: continue; } //.m_descriptorsArray[i].ID.m_id int id = Program.Read <int>(descriptor, 0x18, 0x10); //.m_descriptorsArray[i].Name IntPtr namePtr = (IntPtr)Program.Read <ulong>(descriptor, 0x10, 0x48); string name = string.Empty; if (namePtr != IntPtr.Zero) { name = Program.ReadAscii(namePtr); } else { name = Program.ReadAscii(descriptor, 0x10, 0x50); } //.m_descriptorsArray[i].Group.ID.m_id int groupID = Program.Read <int>(descriptor, groupOffset, 0x18, 0x10); //.m_descriptorsArray[i].Group.Name namePtr = (IntPtr)Program.Read <ulong>(descriptor, groupOffset, 0x10, 0x48); string groupName = string.Empty; if (namePtr != IntPtr.Zero) { groupName = Program.ReadAscii(namePtr); } else { groupName = Program.ReadAscii(descriptor, groupOffset, 0x10, 0x50); } UberState uberState = new UberState() { Type = type, ID = id, Name = name, GroupID = groupID, GroupName = groupName }; uberIDLookup.Add(((long)groupID << 32) | (long)id, uberState); } }