Alexandria.Engines.UltimaUnderworld.State.Get C# (CSharp) Méthode

Get() public static méthode

Get the state based on an Asset within the game.
public static Get ( Asset asset ) : State
asset Asset
Résultat State
        public static State Get(Asset asset)
        {
            AlexandriaManager manager = (AlexandriaManager)asset.Manager;
            FileManager fileManager = asset.LoadFileManager;
            string path = Path.GetDirectoryName(Path.GetDirectoryName(asset.PathName));
            Type gameType;

            if (fileManager.Exists(path + "/uw.exe"))
                gameType = typeof(GameUltimaUnderworld);
            else if (fileManager.Exists(path + "/uw2.exe"))
                gameType = typeof(GameUltimaUnderworld2);
            else if (fileManager.Exists(path + "/sshock.exe"))
                gameType = typeof(GameSystemShock);
            else
                throw new Exception(string.Format("No game executable could be found in '{0}'.", path));

            Game game = (Game)manager.GetGame(gameType);

            return (State)((AlexandriaManager)asset.Manager).GetPathState(game, fileManager, path);
        }

Usage Example

Exemple #1
0
        internal GraphicArchive(int paletteIndex, AssetLoader loader, int[] sizes = null)
            : base(loader)
        {
            State        state   = State.Get(this);
            PaletteAsset palette = state.GetPalette(paletteIndex);

            using (BinaryReader reader = loader.Reader) {
                byte forceSizeCode = reader.ReadByte();
                int  forceSize     = 0;

                if (forceSizeCode == 2)
                {
                    forceSize = reader.ReadByte();
                }
                else if (forceSizeCode != 1)
                {
                    throw new InvalidDataException();
                }

                int   count   = reader.ReadUInt16();
                int[] offsets = reader.ReadArrayInt32(count + 1);

                for (int index = 0; index < count; index++)
                {
                    int length = offsets[index + 1] - offsets[index];

                    reader.BaseStream.Position = offsets[index];

                    int width = -1, height = -1;

                    if (sizes != null && index * 2 < sizes.Length)
                    {
                        width  = sizes[index * 2 + 0];
                        height = sizes[index * 2 + 1];
                    }
                    else if (forceSize != 0)
                    {
                        width = height = forceSize;
                    }

                    new Graphic(this, loader, index, length, width, height, palette);
                }
            }
        }