Beispiel #1
0
        /// <summary>
        /// Reads a geometry animation from a byte array
        /// </summary>
        /// <param name="source">Byte source</param>
        /// <param name="address">Address at which the geometry animation is located</param>
        /// <param name="imageBase">Image base for all addresses</param>
        /// <param name="format">Attach format</param>
        /// <param name="DX">Whether the animation is for sadx</param>
        /// <param name="labels">C struct labels</param>
        /// <param name="models">Models that have already been read</param>
        /// <param name="attaches">Attaches that have already been read</param>
        /// <returns></returns>
        public static LandEntryMotion Read(byte[] source, uint address, uint imageBase, AttachFormat format, bool DX,
                                           Dictionary <uint, string> labels, Dictionary <uint, Attach> attaches)
        {
            float frame    = source.ToSingle(address);
            float step     = source.ToSingle(address + 4);
            float maxFrame = source.ToSingle(address + 8);

            uint     modelAddress = source.ToUInt32(address + 0xC) - imageBase;
            NJObject model        = NJObject.Read(source, modelAddress, imageBase, format, DX, labels, attaches);

            uint   motionAddress = source.ToUInt32(address + 0x10) - imageBase;
            Action action        = Action.Read(source, motionAddress, imageBase, format, DX, labels, attaches);

            uint texListPtr = source.ToUInt32(address + 0x14);

            return(new LandEntryMotion(frame, step, maxFrame, model, action, texListPtr));
        }
Beispiel #2
0
        /// <summary>
        /// Reads an action from a byte array
        /// </summary>
        /// <param name="source">Byte source</param>
        /// <param name="address">Address at which the action is located</param>
        /// <param name="imagebase">Image base for all addresses</param>
        /// <param name="format">Attach format</param>
        /// <param name="DX">Whether the file is for sadx</param>
        /// <param name="labels">C struct labels</param>
        /// <param name="attaches">Attaches that have already been read</param>
        /// <returns></returns>
        public static Action Read(byte[] source, uint address, uint imagebase, AttachFormat format, bool DX, Dictionary <uint, string> labels, Dictionary <uint, Attach> attaches)
        {
            uint mdlAddress = source.ToUInt32(address);

            if (mdlAddress == 0)
            {
                throw new FormatException($"Action at {address:X8} does not have a model!");
            }
            mdlAddress -= imagebase;
            NJObject mdl = NJObject.Read(source, mdlAddress, imagebase, format, DX, labels, attaches);

            uint aniAddress = source.ToUInt32(address + 4);

            if (aniAddress == 0)
            {
                throw new FormatException($"Action at {address:X8} does not have a model!");
            }
            aniAddress -= imagebase;
            Motion mtn = Motion.Read(source, ref aniAddress, imagebase, (uint)mdl.Count(), labels);

            return(new(mdl, mtn));
        }