private static bool serializableUberState(UberStateType type) { switch (type) { case UberStateType.PlayerUberStateDescriptor: case UberStateType.SavePedestalUberState: case UberStateType.SerializedByteUberState: case UberStateType.SerializedBooleanUberState: case UberStateType.SerializedIntUberState: case UberStateType.SerializedFloatUberState: return(true); default: return(false); } }
public static string FmtVal(this UberValue Value, UberStateType t) { switch (t) { case UberStateType.SavePedestalUberState: case UberStateType.SerializedBooleanUberState: return($"{Value.Bool}"); case UberStateType.SerializedByteUberState: return($"{Value.Byte}"); case UberStateType.SerializedIntUberState: return($"{Value.Int}"); case UberStateType.SerializedFloatUberState: return($"{Value.Float}"); } return($"{t}-{Value}"); }
public static UberValue CreateValue(UberStateType type, float value) { switch (type) { case UberStateType.PlayerUberStateDescriptor: case UberStateType.SavePedestalUberState: case UberStateType.SerializedByteUberState: return(new UberValue((byte)value)); case UberStateType.SerializedBooleanUberState: return(new UberValue(!(Math.Abs(value) < 0.001f))); case UberStateType.SerializedIntUberState: return(new UberValue((int)value)); default: return(new UberValue(value)); } }
public static float AsFloat(this UberValue v, UberStateType t) { switch (t) { case UberStateType.SavePedestalUberState: case UberStateType.ByteUberState: case UberStateType.SerializedByteUberState: return(Convert.ToSingle(v.Byte)); case UberStateType.BooleanUberState: case UberStateType.SerializedBooleanUberState: return(v.Bool ? 1.0f : 0.0f); case UberStateType.SerializedFloatUberState: return(v.Float); case UberStateType.IntUberState: case UberStateType.SerializedIntUberState: default: return(Convert.ToSingle(v.Int)); } }
public static int AsInt(this UberValue v, UberStateType t) { switch (t) { case UberStateType.SavePedestalUberState: case UberStateType.ByteUberState: case UberStateType.SerializedByteUberState: return(Convert.ToInt32(v.Byte)); case UberStateType.BooleanUberState: case UberStateType.SerializedBooleanUberState: return(Convert.ToInt32(v.Bool)); case UberStateType.SerializedFloatUberState: return(Convert.ToInt32(v.Float)); case UberStateType.IntUberState: case UberStateType.SerializedIntUberState: default: return(v.Int); } }
private void PopulateUberStates() { uberIDLookup = new Dictionary <long, UberState>(); //UberStateCollection.Instance.m_descriptorsArray IntPtr descriptors = UberStateCollection.Read <IntPtr>(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 = Program.Read <IntPtr>(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 = Program.Read <IntPtr>(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); } }