Ejemplo n.º 1
0
        public static int TryToGetStateID(TRVersion.Game version, uint objectId, string stateName)
        {
            Game      game;
            ItemState entry = new ItemState();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.States.FirstOrDefault(item => item.Item == objectId && item.Name.ToLower().Contains(stateName.ToLower()));
            }

            if (entry.Name == null)
            {
                foreach (var otherGame in Games.Where(g => g.Key != version.Native()))
                {
                    entry = otherGame.Value.States.FirstOrDefault(item => item.Item == objectId && item.Name.ToLower().Contains(stateName.ToLower()));
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return(-1);
            }
            else
            {
                return((int)entry.State);
            }
        }
Ejemplo n.º 2
0
 public ItemType(WadMoveableId moveableId, TRVersion.Game gameVersion = TRVersion.Game.TR4)
 {
     IsStatic     = false;
     MoveableId   = moveableId;
     _gameVersion = gameVersion.Native();
     StaticId     = new WadStaticId();
 }
Ejemplo n.º 3
0
        public Prj2SoundsConversionDialog(TRVersion.Game version, List <FileFormatConversions.SoundInfoConversionRow> conversionRows)
        {
            _version        = version.Native();
            _conversionRows = conversionRows;

            InitializeComponent();
        }
Ejemplo n.º 4
0
 public ItemType(WadStaticId staticId, TRVersion.Game gameVersion = TRVersion.Game.TR4)
 {
     IsStatic     = true;
     MoveableId   = new WadMoveableId();
     _gameVersion = gameVersion.Native();
     StaticId     = staticId;
 }
Ejemplo n.º 5
0
        public static uint?GetItemIndex(TRVersion.Game version, string name, out bool isMoveable)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                isMoveable = false;
                return(null);
            }

            var entry = game.Moveables.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));

            if (entry.Value.Names != null)
            {
                isMoveable = true;
                return(entry.Key);
            }

            entry = game.Statics.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));
            if (entry.Value.Names != null)
            {
                isMoveable = false;
                return(entry.Key);
            }

            entry = game.SpriteSequences.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));
            if (entry.Value.Names != null)
            {
                isMoveable = false;
                return(entry.Key);
            }

            isMoveable = false;
            return(null);
        }
Ejemplo n.º 6
0
        public static int TryGetSoundInfoIdByDescription(TRVersion.Game version, string name)
        {
            var sounds = Games[version.Native()].Sounds;

            foreach (var pair in sounds)
            {
                if (pair.Value.Description.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return((int)pair.Key);
                }
            }
            return(-1);
        }
Ejemplo n.º 7
0
        public static string GetStateName(TRVersion.Game version, uint objectId, uint stateId)
        {
            Game      game;
            ItemState entry = new ItemState();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.States.FirstOrDefault(item => item.Item == objectId && item.State == stateId);
            }

            if (entry.Name == null)
            {
                var otherGames = Games.Where(g => g.Key != version.Native()).ToList();
                otherGames.Reverse();

                foreach (var otherGame in otherGames)
                {
                    entry = otherGame.Value.States.FirstOrDefault(item => item.Item == objectId && item.State == stateId);
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return("Unknown state " + stateId);
            }
            else
            {
                return(entry.Name);
            }
        }
Ejemplo n.º 8
0
        public static string GetAnimationName(TRVersion.Game version, uint objectId, uint animId)
        {
            Game          game;
            ItemAnimation entry = new ItemAnimation();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.Animations.FirstOrDefault(item => item.Item == objectId && item.Animation == animId);
            }

            if (entry.Name == null)
            {
                var otherGames = Games.Where(g => g.Key != version.Native()).ToList();
                otherGames.Reverse();

                foreach (var otherGame in otherGames)
                {
                    entry = otherGame.Value.Animations.FirstOrDefault(item => item.Item == objectId && item.Animation == animId);
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return("Animation " + animId);
            }
            else
            {
                return(entry.Name);
            }
        }
Ejemplo n.º 9
0
        public static string GetSpriteSequenceTR5MainSlot(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("");
            }
            Item entry;

            if (!game.SpriteSequences.TryGetValue(id, out entry))
            {
                return("");
            }
            return(game.SpriteSequences[id].TR5MainSlot);
        }
