Esempio n. 1
0
            public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW)
            {
                n.Keys = r.ReadArray(i =>
                {
                    var time           = r.ReadSingle();
                    var position       = r.ReadVec3();
                    var pitchYawRoll   = r.ReadVec3(); // in radians
                    var fov            = r.ReadSingle();
                    var anchorRot      = r.ReadBoolean();
                    var anchor         = r.ReadInt32();
                    var anchorVis      = r.ReadBoolean();
                    var target         = r.ReadInt32();
                    var targetPosition = r.ReadVec3();
                    var a = r.ReadSingle(); // 1
                    var b = r.ReadSingle(); // -0.48
                    var c = r.ReadSingle(); // 0
                    var d = r.ReadSingle(); // 0
                    var e = r.ReadSingle();

                    return(new Key()
                    {
                        Time = time,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,
                        AnchorRot = anchorRot,
                        Anchor = anchor,
                        AnchorVis = anchorVis,
                        Target = target,
                        TargetPosition = targetPosition,
                        Unknown = new object[] { a, b, c, d, e }
                    });
                });
            }
Esempio n. 2
0
            public override void Read(CGameCtnMediaBlockCameraPath n, GameBoxReader r, GameBoxWriter unknownW)
            {
                Version = r.ReadInt32();

                n.Keys = r.ReadArray(i =>
                {
                    var time         = r.ReadSingle();
                    var position     = r.ReadVec3();
                    var pitchYawRoll = r.ReadVec3(); // in radians
                    var fov          = r.ReadSingle();

                    float?nearZ = null;
                    if (Version >= 3)
                    {
                        nearZ = r.ReadSingle();
                    }
                    var anchorRot      = r.ReadBoolean();
                    var anchor         = r.ReadInt32();
                    var anchorVis      = r.ReadBoolean();
                    var target         = r.ReadInt32();
                    var targetPosition = r.ReadVec3();

                    var unknown = r.ReadArray <float>(5).Cast <object>().ToList();

                    if (Version >= 4)
                    {
                        unknown.AddRange(r.ReadArray <int>(2).Cast <object>());
                    }

                    return(new Key()
                    {
                        Time = time,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,
                        NearZ = nearZ,
                        AnchorRot = anchorRot,
                        Anchor = anchor,
                        AnchorVis = anchorVis,
                        Target = target,
                        TargetPosition = targetPosition,
                        Unknown = unknown.Cast <object>().ToArray()
                    });
                });
            }
            public override void Read(CGameCtnMediaBlockCameraCustom n, GameBoxReader r, GameBoxWriter unknownW)
            {
                Version = r.ReadInt32();
                n.Keys  = r.ReadArray(i =>
                {
                    var time         = r.ReadSingle();
                    var a            = r.ReadInt32();   // 1
                    var anchorRot    = r.ReadBoolean(); // 0
                    var anchor       = r.ReadInt32();   // -1 if not set, 0 for local player
                    var anchorVis    = r.ReadBoolean(); // 1
                    var target       = r.ReadInt32();   // -1
                    var position     = r.ReadVec3();
                    var pitchYawRoll = r.ReadVec3();    // in radians
                    var fov          = r.ReadSingle();
                    var f            = r.ReadInt32();   // 0
                    var g            = r.ReadInt32();   // 0
                    var h            = r.ReadInt32();   // 0
                    var zIndex       = r.ReadSingle();
                    var leftTangent  = r.ReadVec3();
                    var ii           = r.ReadArray <float>(8);
                    var rightTangent = r.ReadVec3();
                    var j            = r.ReadArray <float>(8);

                    return(new Key()
                    {
                        Time = time,
                        AnchorRot = anchorRot,
                        Anchor = anchor,
                        AnchorVis = anchorVis,
                        Target = target,
                        Position = position,
                        PitchYawRoll = pitchYawRoll,
                        FOV = fov,
                        ZIndex = zIndex,
                        LeftTangent = leftTangent,
                        RightTangent = rightTangent,

                        Unknown = new object[]
                        {
                            a, f, g, h, ii, j
                        }
                    });
                }).ToList();
            }
 public override void Read(CGameCtnMediaBlockFxBlurDepth n, GameBoxReader r, GameBoxWriter unknownW)
 {
     n.Keys = r.ReadArray(i =>
     {
         return(new Key()
         {
             Time = r.ReadSingle(),
             LensSize = r.ReadSingle(),
             ForceFocus = r.ReadBoolean(),
             FocusZ = r.ReadSingle(),
         });
     });
 }
