Пример #1
0
        private void RandomizeEnemiesNatively(TR2CombinedLevel level)
        {
            // For the assault course, nothing will be changed for the time being
            if (level.IsAssault)
            {
                return;
            }

            List <TR2Entities> availableEnemyTypes = TR2EntityUtilities.GetEnemyTypeDictionary()[level.Name];
            List <TR2Entities> droppableEnemies    = TR2EntityUtilities.DroppableEnemyTypes()[level.Name];
            List <TR2Entities> waterEnemies        = TR2EntityUtilities.FilterWaterEnemies(availableEnemyTypes);

            if (DocileBirdMonsters && level.Is(LevelNames.CHICKEN))
            {
                DisguiseEntity(level, TR2Entities.MaskedGoon1, TR2Entities.BirdMonster);
            }

            RandomizeEnemies(level, new EnemyRandomizationCollection
            {
                Available         = availableEnemyTypes,
                Droppable         = droppableEnemies,
                Water             = waterEnemies,
                BirdMonsterGuiser = TR2Entities.MaskedGoon1 // If randomizing natively, this will only apply to Ice Palace
            });
        }
Пример #2
0
            // This is triggered synchronously after the import work to ensure the RNG remains consistent
            internal void ApplyRandomization()
            {
                foreach (TR2CombinedLevel level in _enemyMapping.Keys)
                {
                    if (!level.IsAssault)
                    {
                        EnemyTransportCollection importedCollection = null;
                        foreach (EnemyTransportCollection enemies in _enemyMapping[level])
                        {
                            if (enemies.ImportResult)
                            {
                                importedCollection = enemies;
                                break;
                            }
                        }

                        if (importedCollection == null)
                        {
                            // Cross-level was not possible with the enemy combinations. This could be due to either
                            // a lack of space for texture packing, or the max ObjectTexture count (2048) was reached.
                            _outer.TextureMonitor.RemoveMonitor(level.Name);

                            // And just randomize normally
                            // TODO: maybe trigger a warning to display at the end of randomizing to say that cross-
                            // level was not possible?
                            _outer.RandomizeEnemiesNatively(level);
                            //System.Diagnostics.Debug.WriteLine(level.Name + ": Native enemies");
                        }
                        else
                        {
                            // The import worked, so randomize the entities based on what we now have in place.
                            //System.Diagnostics.Debug.WriteLine(level.Name + ": " + string.Join(", ", importedCollection.EntitiesToImport));
                            EnemyRandomizationCollection enemies = new EnemyRandomizationCollection
                            {
                                Available = importedCollection.EntitiesToImport,
                                Droppable = TR2EntityUtilities.FilterDroppableEnemies(importedCollection.EntitiesToImport, !_outer.ProtectMonks),
                                Water     = TR2EntityUtilities.FilterWaterEnemies(importedCollection.EntitiesToImport)
                            };

                            if (_outer.DocileBirdMonsters && importedCollection.BirdMonsterGuiser != TR2Entities.BirdMonster)
                            {
                                _outer.DisguiseEntity(level, importedCollection.BirdMonsterGuiser, TR2Entities.BirdMonster);
                                enemies.BirdMonsterGuiser = importedCollection.BirdMonsterGuiser;
                            }

                            _outer.RandomizeEnemies(level, enemies);
                        }

                        _outer.SaveLevel(level);
                    }

                    if (!_outer.TriggerProgress())
                    {
                        break;
                    }
                }
            }