Exemplo n.º 1
0
        public static void SetupUnlockOnFlag(this PickupObject self, GungeonFlags flag, bool requiredFlagValue) //thanks SpAPI
        {
            EncounterTrackable encounterTrackable = self.encounterTrackable;
            bool flag2 = encounterTrackable.prerequisites == null;

            if (flag2)
            {
                encounterTrackable.prerequisites    = new DungeonPrerequisite[1];
                encounterTrackable.prerequisites[0] = new DungeonPrerequisite
                {
                    prerequisiteType = DungeonPrerequisite.PrerequisiteType.FLAG,
                    requireFlag      = requiredFlagValue,
                    saveFlagToCheck  = flag
                };
            }
            else
            {
                encounterTrackable.prerequisites = encounterTrackable.prerequisites.Concat(new DungeonPrerequisite[]
                {
                    new DungeonPrerequisite
                    {
                        prerequisiteType = DungeonPrerequisite.PrerequisiteType.FLAG,
                        requireFlag      = requiredFlagValue,
                        saveFlagToCheck  = flag
                    }
                }).ToArray <DungeonPrerequisite>();
            }
            EncounterDatabaseEntry entry = EncounterDatabase.GetEntry(encounterTrackable.EncounterGuid);
            bool flag3 = !string.IsNullOrEmpty(entry.ProxyEncounterGuid);

            if (flag3)
            {
                entry.ProxyEncounterGuid = "";
            }
            bool flag4 = entry.prerequisites == null;

            if (flag4)
            {
                entry.prerequisites    = new DungeonPrerequisite[1];
                entry.prerequisites[0] = new DungeonPrerequisite
                {
                    prerequisiteType = DungeonPrerequisite.PrerequisiteType.FLAG,
                    requireFlag      = requiredFlagValue,
                    saveFlagToCheck  = flag
                };
            }
            else
            {
                entry.prerequisites = entry.prerequisites.Concat(new DungeonPrerequisite[]
                {
                    new DungeonPrerequisite
                    {
                        prerequisiteType = DungeonPrerequisite.PrerequisiteType.FLAG,
                        requireFlag      = requiredFlagValue,
                        saveFlagToCheck  = flag
                    }
                }).ToArray <DungeonPrerequisite>();
            }
        }
Exemplo n.º 2
0
        public static void Init()
        {
            string     itemName     = "Master Chamber";
            string     resourceName = "SpecialItemPack/Resources/MasterChamber";
            GameObject obj          = new GameObject(itemName);
            var        item         = obj.AddComponent <BasicStatPickup>();

            ItemBuilder.AddSpriteToObject(itemName, resourceName, obj);
            string shortDesc = "Red Chamber";
            string longDesc  = "This forgotten artifact indicates mastery of the red chamber.\n\nBecause of a paradox, this Master Round was turned into a chamber.";

            ItemBuilder.SetupItem(item, shortDesc, longDesc, "spapi");
            item.quality = PickupObject.ItemQuality.SPECIAL;
            ItemBuilder.AddPassiveStatModifier(item, PlayerStats.StatType.Health, 1f, StatModifier.ModifyMethod.ADDITIVE);
            EncounterDatabase.GetEntry(item.encounterTrackable.EncounterGuid).usesPurpleNotifications = true;
            item.IsMasteryToken = true;
            item.PlaceItemInAmmonomiconAfterItemById(467);
            item.AddItemToSynergy(CustomSynergyType.MASTERS_CHAMBERS);
            SpecialItemIds.MasterChamber = item.PickupObjectId;
        }