Esempio n. 5
0
    internal void Read(GameBoxReader reader)
    {
        var numFiles = reader.ReadInt32(); // With this, number of files value can be optimized

        if (numFiles <= 0)
        {
            Log.Write("No external nodes found, reference table completed.", ConsoleColor.Green);
            return;
        }

        AncestorLevel = reader.ReadInt32();
        var numFolders = reader.ReadInt32();

        var allFolders = new List <Folder>();

        Folders = ReadRefTableFolders(numFolders);

        Folder[] ReadRefTableFolders(int n)
        {
            var folders = new Folder[n];

            for (var i = 0; i < n; i++)
            {
                var name          = reader.ReadString();
                var numSubFolders = reader.ReadInt32();

                var folder = new Folder(name);
                allFolders.Add(folder);
                foreach (var subFolder in ReadRefTableFolders(numSubFolders))
                {
                    folder.Folders.Add(subFolder);
                }

                folders[i] = folder;
            }

            return(folders);
        }

        Files = new List <File>();

        for (var i = 0; i < numFiles; i++)
        {
            string?fileName      = null;
            int?   resourceIndex = null;
            bool?  useFile       = null;
            int?   folderIndex   = null;

            var flags = reader.ReadInt32();

            if ((flags & 4) == 0)
            {
                fileName = reader.ReadString();
            }
            else
            {
                resourceIndex = reader.ReadInt32();
            }

            var nodeIndex = reader.ReadInt32();

            if (Header.Version >= 5)
            {
                useFile = reader.ReadBoolean();
            }

            if ((flags & 4) == 0)
            {
                folderIndex = reader.ReadInt32();
            }

            var file = new File(flags, fileName, resourceIndex, nodeIndex, useFile, folderIndex);

            if (folderIndex.HasValue)
            {
                if (folderIndex.Value - 1 < 0)
                {
                    Files.Add(file);
                }
                else
                {
                    allFolders[folderIndex.Value - 1].Files.Add(file);
                }
            }
        }
    }
Esempio n. 6
0
    private static ScriptVariable ReadType(ScriptVariable type, GameBoxReader r)
    {
        switch (type.Type)
        {
        case ScriptType.Boolean:
            type.Value = r.ReadBoolean(true);
            break;

        case ScriptType.Integer:
            type.Value = r.ReadInt32();
            break;

        case ScriptType.Real:
            type.Value = r.ReadSingle();
            break;

        case ScriptType.Text:
            type.Value = r.ReadString(StringLengthPrefix.Byte);
            break;

        case ScriptType.Vec2:
            type.Value = r.ReadVec2();
            break;

        case ScriptType.Vec3:
            type.Value = r.ReadVec3();
            break;

        case ScriptType.Int3:
            type.Value = r.ReadInt3();
            break;

        case ScriptType.Int2:
            type.Value = r.ReadInt2();
            break;

        case ScriptType.Array:
            var array = (ScriptArray)type;

            var numElements = r.ReadByte();
            if (numElements > 0)
            {
                ScriptVariable key;
                if (array.Reference.Key.Type == ScriptType.Void)
                {
                    for (var i = 0; i < numElements; i++)
                    {
                        array.Elements[new ScriptVariable(ScriptType.Void)
                                       {
                                           Value = i
                                       }] = ReadType(array.Reference.Value.Clone(), r);
                    }
                }
                else
                {
                    key = ReadType(array.Reference.Key.Clone(), r);
                    for (var i = 0; i < numElements; i++)
                    {
                        array.Elements[key] = ReadType(array.Reference.Value.Clone(), r);
                    }
                }
            }
            break;

        case ScriptType.Struct:
            var strc = (ScriptStruct)type;
            for (var i = 0; i < strc.Members.Length; i++)
            {
                strc.Members[i] = ReadType(strc.Members[i], r);
            }
            break;

        default:
            throw new Exception(type.Type.ToString());
        }

        return(type);
    }
