Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="physicsTable"></param>
        private static void _ResetCamIK(string vehicle, DB physicsTable)
        {
            VehicleSlotsHelper.VehicleInfo vi = VehicleSlotsHelper.VehicleInformation[vehicle];

            VehicleSlotsHelper.ChangeCameraById(vehicle, vi.defaultCamera, physicsTable);
            VehicleSlotsHelper.ChangeIKById(vehicle, vi.defaultIK, physicsTable);
        }
Exemplo n.º 2
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Parameters
            string vehicleName = _GetParameter(PatchInstructionParameter.ParameterName.slotFullName);
            string ikId        = _GetParameter(PatchInstructionParameter.ParameterName.cameraIKIdentifier);

            // Loading reference
            VehicleSlotsHelper.InitReference(PatchHelper.CurrentPath);

            // Checking validity
            if (!VehicleSlotsHelper.SlotReference.ContainsKey(vehicleName))
            {
                throw new Exception("Specified vehicle name is not supported: " + vehicleName);
            }

            if (!VehicleSlotsHelper.CamReference.ContainsKey(ikId))
            {
                throw new Exception("Specified IK identifier is not supported: " + ikId);
            }

            // Edit task
            EditHelper.Task task = new EditHelper.Task();

            try
            {
                try
                {
                    string bnkFileName = string.Concat(Tools.TduPath, LibraryConstants.FOLDER_DB, DB.GetBNKFileName(DB.Culture.Global));
                    BNK    dbBnkFile   = TduFile.GetFile(bnkFileName) as BNK;

                    if (dbBnkFile != null)
                    {
                        string dbFilePath =
                            dbBnkFile.GetPackedFilesPaths(DB.GetFileName(DB.Culture.Global, DB.Topic.CarPhysicsData))[0];

                        task =
                            EditHelper.Instance.AddTask(dbBnkFile, dbFilePath, true);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to get TDU database contents in DB.BNK.", ex);
                }

                // Opens packed file
                DB physicsDB = TduFile.GetFile(task.extractedFile) as DB;

                if (physicsDB == null)
                {
                    throw new Exception("Unable to get CarPhysicsData information.");
                }

                // Changes IK
                try
                {
                    string vehicleRef = VehicleSlotsHelper.SlotReference[vehicleName];

                    VehicleSlotsHelper.ChangeIKById(vehicleRef, ikId, physicsDB);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to use new IK set: " + ikId + " for " + vehicleName, ex);
                }

                // Saving
                try
                {
                    physicsDB.Save();
                    EditHelper.Instance.ApplyChanges(task);
                    EditHelper.Instance.RemoveTask(task);
                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to save and replace file in BNK.", ex);
                }
            }
            finally
            {
                EditHelper.Instance.RemoveTask(task);
            }
        }