Exemplo n.º 3
0
 public static void RemovePeskyQuestionmark(this PickupObject item)
 {
     EncounterDatabase.GetEntry(item.encounterTrackable.EncounterGuid).journalData.SuppressKnownState = false;
 }
        public bool CheckConditionsFulfilledOrig()
        {
            EncounterDatabaseEntry encounterDatabaseEntry = null;

            if (!string.IsNullOrEmpty(this.encounteredObjectGuid))
            {
                encounterDatabaseEntry = EncounterDatabase.GetEntry(this.encounteredObjectGuid);
            }
            switch (this.prerequisiteType)
            {
            case DungeonPrerequisite.PrerequisiteType.ENCOUNTER:
                if (encounterDatabaseEntry == null && this.encounteredRoom == null)
                {
                    return(true);
                }
                if (encounterDatabaseEntry != null)
                {
                    int num = GameStatsManager.Instance.QueryEncounterable(encounterDatabaseEntry);
                    switch (this.prerequisiteOperation)
                    {
                    case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                        return(num < this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                        return(num == this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                        return(num > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                else if (this.encounteredRoom != null)
                {
                    int num2 = GameStatsManager.Instance.QueryRoomEncountered(this.encounteredRoom.GUID);
                    switch (this.prerequisiteOperation)
                    {
                    case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                        return(num2 < this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                        return(num2 == this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                        return(num2 > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                return(false);

            case DungeonPrerequisite.PrerequisiteType.COMPARISON:
            {
                float playerStatValue = GameStatsManager.Instance.GetPlayerStatValue(this.statToCheck);
                switch (this.prerequisiteOperation)
                {
                case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                    return(playerStatValue < this.comparisonValue);

                case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                    return(playerStatValue == this.comparisonValue);

                case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                    return(playerStatValue > this.comparisonValue);

                default:
                    Debug.LogError("Switching on invalid stat comparison operation!");
                    break;
                }
                break;
            }

            case DungeonPrerequisite.PrerequisiteType.CHARACTER:
            {
                PlayableCharacters playableCharacters = (PlayableCharacters)(-1);
                if (!BraveRandom.IgnoreGenerationDifferentiator)
                {
                    if (GameManager.Instance.PrimaryPlayer != null)
                    {
                        playableCharacters = GameManager.Instance.PrimaryPlayer.characterIdentity;
                    }
                    else if (GameManager.PlayerPrefabForNewGame != null)
                    {
                        playableCharacters = GameManager.PlayerPrefabForNewGame.GetComponent <PlayerController>().characterIdentity;
                    }
                    else if (GameManager.Instance.BestGenerationDungeonPrefab != null)
                    {
                        playableCharacters = GameManager.Instance.BestGenerationDungeonPrefab.defaultPlayerPrefab.GetComponent <PlayerController>().characterIdentity;
                    }
                }
                return(this.requireCharacter == (playableCharacters == this.requiredCharacter));
            }

            case DungeonPrerequisite.PrerequisiteType.TILESET:
                if (GameManager.Instance.BestGenerationDungeonPrefab != null)
                {
                    return(this.requireTileset == (GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId == this.requiredTileset));
                }
                return(this.requireTileset == (GameManager.Instance.Dungeon.tileIndices.tilesetId == this.requiredTileset));

            case DungeonPrerequisite.PrerequisiteType.FLAG:
                return(GameStatsManager.Instance.GetFlag(this.saveFlagToCheck) == this.requireFlag);

            case DungeonPrerequisite.PrerequisiteType.DEMO_MODE:
                return(!this.requireDemoMode);

            case DungeonPrerequisite.PrerequisiteType.MAXIMUM_COMPARISON:
            {
                float playerMaximum = GameStatsManager.Instance.GetPlayerMaximum(this.maxToCheck);
                switch (this.prerequisiteOperation)
                {
                case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                    return(playerMaximum < this.comparisonValue);

                case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                    return(playerMaximum == this.comparisonValue);

                case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                    return(playerMaximum > this.comparisonValue);

                default:
                    Debug.LogError("Switching on invalid stat comparison operation!");
                    break;
                }
                break;
            }

            case DungeonPrerequisite.PrerequisiteType.ENCOUNTER_OR_FLAG:
                if (GameStatsManager.Instance.GetFlag(this.saveFlagToCheck) == this.requireFlag)
                {
                    return(true);
                }
                if (encounterDatabaseEntry != null)
                {
                    int num3 = GameStatsManager.Instance.QueryEncounterable(encounterDatabaseEntry);
                    switch (this.prerequisiteOperation)
                    {
                    case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                        return(num3 < this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                        return(num3 == this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                        return(num3 > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                else if (this.encounteredRoom != null)
                {
                    int num4 = GameStatsManager.Instance.QueryRoomEncountered(this.encounteredRoom.GUID);
                    switch (this.prerequisiteOperation)
                    {
                    case DungeonPrerequisite.PrerequisiteOperation.LESS_THAN:
                        return(num4 < this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.EQUAL_TO:
                        return(num4 == this.requiredNumberOfEncounters);

                    case DungeonPrerequisite.PrerequisiteOperation.GREATER_THAN:
                        return(num4 > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                return(false);

            case DungeonPrerequisite.PrerequisiteType.NUMBER_PASTS_COMPLETED:
                return((float)GameStatsManager.Instance.GetNumberPastsBeaten() >= this.comparisonValue);

            default:
                Debug.LogError("Switching on invalid prerequisite type!!!");
                break;
            }
            return(false);
        }
        /// <summary>
        /// Overridable condition checker method
        /// </summary>
        /// <returns><see langword="true"/> if all conditions are fulfilled</returns>
        public virtual new bool CheckConditionsFulfilled()
        {
            if (this.advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_FLAG)
            {
                return(AdvancedGameStatsManager.Instance.GetFlag(this.customFlagToCheck) == this.requireCustomFlag);
            }
            else if (this.advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_STAT_COMPARISION)
            {
                float playerStatValue = AdvancedGameStatsManager.Instance.GetPlayerStatValue(this.customStatToCheck);
                switch (this.prerequisiteOperation)
                {
                case PrerequisiteOperation.LESS_THAN:
                    return(playerStatValue < this.comparisonValue);

                case PrerequisiteOperation.EQUAL_TO:
                    return(playerStatValue == this.comparisonValue);

                case PrerequisiteOperation.GREATER_THAN:
                    return(playerStatValue > this.comparisonValue);

                default:
                    Debug.LogError("Switching on invalid stat comparison operation!");
                    break;
                }
            }
            else if (this.advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_MAXIMUM_COMPARISON)
            {
                float playerMaximum = AdvancedGameStatsManager.Instance.GetPlayerMaximum(this.customMaximumToCheck);
                switch (this.prerequisiteOperation)
                {
                case PrerequisiteOperation.LESS_THAN:
                    return(playerMaximum < this.comparisonValue);

                case PrerequisiteOperation.EQUAL_TO:
                    return(playerMaximum == this.comparisonValue);

                case PrerequisiteOperation.GREATER_THAN:
                    return(playerMaximum > this.comparisonValue);

                default:
                    Debug.LogError("Switching on invalid stat comparison operation!");
                    break;
                }
            }
            else if (this.advancedPrerequisiteType == AdvancedPrerequisiteType.NUMBER_PASTS_COMPLETED_BETTER)
            {
                float pastsBeaten = GameStatsManager.Instance.GetNumberPastsBeaten();
                switch (this.prerequisiteOperation)
                {
                case PrerequisiteOperation.LESS_THAN:
                    return(pastsBeaten < this.comparisonValue);

                case PrerequisiteOperation.EQUAL_TO:
                    return(pastsBeaten == this.comparisonValue);

                case PrerequisiteOperation.GREATER_THAN:
                    return(pastsBeaten > this.comparisonValue);

                default:
                    Debug.LogError("Switching on invalid stat comparison operation!");
                    break;
                }
            }
            else if (this.advancedPrerequisiteType == AdvancedPrerequisiteType.ENCOUNTER_OR_CUSTOM_FLAG)
            {
                EncounterDatabaseEntry encounterDatabaseEntry = null;
                if (!string.IsNullOrEmpty(this.encounteredObjectGuid))
                {
                    encounterDatabaseEntry = EncounterDatabase.GetEntry(this.encounteredObjectGuid);
                }
                if (AdvancedGameStatsManager.Instance.GetFlag(this.customFlagToCheck) == this.requireCustomFlag)
                {
                    return(true);
                }
                if (encounterDatabaseEntry != null)
                {
                    int num3 = GameStatsManager.Instance.QueryEncounterable(encounterDatabaseEntry);
                    switch (this.prerequisiteOperation)
                    {
                    case PrerequisiteOperation.LESS_THAN:
                        return(num3 < this.requiredNumberOfEncounters);

                    case PrerequisiteOperation.EQUAL_TO:
                        return(num3 == this.requiredNumberOfEncounters);

                    case PrerequisiteOperation.GREATER_THAN:
                        return(num3 > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                else if (this.encounteredRoom != null)
                {
                    int num4 = GameStatsManager.Instance.QueryRoomEncountered(this.encounteredRoom.GUID);
                    switch (this.prerequisiteOperation)
                    {
                    case PrerequisiteOperation.LESS_THAN:
                        return(num4 < this.requiredNumberOfEncounters);

                    case PrerequisiteOperation.EQUAL_TO:
                        return(num4 == this.requiredNumberOfEncounters);

                    case PrerequisiteOperation.GREATER_THAN:
                        return(num4 > this.requiredNumberOfEncounters);

                    default:
                        Debug.LogError("Switching on invalid stat comparison operation!");
                        break;
                    }
                }
                return(false);
            }
            else
            {
                return(this.CheckConditionsFulfilledOrig());
            }
            return(false);
        }
Exemplo n.º 6
0
        public static void SetupUnlockOnStat(this PickupObject self, TrackedStats stat, DungeonPrerequisite.PrerequisiteOperation operation, int comparisonValue)
        {
            EncounterTrackable encounterTrackable = self.encounterTrackable;
            bool flag = encounterTrackable.prerequisites == null;

            if (flag)
            {
                encounterTrackable.prerequisites    = new DungeonPrerequisite[1];
                encounterTrackable.prerequisites[0] = new DungeonPrerequisite
                {
                    prerequisiteType      = DungeonPrerequisite.PrerequisiteType.COMPARISON,
                    prerequisiteOperation = operation,
                    statToCheck           = stat,
                    comparisonValue       = (float)comparisonValue
                };
            }
            else
            {
                encounterTrackable.prerequisites = encounterTrackable.prerequisites.Concat(new DungeonPrerequisite[]
                {
                    new DungeonPrerequisite
                    {
                        prerequisiteType      = DungeonPrerequisite.PrerequisiteType.COMPARISON,
                        prerequisiteOperation = operation,
                        statToCheck           = stat,
                        comparisonValue       = (float)comparisonValue
                    }
                }).ToArray <DungeonPrerequisite>();
            }
            EncounterDatabaseEntry entry = EncounterDatabase.GetEntry(encounterTrackable.EncounterGuid);
            bool flag2 = !string.IsNullOrEmpty(entry.ProxyEncounterGuid);

            if (flag2)
            {
                entry.ProxyEncounterGuid = "";
            }
            bool flag3 = entry.prerequisites == null;

            if (flag3)
            {
                entry.prerequisites    = new DungeonPrerequisite[1];
                entry.prerequisites[0] = new DungeonPrerequisite
                {
                    prerequisiteType      = DungeonPrerequisite.PrerequisiteType.COMPARISON,
                    prerequisiteOperation = operation,
                    statToCheck           = stat,
                    comparisonValue       = (float)comparisonValue
                };
            }
            else
            {
                entry.prerequisites = entry.prerequisites.Concat(new DungeonPrerequisite[]
                {
                    new DungeonPrerequisite
                    {
                        prerequisiteType      = DungeonPrerequisite.PrerequisiteType.COMPARISON,
                        prerequisiteOperation = operation,
                        statToCheck           = stat,
                        comparisonValue       = (float)comparisonValue
                    }
                }).ToArray <DungeonPrerequisite>();
            }
        }