Ejemplo n.º 10
0
        public static bool IsSoundFixedByDefault(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            ItemSound entry;

            if (!game.Sounds.TryGetValue(id, out entry))
            {
                return(false);
            }
            return(game.Sounds[id].FixedByDefault);
        }
Ejemplo n.º 11
0
        public static string GetSpriteSequenceName(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("Unknown #" + id);
            }
            Item entry;

            if (!game.SpriteSequences.TryGetValue(id, out entry))
            {
                return("Unknown #" + id);
            }
            return(game.SpriteSequences[id].Names.LastOrDefault());
        }
Ejemplo n.º 12
0
        public static string GetOriginalSoundName(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("UNKNOWN_SOUND_" + id);
            }
            ItemSound entry;

            if (!game.Sounds.TryGetValue(id, out entry))
            {
                return("UNKNOWN_SOUND_" + id);
            }
            return(game.Sounds[id].Name);
        }
Ejemplo n.º 13
0
        public static uint GetMoveableSkin(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(id);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(id);
            }
            return(game.Moveables[id].SkinId);
        }
Ejemplo n.º 14
0
        public static bool IsStaticShatterable(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            Item entry;

            if (!game.Statics.TryGetValue(id, out entry))
            {
                return(false);
            }

            return(entry.Shatterable);
        }
Ejemplo n.º 15
0
        public static bool IsMoveableAI(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(false);
            }

            return(entry.AIObject);
        }
Ejemplo n.º 16
0
        public static uint GetSubstituteID(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(id);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(id);
            }
            if (game.Moveables[id].SubstituteId == -1)
            {
                return(id);
            }
            return((uint)game.Moveables[id].SubstituteId);
        }
Ejemplo n.º 17
0
        public static int PredictSoundMapSize(TRVersion.Game version, bool IsNg, int numDemoData)
        {
            switch (version.Native())
            {
            case TRVersion.Game.TR1:
                return(256);

            case TRVersion.Game.TR2:
            case TRVersion.Game.TR3:
                return(370);

            case TRVersion.Game.TR4:
                return(IsNg && numDemoData != 0 ? numDemoData : 370);

            case TRVersion.Game.TR5:
            case TRVersion.Game.TR5Main:
                return(450);

            default:
                throw new ArgumentOutOfRangeException("Unknown game version.");
            }
        }
Ejemplo n.º 18
0
 public string ToString(TRVersion.Game gameVersion) => Id.ToString(gameVersion.Native());
Ejemplo n.º 19
0
 public bool IsOptics(TRVersion.Game gameVersion)
 {
     return((gameVersion.Native() == TRVersion.Game.TR4 && TypeId >= 461 && TypeId <= 462) ||
            (gameVersion.Native() >= TRVersion.Game.TR5 && TypeId >= 456 && TypeId <= 457));
 }
Ejemplo n.º 20
0
 public bool IsWaterfall(TRVersion.Game gameVersion)
 {
     return((gameVersion.Native() == TRVersion.Game.TR4 && TypeId >= 423 && TypeId <= 425) ||
            (gameVersion.Native() >= TRVersion.Game.TR5 && TypeId >= 410 && TypeId <= 415));
 }
Ejemplo n.º 21
0
 public static IDictionary <uint, string> GetAllSpriteSequences(TRVersion.Game version)
 {
     return(Games[version.Native()].SpriteSequences.DicSelect(item => item.Value.Names.LastOrDefault()));
 }
Ejemplo n.º 22
0
 public static IDictionary <uint, string> GetAllSounds(TRVersion.Game version)
 {
     return(Games[version.Native()].Sounds.DicSelect(item => item.Value.Name));
 }
Ejemplo n.º 23
0
 public static IDictionary <uint, string> GetAllFixedByDefaultSounds(TRVersion.Game version)
 {
     return(Games[version.Native()].Sounds
            .DicWhere(sound => sound.Value.FixedByDefault)
            .DicSelect(item => item.Value.Name));
 }