Ejemplo n.º 1
0
        public State ConvertState(ME3State obj)
        {
            // TODO: ignores and body/labels

            State parent = null;
            if (obj.SuperField != null)
                parent = new State(obj.SuperField.Name, null, null, null, null, null, null, null, null);

            var Funcs = new List<Function>();
            var Ignores = new List<Function>();
            foreach (var member in obj.DefinedFunctions)
            {
                if (member.FunctionFlags.HasFlag(FunctionFlags.Defined))
                    Funcs.Add(ConvertFunction(member));
                else
                    Ignores.Add(new Function(member.Name, null, null,
                         null, null, null, null));
                /* Ignored functions are not marked as defined, so we dont need to lookup the ignormask.
                 * They are defined though, each being its own proper object with simply a return nothing for bytecode.
                 * */
            }

            var ByteCode = new ME3ByteCodeDecompiler(obj, new List<FunctionParameter>());
            var body = ByteCode.Decompile();

            return new State(obj.Name, body, new List<Specifier>(), (State)parent, Funcs, new List<Function>(), new List<StateLabel>(), null, null);
        }
Ejemplo n.º 2
0
        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();
            }
        }