예제 #1
0
 /// <summary>
 /// Reloads the shop tiers of all instance meta shop controllers
 /// </summary>
 public static void ReloadInstanceMetaShopTiers()
 {
     foreach (MetaShopController meta in UnityEngine.Object.FindObjectsOfType <MetaShopController>())
     {
         meta.metaShopTiers = SaveTools.CloneList(BaseMetaShopController.metaShopTiers);
     }
 }
예제 #2
0
 /// <summary>
 /// Adds hooks required for custom item blueprints to work and loads shops and shop item tables
 /// </summary>
 public static void DoSetup()
 {
     if (m_loaded)
     {
         return;
     }
     BaseMetaShopController        = SaveTools.LoadAssetFromAnywhere <GameObject>("Foyer_MetaShop").GetComponent <MetaShopController>();
     TrorcMetaShopItems            = SaveTools.LoadAssetFromAnywhere <GenericLootTable>("Shop_Truck_Meta");
     GooptonMetaShopItems          = SaveTools.LoadAssetFromAnywhere <GenericLootTable>("Shop_Goop_Meta");
     DougMetaShopItems             = SaveTools.LoadAssetFromAnywhere <GenericLootTable>("Shop_Beetle_Meta");
     pickupObjectEncounterableHook = new Hook(
         typeof(PickupObject).GetMethod("HandleEncounterable", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(BreachShopTool).GetMethod("HandleEncounterableHook")
         );
     baseShopSetupHook = new Hook(
         typeof(BaseShopController).GetMethod("DoSetup", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(BreachShopTool).GetMethod("BaseShopSetupHook")
         );
     metaShopSetupHook = new Hook(
         typeof(MetaShopController).GetMethod("DoSetup", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(BreachShopTool).GetMethod("MetaSetupHook")
         );
     metaShopCurrentTierHook = new Hook(
         typeof(MetaShopController).GetMethod("GetCurrentTier", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(BreachShopTool).GetMethod("MetaShopCurrentTierHook")
         );
     metaShopProximateTierHook = new Hook(
         typeof(MetaShopController).GetMethod("GetProximateTier", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(BreachShopTool).GetMethod("MetaShopProximateTierHook")
         );
     m_loaded = true;
 }
 public bool IsEnemyValid(AIActor enemy, MonsterHuntProgress progress)
 {
     if (this.ValidTargetCheck != null && !this.ValidTargetCheck(enemy, progress))
     {
         return(false);
     }
     return(SaveTools.IsEnemyStateValid(enemy, this.RequiredEnemyState));
 }
예제 #4
0
        /// <summary>
        /// Builds a new <see cref="MonsterHuntQuest"/> and adds it to the quest list
        /// </summary>
        /// <param name="questFlag">The flag that will be used to check if the quest is complete and will be set to true when the quest is completed</param>
        /// <param name="questIntroConversation">The list of text Frifle will say when giving the player the quest</param>
        /// <param name="targetEnemyName">The name that will be used when Frifle or Grey Mauser say how much enemies are remaining</param>
        /// <param name="targetEnemies">List of enemies that can progress the quest</param>
        /// <param name="numberKillsRequired">Amount of kills that are required for the quest to be completed</param>
        /// <param name="rewardFlags">Flags that will be set when the player talks to Frifle or the Grey Mauser after completing the quest</param>
        /// <param name="customRewardFlags">Custom flags that will be set when the player talks to Frifle or the Grey Mauser after completing the quest</param>
        /// <param name="requiredState">Enemy state that will be required for the quest to count the kill</param>
        /// <param name="validTargetCheck">Custom check function that will be used to check if a kill is valid</param>
        /// <param name="index">Index to add the quest at</param>
        /// <returns>The built quest</returns>
        public static MonsterHuntQuest AddQuest(GungeonFlags questFlag, List <string> questIntroConversation, string targetEnemyName, List <AIActor> targetEnemies, int numberKillsRequired, List <GungeonFlags> rewardFlags = null,
                                                List <CustomDungeonFlags> customRewardFlags = null, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func <AIActor, MonsterHuntProgress, bool> validTargetCheck = null, int?index = null)
        {
            string questStringPrefix      = "#CUSTOMQUEST_" + questFlag.ToString() + "_" + Guid.NewGuid().ToString().ToUpper();
            string questIntroString       = questStringPrefix + "_INTRO";
            string questTargetEnemyString = questStringPrefix + "_TARGET";

            ETGMod.Databases.Strings.Core.SetComplex(questIntroString, questIntroConversation.ToArray());
            ETGMod.Databases.Strings.Core.Set(questTargetEnemyString, targetEnemyName);
            return(AddQuest(new CustomHuntQuest()
            {
                QuestFlag = questFlag,
                QuestIntroString = questIntroString,
                TargetStringKey = questTargetEnemyString,
                ValidTargetMonsterGuids = targetEnemies.Convert(delegate(AIActor enemy) { return enemy.EnemyGuid; }),
                FlagsToSetUponReward = rewardFlags != null ? SaveTools.CloneList(rewardFlags) : new List <GungeonFlags>(),
                CustomFlagsToSetUponReward = customRewardFlags != null ? SaveTools.CloneList(customRewardFlags) : new List <CustomDungeonFlags>(),
                NumberKillsRequired = numberKillsRequired,
                RequiredEnemyState = requiredState,
                ValidTargetCheck = validTargetCheck,
                CustomQuestFlag = CustomDungeonFlags.NONE
            }, index));
        }
예제 #5
0
    /// <summary>
    /// read tools method. Returns true if successful, false otherwise
    /// </summary>
    public bool ReadToolsFromFile()
    {
        bool isSuccess = false;

        if (string.IsNullOrEmpty(filenameTools) == false)
        {
            if (File.Exists(filenameTools) == true)
            {
                //read data from File
                try { jsonRead = File.ReadAllText(filenameTools); }
                catch (Exception e) { Debug.LogErrorFormat("Failed to read TEXT FROM FILE, error \"{0}\"", e.Message); }
                isSuccess = true;
                if (isSuccess == true)
                {
                    //read to Save file
                    try
                    {
                        readToolsJSON = JsonUtility.FromJson <SaveTools>(jsonRead);
                        Debug.LogFormat("[Fil] FileManager.cs -> ReadToolsFromFile: GAME LOADED from \"{0}\"{1}", filenameTools, "\n");
                        return(true);
                    }
                    catch (Exception e)
                    { Debug.LogErrorFormat("Failed to read Json, error \"{0}\"", e.Message); }
                }
            }
            else
            {
                Debug.LogWarningFormat("File \"{0}\" not found", filenameTools);
            }
        }
        else
        {
            Debug.LogError("Invalid filename (Null or Empty)");
        }
        return(false);
    }
예제 #6
0
    // - - - JSON File

    #region Write Tool Data
    /// <summary>
    /// copy inGame data to saveData
    /// </summary>
    public void WriteToolData()
    {
        writeToolsJSON = new SaveTools();
        //Sequentially write data
        WriteStories();
    }
예제 #7
0
 /// <summary>
 /// Call this method in your <see cref="ETGModule.Init"/> method. Adds SaveAPI <see cref="Hook"/>s, loads <see cref="AdvancedGameStatsManager"/> and setups the custom <see cref="SaveManager.SaveType"/>s
 /// </summary>
 /// <param name="prefix">Mod prefix for SaveTypes</param>
 public static void Setup(string prefix)
 {
     if (m_loaded)
     {
         return;
     }
     AdvancedGameSave = new SaveManager.SaveType
     {
         filePattern       = "Slot{0}." + prefix + "Save",
         encrypted         = true,
         backupCount       = 3,
         backupPattern     = "Slot{0}." + prefix + "Backup.{1}",
         backupMinTimeMin  = 45,
         legacyFilePattern = prefix + "GameStatsSlot{0}.txt"
     };
     AdvancedMidGameSave = new SaveManager.SaveType
     {
         filePattern       = "Active{0}." + prefix + "Game",
         legacyFilePattern = prefix + "ActiveSlot{0}.txt",
         encrypted         = true,
         backupCount       = 0,
         backupPattern     = "Active{0}." + prefix + "Backup.{1}",
         backupMinTimeMin  = 60
     };
     for (int i = 0; i < 3; i++)
     {
         SaveManager.SaveSlot saveSlot = (SaveManager.SaveSlot)i;
         SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.legacyFilePattern, saveSlot)), Path.Combine(SaveManager.OldSavePath,
                                                                                                                                             string.Format(AdvancedGameSave.filePattern, saveSlot)), false);
         SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.filePattern, saveSlot)), Path.Combine(SaveManager.OldSavePath,
                                                                                                                                       string.Format(AdvancedGameSave.filePattern, saveSlot)), false);
         SaveTools.SafeMove(SaveTools.PathCombine(SaveManager.SavePath, "01", string.Format(AdvancedGameSave.filePattern, saveSlot)), Path.Combine(SaveManager.SavePath,
                                                                                                                                                   string.Format(AdvancedGameSave.filePattern, saveSlot)), true);
     }
     AdvancedGameStatsManager.Load();
     saveHook = new Hook(
         typeof(GameStatsManager).GetMethod("Save", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("SaveHook")
         );
     loadHook = new Hook(
         typeof(GameStatsManager).GetMethod("Load", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("LoadHook")
         );
     resetHook = new Hook(
         typeof(GameStatsManager).GetMethod("DANGEROUS_ResetAllStats", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("ResetHook")
         );
     beginSessionHook = new Hook(
         typeof(GameStatsManager).GetMethod("BeginNewSession", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("BeginSessionHook")
         );
     endSessionHook = new Hook(
         typeof(GameStatsManager).GetMethod("EndSession", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("EndSessionHook")
         );
     clearAllStatsHook = new Hook(
         typeof(GameStatsManager).GetMethod("ClearAllStatsGlobal", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("ClearAllStatsHook")
         );
     deleteMidGameSaveHook = new Hook(
         typeof(SaveManager).GetMethod("DeleteCurrentSlotMidGameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("DeleteMidGameSaveHook")
         );
     midgameSaveHook = new Hook(
         typeof(GameManager).GetMethod("DoMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("MidgameSaveHook")
         );
     invalidateSaveHook = new Hook(
         typeof(GameManager).GetMethod("InvalidateMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("InvalidateSaveHook")
         );
     revalidateSaveHook = new Hook(
         typeof(GameManager).GetMethod("RevalidateMidgameSave", BindingFlags.Public | BindingFlags.Static),
         typeof(DaveAPIManager).GetMethod("RevalidateSaveHook")
         );
     frameDelayedInitizlizationHook = new Hook(
         typeof(Dungeon).GetMethod("FrameDelayedMidgameInitialization", BindingFlags.NonPublic | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("FrameDelayedInitizlizationHook")
         );
     moveSessionStatsHook = new Hook(
         typeof(GameStatsManager).GetMethod("MoveSessionStatsToSavedSessionStats", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("MoveSessionStatsHook")
         );
     prerequisiteHook = new Hook(
         typeof(DungeonPrerequisite).GetMethod("CheckConditionsFulfilled", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("PrerequisiteHook")
         );
     clearActiveGameDataHook = new Hook(
         typeof(GameManager).GetMethod("ClearActiveGameData", BindingFlags.Public | BindingFlags.Instance),
         typeof(DaveAPIManager).GetMethod("ClearActiveGameDataHook")
         );
     BreachShopTool.DoSetup();
     m_loaded = true;
 }