public ME3Class(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { _ImplInterfaces = new List<InterfaceMapEntry>(); _Components = new List<ComponentMapEntry>(); _FunctionRefs = new List<Int32>(); }
public bool LoadFromSource(PCCFile source) { SourcePCC = source; var entry = PCCFile.GetExportFromImport(this); if (entry == null) return false; SourceEntry = entry as ExportTableEntry; Object = SourceEntry.Object; ObjectType = SourceEntry.ObjectType; OuterObject = entry.OuterObject; OuterName = entry.OuterName; FullyLoaded = true; return true; }
public ME3ArrayProperty(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { }
public ME3ScriptStruct(ObjectReader data, ExportTableEntry exp, PCCFile pccObj) : base(data, exp, pccObj) { }
public ME3Object(ObjectReader data, ExportTableEntry exp, PCCFile pcc) { PCC = pcc; Data = data; ExportEntry = exp; }
public ME3Enum(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { }
public ObjectReader GetReader(ExportTableEntry export) { return GetReader(export.FileOffset, export.Size); }
public ME3State(ObjectReader data, ExportTableEntry exp, PCCFile pcc) : base(data, exp, pcc) { _FunctionMap = new List<FunctionMapEntry>(); }
private bool DeserializeExports() { uint pos = 0; for (int n = 0; n < _exportCount; n++) { var export = new ExportTableEntry(this, Data.GetReader(_exportOffset + pos, ExportTableEntry.SizeInBytes)); int result = export.Deserialize(); if (result == -1) return false; pos += (uint)result; Exports.Add(export); } return true; }
private bool DeserializeExportObject(ExportTableEntry entry) { switch (entry.ClassName) { case "Class": var classObj = new ME3Class(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = classObj; return classObj.Deserialize(); case "Function": var funcObj = new ME3Function(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = funcObj; return funcObj.Deserialize(); case "Struct": var structObj = new ME3Struct(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = structObj; return structObj.Deserialize(); case "ScriptStruct": var scriptstructObj = new ME3ScriptStruct(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = scriptstructObj; return scriptstructObj.Deserialize(); case "Enum": var enumObj = new ME3Enum(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = enumObj; return enumObj.Deserialize(); case "Const": var constObj = new ME3Const(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = constObj; return constObj.Deserialize(); case "State": var stateObj = new ME3State(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = stateObj; return stateObj.Deserialize(); case "ArrayProperty": var arrayProp = new ME3ArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = arrayProp; return arrayProp.Deserialize(); case "IntProperty": var intProp = new ME3IntProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = intProp; return intProp.Deserialize(); case "BoolProperty": var boolProp = new ME3BoolProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = boolProp; return boolProp.Deserialize(); case "ByteProperty": var byteProp = new ME3ByteProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = byteProp; return byteProp.Deserialize(); case "ObjectProperty": var objectProp = new ME3ObjectProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = objectProp; return objectProp.Deserialize(); case "ClassProperty": var classProp = new ME3ClassProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = classProp; return classProp.Deserialize(); case "ComponentProperty": var compProp = new ME3ComponentProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = compProp; return compProp.Deserialize(); case "DelegateProperty": var deleProp = new ME3DelegateProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = deleProp; return deleProp.Deserialize(); case "FixedArrayProperty": var fixedProp = new ME3FixedArrayProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = fixedProp; return fixedProp.Deserialize(); case "FloatProperty": var floatProp = new ME3FloatProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = floatProp; return floatProp.Deserialize(); case "InterfaceProperty": var interfaceProp = new ME3InterfaceProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = interfaceProp; return interfaceProp.Deserialize(); case "NameProperty": var nameProp = new ME3NameProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = nameProp; return nameProp.Deserialize(); case "StrProperty": var strProp = new ME3StrProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = strProp; return strProp.Deserialize(); case "StructProperty": var structProp = new ME3StructProperty(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = structProp; return structProp.Deserialize(); default : var obj = new ME3Object(Data.GetReader(entry.FileOffset, entry.Size), entry, this); entry.Object = obj; return obj.Deserialize(); } }
public static ExportTableEntry GetExportFromImport(ImportTableEntry entry) { if (entry.ClassName == "Package") { return new ExportTableEntry(null, null); // TODO: this imports the whole package? } var OuterTree = entry.GetOuterTreeString().Split(new char[] {'.'}, 2, StringSplitOptions.RemoveEmptyEntries); if (OuterTree[0] == entry.CurrentPCC.Name || _NativeOnlyPackages.Contains(OuterTree[0]) || _CoreObjectTypes.Contains(entry.ObjectName)) { if (entry.ClassName == "Class") { // Quick hack until all classes are mapped var nativeClass = new ExportTableEntry(null, null); nativeClass.ObjectName = entry.ObjectName; nativeClass.OuterName = "object"; nativeClass.ClassName = "Class"; nativeClass.Object = new NativeME3Class(entry.ObjectName); nativeClass.FullyNative = true; return nativeClass; } // Quick hack until all objects are mapped var native = new ExportTableEntry(null, null); native.ObjectName = entry.ObjectName; native.OuterName = "object"; native.ClassName = "Class"; native.Object = new NativeME3Class(entry.ObjectName); native.FullyNative = true; return native; //Console.WriteLine(entry.SourcePCCName + " to " + entry.CurrentPCC.Name + " | " + entry.ClassName + " | " + entry.GetOuterTreeString() + "." + entry.ObjectName); // TODO: this means its a fully native object, we should create those for all types required by ME3. } if (entry.SourcePCCName != OuterTree[0]) { var realPCC = entry.CurrentPCC.ImportPackages.FirstOrDefault(x => x.Name == OuterTree[0]); if (realPCC == null) return null; // Error, missing import? entry.SourcePCC = realPCC; } var objects = entry.SourcePCC.Exports.Where(x => // TODO: can probably be much quicker, perhaps by outer tree traversal? String.Equals(x.ObjectName, entry.ObjectName, StringComparison.OrdinalIgnoreCase) && String.Equals(x.ClassName, entry.ClassName, StringComparison.OrdinalIgnoreCase)); if (objects.Count() > 1) { if (OuterTree.Length == 2) { objects = objects.Where(x => String.Equals(x.GetOuterTreeString(), OuterTree[1], StringComparison.OrdinalIgnoreCase)); } else { objects = objects.Where(x => x.GetOuterTreeString() == String.Empty); // should not happen? } } if (objects.Count() != 1) { return null; // This should not happen unless we have a faulty import. } return objects.First(); }