public ManagedRecvTable(int address) { Address = address; RecvTable = new LazyCache <RecvTable_t>(() => Program.Hack.Memory.Read <RecvTable_t>(address)); var r = RecvTable; NetTableName = new LazyCache <string>(() => Program.Hack.Memory.ReadString(r.Value.m_pNetTableName, 32, Encoding.ASCII)); RecvProps = new LazyCache <ManagedRecvProp[]>(() => { ManagedRecvProp[] props = new ManagedRecvProp[r.Value.m_nProps]; for (int i = 0; i < props.Length; i++) { props[i] = new ManagedRecvProp(r.Value.m_pProps + i * 0x3C, this); } return(props); }); HighestOffset = new LazyCache <int>(() => { return(RecvProps.Value.Length == 0 ? 0 : RecvProps.Value.Max(x => x == null ? 0 : x.Offset));// GetHighestOffset(this); }); BaseClassDepth = new LazyCache <int>(() => { if (BaseClass.Value != null) { return(1 + BaseClass.Value.BaseClassDepth); } return(0); }); BaseClass = new LazyCache <ManagedRecvTable>(() => { if (RecvProps.Value.Any(x => x.VarName == "baseclass")) { return(RecvProps.Value.First(x => x.VarName == "baseclass").SubTable); } return(null); }); Size = new LazyCache <int>(() => RecvProps.Value.Length > 0 ? RecvProps.Value.Last().Size : 0); }
public ManagedRecvProp(int address, ManagedRecvTable table) { Address = address; Table = table; RecvProp = new LazyCache <RecvProp_t>(() => Program.Hack.Memory.Read <RecvProp_t>(address)); var r = RecvProp; VarName = new LazyCache <string>(() => Program.Hack.Memory.ReadString(r.Value.m_pVarName, 32, Encoding.ASCII)); SubTable = new LazyCache <ManagedRecvTable>(() => { if (r.Value.m_pDataTable == 0) { return(null); } return(new ManagedRecvTable(r.Value.m_pDataTable)); }); BaseClassDepth = new LazyCache <int>(() => SubTable.Value != null ? 1 + SubTable.Value.BaseClassDepth : 0); Size = new LazyCache <int>(() => { if (SubTable.Value != null) { return(SubTable.Value.Size); } int size = RecvProp_t.GetPropTypeSize(Type); if (size >= 0) { return(size); } switch (Type) { case RecvProp_t.ePropType.String: return(StringBufferSize); case RecvProp_t.ePropType.Array: if (ArrayProp.Value.Length > 0) { return(ElementCount * ArrayProp.Value[0].Size); } return(0); } return(0); }); ArrayProp = new LazyCache <ManagedRecvProp[]>(() => { if (this.Type != RecvProp_t.ePropType.Array || this.RecvProp.Value.m_pArrayProp == 0 || this.ElementCount == 0) { return(new ManagedRecvProp[0]); } var props = new ManagedRecvProp[this.ElementCount]; for (int i = 0; i < props.Length; i++) { int a = this.RecvProp.Value.m_pArrayProp + SizeCache <RecvProp_t> .Size * i; if (address == a) { props[i] = this; } else { props[i] = new ManagedRecvProp(a, table); } } return(props); }); }