Beispiel #1
0
        private byte[] WriteMobies(List <Model> mobyModels, int offset)
        {
            var headBytes = new byte[mobyModels.Count * 8 + 4];
            var bodBytes  = new List <byte>();

            WriteInt(headBytes, 0, mobyModels.Count);
            offset += headBytes.Length;

            for (int i = 0; i < mobyModels.Count; i++)
            {
                WriteInt(headBytes, 4 + i * 8, mobyModels[i].id);

                MobyModel g = (MobyModel)mobyModels[i];
                if (!g.isModel)
                {
                    continue;
                }

                WriteInt(headBytes, 4 + i * 8 + 4, offset);
                byte[] bodyByte = g.Serialize(offset);
                bodBytes.AddRange(bodyByte);
                offset += bodyByte.Length;
            }

            var outBuff = new byte[headBytes.Length + bodBytes.Count];

            headBytes.CopyTo(outBuff, 0);
            bodBytes.CopyTo(outBuff, headBytes.Length);

            return(outBuff);
        }
Beispiel #2
0
        private byte[] WriteWeapons(List <Model> weaponModels, int offset)
        {
            var headBytes = new byte[weaponModels.Count * 0x10];
            var bodyBytes = new List <byte>();

            int headLength = GetLength(headBytes.Length);

            offset += headLength;

            for (int i = 0; i < weaponModels.Count; i++)
            {
                WriteInt(headBytes, i * 0x10, weaponModels[i].id);

                MobyModel g = (MobyModel)weaponModels[i];
                if (!g.isModel)
                {
                    continue;
                }

                byte[] bodyByte = g.Serialize(offset);
                WriteInt(headBytes, i * 0x10 + 4, offset);
                WriteInt(headBytes, i * 0x10 + 8, bodyByte.Length);
                bodyBytes.AddRange(bodyByte);
                offset += bodyByte.Length;
            }

            var outBuff = new byte[headLength + bodyBytes.Count];

            headBytes.CopyTo(outBuff, 0);
            bodyBytes.CopyTo(outBuff, headLength);

            return(outBuff);
        }
        public List <MobyModel> GetModels()
        {
            List <MobyModel> models = new List <MobyModel>();

            foreach (int modelPointer in gadgetHead.modelPointers)
            {
                models.Add(MobyModel.GetGadgetMobyModel(fileStream, modelPointer));
            }

            // textureID is always 0 based hence we shift them so that they match with the textures
            int offset = 0;

            for (int i = 0; i < models.Count; i++)
            {
                int maxID = 0;

                foreach (TextureConfig t in models[i].textureConfig)
                {
                    maxID = (maxID < t.id + 1) ? t.id + 1 : maxID;
                    t.id += offset;
                }

                offset += maxID;
            }

            return(models);
        }
Beispiel #4
0
        public List <Animation> GetPlayerAnimations(MobyModel ratchet)
        {
            if (engineHead.game.num == 4)
            {
                return(new List <Animation>());
            }

            return(GetPlayerAnimations(engineHead.playerAnimationPointer, ratchet));
        }
        public MobyModel GetArmor()
        {
            if (armorHead.modelPointer == 0)
            {
                return(null);
            }

            if (game.num == 4)
            {
                return(new MobyModel(fileStream, game, 0, armorHead.modelPointer));
            }
            else
            {
                return(MobyModel.GetArmorMobyModel(fileStream, armorHead.modelPointer));
            }
        }
        protected List <Animation> GetPlayerAnimations(int offset, MobyModel ratchet)
        {
            int count = ratchet.animations.Count;
            List <Animation> animations = new List <Animation>(ratchet.animations.Count);

            if (offset > 0)
            {
                byte boneCount = (byte)ratchet.boneMatrices.Count;

                byte[] headBlock = ReadBlock(fileStream, offset, count * 0x04);

                for (int i = 0; i < count; i++)
                {
                    animations.Add(new Animation(fileStream, ReadInt(headBlock, i * 4), 0, boneCount, true));
                }
            }

            return(animations);
        }
Beispiel #7
0
        public List <Model> GetModels()
        {
            List <Model> models = new List <Model>();

            byte[] mobyBlock = ReadBlock(fileStream, 0x10, missionHead.mobiesCount * 0x08);
            for (int i = 0; i < missionHead.mobiesCount; i++)
            {
                short modelID = ReadShort(mobyBlock, (i * 0x08) + 0x02);
                int   offset  = ReadInt(mobyBlock, (i * 0x08) + 0x04);

                if (offset != 0)
                {
                    MobyModel model = MobyModel.GetGadgetMobyModel(fileStream, offset);
                    model.id = modelID;
                    models.Add(model);
                }
            }

            return(models);
        }
Beispiel #8
0
 public List <Animation> GetPlayerAnimations(MobyModel ratchet)
 {
     return(GetPlayerAnimations(engineHead.playerAnimationPointer, ratchet));
 }