コード例 #1
0
        /// <summary>
        /// Creates an instance of a stage from a provided directory containing stage files.
        /// </summary>
        /// <param name="stageDirectory">Contains the full path leading to individual stage content.</param>
        public Stage(string stageDirectory)
        {
            // Set the stage directory.
            _stageDirectory = stageDirectory;

            // Set the config for the stage.
            StageConfig = Config.ParseConfig(ConfigFilePath);

            // Get all splines.
            string[] splineFiles = Directory.GetFiles(SplineFolderPath, "*.obj");

            // Allocate unmanaged memory for splines
            int pointerSize     = sizeof(Spline *);
            int splineArraySize = pointerSize * (splineFiles.Length + 1);

            Splines = (Spline **)Marshal.AllocHGlobal(splineArraySize);

            // We allocate one more than required because the last one should be a null pointer.
            // The game uses a null pointer to determine end of array.

            // Populate Splines.
            for (int x = 0; x < splineFiles.Length; x++)
            {
                Splines[x] = Spline.MakeSpline(splineFiles[x]);
            }

            Splines[splineFiles.Length] = (Spline *)0;
            SplineCount = splineFiles.Length;
        }
コード例 #2
0
        /// <summary>
        /// <see cref="SonicHeroes.Utils.StageInjector.Hooks.Hooks.InitPath"/>
        /// </summary>
        private bool InitSplineImpl(Spline **splinePointerArray)
        {
            if (TryGetCurrentStage(out Stage stage))
            {
                if (stage.Splines != null)
                {
                    return(_hooks.InitPathHook.OriginalFunction(stage.Splines));
                }
            }

            return(_hooks.InitPathHook.OriginalFunction(splinePointerArray));
        }