NScumm.Sword1.ResMan.ResFile C# (CSharp) Метод

ResFile() приватный Метод

private ResFile ( uint id ) : Stream
id uint
Результат Stream
        private Stream ResFile(uint id)
        {
            Clu cluster = _prj.clu[((id >> 24) - 1)];
            if (cluster.file == null)
            {
                _openClus++;
                if (_openCluEnd == null)
                {
                    _openCluStart = _openCluEnd = cluster;
                }
                else
                {
                    _openCluEnd.nextOpen = cluster;
                    _openCluEnd = cluster;
                }
                string fileName;
                // Supposes that big endian means mac cluster file and little endian means PC cluster file.
                // This works, but we may want to separate the file name from the endianess or try .CLM extension if opening.clu file fail.
                if (_isBigEndian)
                    fileName = $"{_prj.clu[(id >> 24) - 1].label.Trim('\0')}.CLM";
                else
                    fileName = $"{_prj.clu[(id >> 24) - 1].label.Trim('\0')}.CLU";
                var path = ScummHelper.LocatePath(_directory, fileName);
                cluster.file = ServiceLocator.FileStorage.OpenFileRead(path);

                while (_openClus > MAX_OPEN_CLUS)
                {
                    Debug.Assert(_openCluStart != null);
                    Clu closeClu = _openCluStart;
                    _openCluStart = _openCluStart.nextOpen;

                    if (closeClu != null)
                    {
                        closeClu.file?.Dispose();
                        closeClu.file = null;
                        closeClu.nextOpen = null;
                    }
                    _openClus--;
                }
            }
            return cluster.file;
        }