예제 #1
0
            static uint CreateReferenceHelper(GenericRCOLResource rcol, IResourceKey rk)
            {
                int i = rcol.ChunkEntries.FindIndex(x => x.TGIBlock.Equals(rk));

                if (i < 0)
                {
                    i = rcol.Resources.FindIndex(x => x.Equals(rk));
                    return(i < 0 ? 0 : (uint)(i + 1) | 0x30000000);
                }
                else
                {
                    i++;
                    return(i < rcol.publicChunks ? (uint)i : (uint)i | 0x10000000);
                }
            }
예제 #2
0
            /// <summary>
            /// Return the RCOL block indexed by the given <see cref="ChunkReference"/>.
            /// </summary>
            /// <param name="rcol">The RCOL resource to inspect.</param>
            /// <param name="reference">The <see cref="ChunkReference"/> to look up.</param>
            /// <returns>The RCOL block indexed by the given <see cref="ChunkReference"/>.</returns>
            /// <exception cref="NotImplementedException">The <paramref name="reference"/> passed
            /// does not have a supported <see cref="ReferenceType"/> value.</exception>
            /// <remarks>Only <see cref="ReferenceType.Public"/> and <see cref="ReferenceType.Private"/>
            /// are &quot;sane&quot; types.</remarks>
            public static IRCOLBlock GetBlock(GenericRCOLResource rcol, ChunkReference reference)
            {
                if (reference.chunkReference == 0)
                {
                    return(null);
                }

                switch (reference.RefType)
                {
                case ReferenceType.Public:
                    return(rcol.ChunkEntries[reference.TGIBlockIndex].RCOLBlock);

                case ReferenceType.Private:
                    return(rcol.ChunkEntries[reference.TGIBlockIndex + rcol.PublicChunks].RCOLBlock);
                }
                throw new NotImplementedException(String.Format("Reference Type {0} is not supported.", reference.RefType));
            }
예제 #3
0
 /// <summary>
 /// Determine the <see cref="ChunkReference"/> value for the given <see cref="IResourceKey"/> value.
 /// </summary>
 /// <param name="rcol">The RCOL resource to inspect.</param>
 /// <param name="rk">The <see cref="IResourceKey"/> to encode.</param>
 /// <returns>The <see cref="ChunkReference"/> value for the given <see cref="IResourceKey"/> value.</returns>
 /// <remarks>Note that the value will be zero (i.e. indicating an invalid entry) if the <paramref name="rk"/>
 /// value supplied is not found either in the <see cref="GenericRCOLResource.ChunkEntries"/> or
 /// <see cref="GenericRCOLResource.Resources"/> lists.</remarks>
 public static ChunkReference CreateReference(GenericRCOLResource rcol, IResourceKey rk)
 {
     return(new ChunkReference(0, null, CreateReferenceHelper(rcol, rk)));
 }