Пример #1
0
        private static MultiplayerUnlocks.LevelUnlockID MultiplayerUnlocks_LevelLockID(On.MultiplayerUnlocks.orig_LevelLockID orig, string levelName)
        {
            if (CustomWorldMod.levelUnlocks.ContainsKey(levelName))
            {
                MultiplayerUnlocks.LevelUnlockID unlockID = (MultiplayerUnlocks.LevelUnlockID)(-1);
                try
                {
                    unlockID = (MultiplayerUnlocks.LevelUnlockID)
                               Enum.Parse(typeof(MultiplayerUnlocks.LevelUnlockID), CustomWorldMod.levelUnlocks[levelName]);
                    CustomWorldMod.Log($"Unlocked custom arena [{levelName}] [{unlockID}]");
                } catch (Exception e)
                {
                    CustomWorldMod.Log($"Error parsing levelUnlockID enum [{levelName}] - [{e}]", true);
                }
                if (unlockID >= 0)
                {
                    return(unlockID);
                }
            }

            return(orig(levelName));
        }
 public void ctor(PlayerProgression progression, List <string> allLevels)
 {
     this.progression      = progression;
     this.unlockAll        = MultiplayerUnlocks.CheckUnlockAll();
     this.unlockNoSpoilers = MultiplayerUnlocks.CheckUnlockNoSpoilers();
     Debug.Log(string.Concat(new object[]
     {
         "unlockAll: ",
         this.unlockAll,
         " , unlockNoSpoilers: ",
         this.unlockNoSpoilers
     }));
     this.creaturesUnlockedForLevelSpawn = new bool[Enum.GetNames(typeof(CreatureTemplate.Type)).Length];
     this.unlockedBatches = new List <MultiplayerUnlocks.Unlock>();
     if (this.unlockNoSpoilers && !this.unlockAll)
     {
         this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock(MultiplayerUnlocks.LevelUnlockID.Default));
         this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock(MultiplayerUnlocks.LevelUnlockID.SU));
         this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock(MultiplayerUnlocks.LevelUnlockID.HI));
         this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock(MultiplayerUnlocks.LevelUnlockID.CC));
         this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock(MultiplayerUnlocks.LevelUnlockID.DS));
     }
     else
     {
         int num = Enum.GetNames(typeof(MultiplayerUnlocks.LevelUnlockID)).Length;
         for (int i = 2; i < num; i++)
         {
             if (this.unlockAll || progression.miscProgressionData.GetTokenCollected((MultiplayerUnlocks.LevelUnlockID)i))
             {
                 this.unlockedBatches.Add(new MultiplayerUnlocks.Unlock((MultiplayerUnlocks.LevelUnlockID)i));
             }
         }
     }
     for (int j = 0; j < this.unlockedBatches.Count; j++)
     {
         for (int k = 0; k < this.unlockedBatches[j].creatures.Count; k++)
         {
             this.creaturesUnlockedForLevelSpawn[(int)this.unlockedBatches[j].creatures[k]] = true;
         }
     }
     //Replaced Code
     foreach (MultiplayerUnlocks.SandboxUnlockID creature in patch_MultiplayerUnlocks.CreatureUnlockList)
     {
         if (this.SandboxItemUnlocked(creature))
         {
             this.creaturesUnlockedForLevelSpawn[(int)MultiplayerUnlocks.SymbolDataForSandboxUnlock(creature).critType] = true;
         }
     }
     //-=-=-=-=-=-=-=-=-=-
     for (int m = 0; m < allLevels.Count; m++)
     {
         MultiplayerUnlocks.LevelUnlockID levelUnlockID = MultiplayerUnlocks.LevelLockID(allLevels[m]);
         for (int n = 0; n < this.unlockedBatches.Count; n++)
         {
             if (this.unlockedBatches[n].ID == levelUnlockID)
             {
                 this.unlockedBatches[n].levels.Add(allLevels[m]);
                 break;
             }
         }
     }
 }