Esempio n. 7
0
        public void Read(GameBoxReader r)
        {
            var classId = r.ReadUInt32();

            Version = r.ReadInt32();

            var typeCount = r.ReadByte();
            var types     = new ScriptVariable[typeCount];

            for (var i = 0; i < typeCount; i++)
            {
                var varType = r.ReadByte();

                switch ((ScriptType)varType)
                {
                case ScriptType.Array:
                    types[i] = ReadScriptArray();
                    break;

                case ScriptType.Struct:
                    types[i] = ReadScriptStruct(out int defaultLength);
                    break;

                default:
                    types[i] = new ScriptVariable((ScriptType)varType);
                    break;
                }
            }

            var varCount = r.ReadByte();
            var metadata = new ScriptVariable[varCount];

            for (var i = 0; i < varCount; i++)
            {
                var metadataVarName = r.ReadString(StringLengthPrefix.Byte);
                var typeIndex       = r.ReadByte();

                var type = types[typeIndex];
                metadata[i]      = ReadType(type.Clone());
                metadata[i].Name = metadataVarName;
            }

            Metadata = metadata.ToList();

            var facade = r.ReadUInt32();

            ScriptArray ReadScriptArray()
            {
                ScriptVariable indexVar;

                var indexType = r.ReadByte(); // index

                if ((ScriptType)indexType == ScriptType.Struct)
                {
                    indexVar = ReadScriptStruct(out int defaultLength);
                }
                else
                {
                    indexVar = new ScriptVariable((ScriptType)indexType);
                }

                ScriptVariable valueVar;

                var arrayType = r.ReadByte(); // value

                if ((ScriptType)arrayType == ScriptType.Array)
                {
                    valueVar = ReadScriptArray();
                }
                else if ((ScriptType)arrayType == ScriptType.Struct)
                {
                    valueVar = ReadScriptStruct(out int defaultLength);
                }
                else
                {
                    valueVar = new ScriptVariable((ScriptType)arrayType);
                }

                ScriptArray array = new ScriptArray(new KeyValuePair <ScriptVariable, ScriptVariable>(indexVar, valueVar));

                int counterArray = 0;

                while (r.ReadByte() == 0)
                {
                    counterArray++;
                }
                r.BaseStream.Position -= 1;

                array.Unknown = counterArray;

                return(array);
            }

            ScriptStruct ReadScriptStruct(out int defaultLength)
            {
                var strc = new ScriptStruct();

                var numMembers = r.ReadByte();
                var structName = r.ReadString();

                strc.StructName = structName;
                strc.Members    = new ScriptVariable[numMembers];

                defaultLength = 0;

                for (var i = 0; i < numMembers; i++)
                {
                    ScriptVariable member;

                    var memberName = r.ReadString();
                    var memberType = r.ReadByte();

                    switch ((ScriptType)memberType)
                    {
                    case ScriptType.Array:
                        member = ReadScriptArray();
                        break;

                    case ScriptType.Struct:
                        member         = ReadScriptStruct(out int defLength);
                        defaultLength += defLength;
                        break;

                    default:
                        member = new ScriptVariable((ScriptType)memberType);
                        break;
                    }

                    switch (member.Type)
                    {
                    case ScriptType.Integer:
                        r.ReadInt32();
                        defaultLength += 4;
                        break;

                    case ScriptType.Real:
                        r.ReadSingle();
                        defaultLength += 4;
                        break;

                    case ScriptType.Vec2:
                        r.ReadVec2();
                        defaultLength += 8;
                        break;

                    case ScriptType.Vec3:
                        r.ReadVec3();
                        defaultLength += 12;
                        break;

                    case ScriptType.Int3:
                        r.ReadInt3();
                        defaultLength += 12;
                        break;

                    case ScriptType.Int2:
                        r.ReadInt2();
                        defaultLength += 8;
                        break;

                    case ScriptType.Array:
                        break;

                    case ScriptType.Struct:
                        break;

                    default:
                        r.ReadByte();
                        defaultLength += 1;
                        break;
                    }

                    member.Name = memberName;

                    strc.Members[i] = member;
                }

                int counter = 0;

                while (r.ReadByte() == 0)
                {
                    counter++;
                }
                r.BaseStream.Position -= 1;

                //int counter = 0;
                //while (r.ReadByte() == 0) counter++; // probably size of the struct in byte count?
                //r.BaseStream.Position -= 1;
                strc.Size    = defaultLength + counter; //
                strc.Unknown = counter;

                //Progress += defaultLength;

                return(strc);
            }

            ScriptVariable ReadType(ScriptVariable type)
            {
                switch (type.Type)
                {
                case ScriptType.Boolean:
                    type.Value = Convert.ToBoolean(r.ReadBoolean(true));
                    break;

                case ScriptType.Integer:
                    type.Value = r.ReadInt32();
                    break;

                case ScriptType.Real:
                    type.Value = r.ReadSingle();
                    break;

                case ScriptType.Text:
                    type.Value = r.ReadString(StringLengthPrefix.Byte);
                    break;

                case ScriptType.Vec2:
                    type.Value = r.ReadVec2();
                    break;

                case ScriptType.Vec3:
                    type.Value = r.ReadVec3();
                    break;

                case ScriptType.Int3:
                    type.Value = r.ReadInt3();
                    break;

                case ScriptType.Int2:
                    type.Value = r.ReadInt2();
                    break;

                case ScriptType.Array:
                    var array = type as ScriptArray;

                    var numElements = r.ReadByte();
                    if (numElements > 0)
                    {
                        ScriptVariable key;
                        if (array.Reference.Key.Type == ScriptType.Void)
                        {
                            for (var i = 0; i < numElements; i++)
                            {
                                array.Elements[new ScriptVariable(ScriptType.Void)
                                               {
                                                   Value = i
                                               }] = ReadType(array.Reference.Value.Clone());
                            }
                        }
                        else
                        {
                            key = ReadType(array.Reference.Key.Clone());
                            for (var i = 0; i < numElements; i++)
                            {
                                array.Elements[key] = ReadType(array.Reference.Value.Clone());
                            }
                        }
                    }
                    break;

                case ScriptType.Struct:
                    var strc = type as ScriptStruct;
                    for (var i = 0; i < strc.Members.Length; i++)
                    {
                        strc.Members[i] = ReadType(strc.Members[i]);
                    }
                    break;

                default:
                    throw new Exception(type.Type.ToString());
                }

                return(type);
            }
        }