Beispiel #1
0
        public SosigEnemyTemplate GetSosigEnemyTemplate()
        {
            if (template == null)
            {
                TNHTweakerLogger.Log("TNHTweaker -- Getting sosig template", TNHTweakerLogger.LogType.Character);

                template = (SosigEnemyTemplate)ScriptableObject.CreateInstance(typeof(SosigEnemyTemplate));

                template.DisplayName        = DisplayName;
                template.SosigEnemyCategory = SosigEnemyCategory;
                template.SecondaryChance    = SecondaryChance;
                template.TertiaryChance     = TertiaryChance;

                TNHTweakerLogger.Log("TNHTweaker -- Getting sosig config", TNHTweakerLogger.LogType.Character);
                template.ConfigTemplates = new List <SosigConfigTemplate>();
                foreach (SosigConfig temp in Configs)
                {
                    if (temp == null)
                    {
                        TNHTweakerLogger.LogError("One of the sosig configs is null!");
                        continue;
                    }

                    template.ConfigTemplates.Add(temp.GetConfigTemplate());
                }

                template.ConfigTemplates_Easy = ConfigsEasy.Select(o => o.GetConfigTemplate()).ToList();
                template.OutfitConfig         = OutfitConfigs.Select(o => o.GetOutfitConfig()).ToList();
            }

            return(template);
        }
Beispiel #2
0
        public void PurchaseAmmoButton()
        {
            if (detectedFirearm == null || original.M.GetNumTokens() < PanelCost)
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position);
                return;
            }

            else
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position);
                original.M.SubtractTokens(PanelCost);
                original.M.Increment(10, false);

                FVRObject.OTagFirearmRoundPower roundPower = AM.GetRoundPower(detectedFirearm.RoundType);
                int numSpawned = GetRoundsToSpawn(roundPower);

                TNHTweakerLogger.Log("Compatible rounds count for " + detectedFirearm.ObjectWrapper.ItemID + ": " + IM.OD[detectedFirearm.ObjectWrapper.ItemID].CompatibleSingleRounds.Count, TNHTweakerLogger.LogType.General);

                CustomCharacter        character      = LoadedTemplateManager.LoadedCharactersDict[original.M.C];
                MagazineBlacklistEntry blacklistEntry = null;
                if (character.GetMagazineBlacklist().ContainsKey(detectedFirearm.ObjectWrapper.ItemID))
                {
                    blacklistEntry = character.GetMagazineBlacklist()[detectedFirearm.ObjectWrapper.ItemID];
                }

                FVRObject compatibleRound = FirearmUtils.GetCompatibleRounds(detectedFirearm.ObjectWrapper, character.ValidAmmoEras, character.ValidAmmoSets, character.GlobalAmmoBlacklist, blacklistEntry).GetRandom();

                AnvilManager.Run(SpawnRounds(compatibleRound, numSpawned));

                detectedFirearm = null;
                UpdateIcons();
            }
        }
Beispiel #3
0
        public void DelayedInit()
        {
            if (template != null)
            {
                TNHTweakerLogger.Log("TNHTweaker -- Delayed init of sosig: " + DisplayName, TNHTweakerLogger.LogType.Character);

                TNHTweakerUtils.RemoveUnloadedObjectIDs(this);

                template.SosigPrefabs            = SosigPrefabs.Select(o => IM.OD[o]).ToList();
                template.WeaponOptions           = WeaponOptions.Select(o => IM.OD[o]).ToList();
                template.WeaponOptions_Secondary = WeaponOptionsSecondary.Select(o => IM.OD[o]).ToList();
                template.WeaponOptions_Tertiary  = WeaponOptionsTertiary.Select(o => IM.OD[o]).ToList();

                foreach (OutfitConfig outfit in OutfitConfigs)
                {
                    outfit.DelayedInit();
                }

                if (DroppedObjectPool != null)
                {
                    DroppedObjectPool.DelayedInit();
                }

                //Add the new sosig template to the global dictionaries
                ManagerSingleton <IM> .Instance.odicSosigObjsByID.Add(template.SosigEnemyID, template);

                ManagerSingleton <IM> .Instance.odicSosigIDsByCategory[template.SosigEnemyCategory].Add(template.SosigEnemyID);
                ManagerSingleton <IM> .Instance.odicSosigObjsByCategory[template.SosigEnemyCategory].Add(template);
            }
        }
Beispiel #4
0
        public static bool TrackHoldStart(TNH_HoldPoint __instance)
        {
            TNHTweakerLogger.Log("Hold Start", TNHTweakerLogger.LogType.TNH);
            TNHTweaker.HoldActions[__instance.M.m_level].Add($"Entered Hold {__instance.M.HoldPoints.IndexOf(__instance)}");

            return(true);
        }
        public static bool AddPointDebugText(TNH_Manager __instance)
        {
            foreach (TNH_HoldPoint hold in __instance.HoldPoints)
            {
                TNHTweakerLogger.Log("Adding text!", TNHTweakerLogger.LogType.TNH);

                GameObject canvas = new GameObject("Canvas");
                canvas.transform.rotation = Quaternion.LookRotation(Vector3.right);
                canvas.transform.position = hold.SpawnPoint_SystemNode.position + Vector3.up * 0.2f;

                Canvas        canvasComp = canvas.AddComponent <Canvas>();
                RectTransform rect       = canvasComp.GetComponent <RectTransform>();
                canvasComp.renderMode = RenderMode.WorldSpace;
                rect.sizeDelta        = new Vector2(1, 1);

                GameObject text = new GameObject("Text");
                text.transform.SetParent(canvas.transform);
                text.transform.rotation      = canvas.transform.rotation;
                text.transform.localPosition = Vector3.zero;

                text.AddComponent <CanvasRenderer>();
                Text textComp  = text.AddComponent <Text>();
                Font ArialFont = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");

                textComp.text               = "Hold " + __instance.HoldPoints.IndexOf(hold);
                textComp.alignment          = TextAnchor.MiddleCenter;
                textComp.fontSize           = 32;
                text.transform.localScale   = new Vector3(0.0015f, 0.0015f, 0.0015f);
                textComp.font               = ArialFont;
                textComp.horizontalOverflow = HorizontalWrapMode.Overflow;
            }

            return(true);
        }
Beispiel #6
0
        public static bool TrackVictory(TNH_Manager __instance)
        {
            TNHTweakerLogger.Log("Victory", TNHTweakerLogger.LogType.TNH);
            TNHTweaker.HoldActions.Last().Add("Victory");

            return(true);
        }
Beispiel #7
0
        public static bool TrackNextLevel(TNH_Manager __instance)
        {
            TNHTweakerLogger.Log("Set Level", TNHTweakerLogger.LogType.TNH);
            TNHTweaker.HoldActions.Add(new List <string>());

            return(true);
        }
        /// <summary>
        /// Performs a delayed init on the sent list of sosigs. If a sosig fails to init, any character using that sosig will be removed
        /// </summary>
        /// <param name="sosigs"></param>
        private static void InitSosigs(List <SosigTemplate> sosigs)
        {
            for (int i = 0; i < sosigs.Count; i++)
            {
                SosigTemplate sosig = sosigs[i];

                try
                {
                    sosig.DelayedInit();
                }
                catch (Exception e)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load sosig: " + sosig.DisplayName + ". Error Output:\n" + e.ToString());

                    //Find any characters that use this sosig, and remove them
                    for (int j = 0; j < LoadedTemplateManager.LoadedCharactersDict.Values.Count; j++)
                    {
                        //This is probably monsterously inefficient, but if you're at this point you're already f****d :)
                        KeyValuePair <TNH_CharacterDef, CustomCharacter> value_pair = LoadedTemplateManager.LoadedCharactersDict.ToList()[j];

                        if (value_pair.Value.CharacterUsesSosig(sosig.SosigEnemyID))
                        {
                            TNHTweakerLogger.LogError("TNHTweaker -- Removing character that used removed sosig: " + value_pair.Value.DisplayName);
                            LoadedTemplateManager.LoadedCharactersDict.Remove(value_pair.Key);
                            j -= 1;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Takes a custom SosigTemplate object, and adds it to the necessary dictionaries. This method assumes that you are sending a template for a custom sosig, and that it should be given a new the SosigEnemyID
        /// </summary>
        /// <param name="template">A template for a custom sosig (Loaded at runtime)</param>
        public static void AddSosigTemplate(SosigTemplate template)
        {
            SosigEnemyTemplate realTemplate = template.GetSosigEnemyTemplate();

            //Since this template is for a custom sosig, we should give it a brand new SosigEnemyID
            if (!SosigIDDict.ContainsKey(template.SosigEnemyID))
            {
                SosigIDDict.Add(template.SosigEnemyID, NewSosigID);
                NewSosigID += 1;
            }
            else
            {
                TNHTweakerLogger.LogError("TNHTweaker -- Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + template.SosigEnemyID);
                return;
            }

            //Now fill out the SosigEnemyIDs values for the real sosig template (These will effectively be ints, but this is ok since enums are just ints in disguise)
            realTemplate.SosigEnemyID = (SosigEnemyID)SosigIDDict[template.SosigEnemyID];

            //Finally add the templates to our global dictionary
            CustomSosigs.Add(template);
            LoadedSosigsDict.Add(realTemplate, template);

            TNHTweakerLogger.Log("TNHTweaker -- Sosig added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character);
        }
        public static bool GenerateSentryPatrolPatch(
            List <Vector3> SpawnPoints,
            List <Vector3> ForwardVectors,
            List <Vector3> PatrolPoints,
            TNH_Manager __instance,
            List <TNH_Manager.SosigPatrolSquad> ___m_patrolSquads,
            ref float ___m_timeTilPatrolCanSpawn,
            ref TNH_Manager.SosigPatrolSquad __result
            )
        {
            TNHTweakerLogger.Log("TNHTWEAKER -- Generating a sentry patrol -- There are currently " + ___m_patrolSquads.Count + " patrols active", TNHTweakerLogger.LogType.TNH);

            CustomCharacter character = LoadedTemplateManager.LoadedCharactersDict[__instance.C];
            Level           currLevel = character.GetCurrentLevel(__instance.m_curLevel);

            if (currLevel.Patrols.Count < 1)
            {
                return(false);
            }

            //Get a valid patrol index, and exit if there are no valid patrols
            int patrolIndex = GetValidPatrolIndex(currLevel.Patrols);

            if (patrolIndex == -1)
            {
                TNHTweakerLogger.Log("TNHTWEAKER -- No valid patrols can spawn", TNHTweakerLogger.LogType.TNH);
                ___m_timeTilPatrolCanSpawn = 999;

                //Returning an empty squad is the easiest way to not generate a patrol when no valid ones are found
                //This could cause strange and unpredictable behaviour
                //Good luck!
                __result = new TNH_Manager.SosigPatrolSquad();
                __result.PatrolPoints = new List <Vector3>();
                __result.Squad        = new List <Sosig>();

                return(false);
            }

            TNHTweakerLogger.Log("TNHTWEAKER -- Valid patrol found", TNHTweakerLogger.LogType.TNH);

            Patrol patrol = currLevel.Patrols[patrolIndex];

            TNH_Manager.SosigPatrolSquad squad = GeneratePatrol(__instance, patrol, SpawnPoints, ForwardVectors, PatrolPoints, patrolIndex);

            //We don't add this patrol because it's tracked outside of this method
            //___m_patrolSquads.Add(squad);

            if (__instance.EquipmentMode == TNHSetting_EquipmentMode.Spawnlocking)
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadence;
            }
            else
            {
                ___m_timeTilPatrolCanSpawn = patrol.PatrolCadenceLimited;
            }

            __result = squad;
            return(false);
        }
Beispiel #11
0
        public static bool TrackPlayerSpawnPatch(TNH_Manager __instance)
        {
            TNHTweaker.HoldActions[0].Add($"Spawned At Supply {__instance.m_curPointSequence.StartSupplyPointIndex}");

            TNHTweakerLogger.Log("Spawned Player", TNHTweakerLogger.LogType.TNH);

            return(true);
        }
Beispiel #12
0
        /// <summary>
        /// First method that gets called
        /// </summary>
        private void Awake()
        {
            TNHTweakerLogger.Init();
            TNHTweakerLogger.Log("Hello World (from TNH Tweaker)", TNHTweakerLogger.LogType.General);

            Harmony.CreateAndPatchAll(typeof(TNHTweaker));
            Harmony.CreateAndPatchAll(typeof(TNHPatches));
            //Harmony.CreateAndPatchAll(typeof(DebugPatches));

            Stages.Setup += OnSetup;
        }
Beispiel #13
0
        public static bool TrackRecyclePatch(TNH_GunRecycler __instance)
        {
            TNHTweakerLogger.Log("Recycle button", TNHTweakerLogger.LogType.TNH);
            if (__instance.m_detectedFirearms.Count > 0 && __instance.m_detectedFirearms[0] != null)
            {
                TNHTweaker.HoldActions[__instance.M.m_level].Add($"Recycled {__instance.m_detectedFirearms[0].ObjectWrapper.DisplayName}");
                TNHTweaker.GunsRecycled += 1;
            }

            return(true);
        }
Beispiel #14
0
        public void Awake()
        {
            original = gameObject.GetComponent <TNH_MagDuplicator>();
            if (original == null)
            {
                TNHTweakerLogger.LogError("Fire Rate Modifier failed, original Mag Duplicator was null!");
            }
            original.enabled = false;

            InitPanel();
            UpdateIcons();
        }
Beispiel #15
0
        void OnDestroy()
        {
            if (dontDrop)
            {
                return;
            }

            TNHTweakerLogger.Log("TNHTweaker -- Lootable link was destroyed!", TNHTweakerLogger.LogType.TNH);

            List <EquipmentGroup> selectedGroups = group.GetSpawnedEquipmentGroups();
            string selectedItem;
            int    spawnedItems = 0;

            foreach (EquipmentGroup selectedGroup in selectedGroups)
            {
                for (int itemIndex = 0; itemIndex < selectedGroup.ItemsToSpawn; itemIndex++)
                {
                    if (selectedGroup.IsCompatibleMagazine)
                    {
                        FVRObject mag = FirearmUtils.GetAmmoContainerForEquipped(selectedGroup.MinAmmoCapacity, selectedGroup.MaxAmmoCapacity);
                        if (mag != null)
                        {
                            selectedItem = mag.ItemID;
                        }
                        else
                        {
                            TNHTweakerLogger.Log(
                                "TNHTweaker -- Spawning nothing, since group was compatible magazines, and could not find a compatible magazine for player",
                                TNHTweakerLogger.LogType.TNH);
                            return;
                        }
                    }

                    else
                    {
                        selectedItem = selectedGroup.GetObjects().GetRandom();
                    }

                    if (LoadedTemplateManager.LoadedVaultFiles.ContainsKey(selectedItem))
                    {
                        AnvilManager.Run(TNHTweakerUtils.SpawnFirearm(LoadedTemplateManager.LoadedVaultFiles[selectedItem],
                                                                      transform.position + (Vector3.up * 0.1f * spawnedItems), transform.rotation));
                    }
                    else
                    {
                        Instantiate(IM.OD[selectedItem].GetGameObject(), transform.position + (Vector3.up * 0.1f * spawnedItems), transform.rotation);
                    }

                    spawnedItems += 1;
                }
            }
        }
 public static void CreateTNHFiles(string path)
 {
     //Create files relevant for character creation
     TNHTweakerLogger.Log("TNHTweaker -- Creating character creation files", TNHTweakerLogger.LogType.General);
     TNHTweakerUtils.CreateDefaultSosigTemplateFiles(LoadedTemplateManager.DefaultSosigs, path);
     TNHTweakerUtils.CreateDefaultCharacterFiles(LoadedTemplateManager.DefaultCharacters, path);
     TNHTweakerUtils.CreateIconIDFile(path, LoadedTemplateManager.DefaultIconSprites.Keys.ToList());
     TNHTweakerUtils.CreateObjectIDFile(path);
     TNHTweakerUtils.CreateSosigIDFile(path);
     TNHTweakerUtils.CreateJsonVaultFiles(path);
     TNHTweakerUtils.CreateGeneratedTables(path);
     TNHTweakerUtils.CreatePopulatedCharacterTemplate(path);
 }
Beispiel #17
0
        /// <summary>
        /// Loads the bepinex config file, and applys those settings
        /// </summary>
        private void LoadConfigFile()
        {
            TNHTweakerLogger.Log("TNHTweaker -- Getting config file", TNHTweakerLogger.LogType.File);

            BuildCharacterFiles = Source.Config.Bind("General",
                                                     "BuildCharacterFiles",
                                                     false,
                                                     "If true, files useful for character creation will be generated in TNHTweaker folder");

            EnableScoring = Source.Config.Bind("General",
                                               "EnableScoring",
                                               true,
                                               "If true, TNH scores will be uploaded to the TNH Dashboard (https://devyndamonster.github.io/TNHDashboard/index.html)");

            allowLog = Source.Config.Bind("Debug",
                                          "EnableLogging",
                                          true,
                                          "Set to true to enable logging");

            printCharacters = Source.Config.Bind("Debug",
                                                 "LogCharacterInfo",
                                                 false,
                                                 "Decide if should print all character info");

            logTNH = Source.Config.Bind("Debug",
                                        "LogTNH",
                                        false,
                                        "If true, general TNH information will be logged");

            logFileReads = Source.Config.Bind("Debug",
                                              "LogFileReads",
                                              false,
                                              "If true, reading from a file will log the reading process");

            UnlimitedTokens = Source.Config.Bind("Debug",
                                                 "EnableUnlimitedTokens",
                                                 false,
                                                 "If true, you will spawn with 999999 tokens for any character in TNH (useful for testing loot pools)");

            EnableDebugText = Source.Config.Bind("Debug",
                                                 "EnableDebugText",
                                                 false,
                                                 "If true, some text will appear in TNH maps showing additional info");



            TNHTweakerLogger.AllowLogging = allowLog.Value;
            TNHTweakerLogger.LogCharacter = printCharacters.Value;
            TNHTweakerLogger.LogTNH       = logTNH.Value;
            TNHTweakerLogger.LogFile      = logFileReads.Value;
        }
        public static void AddCharacterTemplate(CustomCharacter template, Sprite thumbnail)
        {
            CustomCharacters.Add(template);
            LoadedCharactersDict.Add(template.GetCharacter(NewCharacterID, thumbnail), template);

            foreach (EquipmentPool pool in template.EquipmentPools)
            {
                EquipmentPoolDictionary.Add(pool.GetPoolEntry(), pool);
            }

            NewCharacterID += 1;

            TNHTweakerLogger.Log("TNHTweaker -- Character added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character);
        }
Beispiel #19
0
        public void Awake()
        {
            original = gameObject.GetComponent <TNH_MagDuplicator>();
            if (original == null)
            {
                TNHTweakerLogger.LogError("Mag Upgrader failed, original Mag Duplicator was null!");
            }
            original.enabled = false;

            blacklist = LoadedTemplateManager.LoadedCharactersDict[original.M.C].GetMagazineBlacklist();

            InitPanel();
            UpdateIcons();
        }
Beispiel #20
0
        public static bool StartOfGamePatch(TNH_Manager __instance)
        {
            if (!__instance.m_hasInit && __instance.AIManager.HasInit)
            {
                //Clear all entries from the tracked stats
                TNHTweaker.HoldActions.Clear();
                TNHTweaker.HoldStats.Clear();

                TNHTweaker.GunsRecycled = 0;
                TNHTweaker.ShotsFired   = 0;

                TNHTweakerLogger.Log("Delayed init", TNHTweakerLogger.LogType.TNH);
            }

            return(true);
        }
        public static void EquipSosigWeapon(Sosig sosig, GameObject weaponPrefab, TNHModifier_AIDifficulty difficulty)
        {
            SosigWeapon weapon = UnityEngine.Object.Instantiate(weaponPrefab, sosig.transform.position + Vector3.up * 0.1f, sosig.transform.rotation).GetComponent <SosigWeapon>();

            weapon.SetAutoDestroy(true);
            weapon.O.SpawnLockable = false;

            TNHTweakerLogger.Log("TNHTWEAKER -- Equipping sosig weapon: " + weapon.gameObject.name, TNHTweakerLogger.LogType.TNH);

            //Equip the sosig weapon to the sosig
            sosig.ForceEquip(weapon);
            weapon.SetAmmoClamping(true);
            if (difficulty == TNHModifier_AIDifficulty.Arcade)
            {
                weapon.FlightVelocityMultiplier = 0.3f;
            }
        }
        public static void AddCharacterTemplate(TNH_CharacterDef realTemplate)
        {
            CustomCharacter template = new CustomCharacter(realTemplate);

            DefaultCharacters.Add(template);
            LoadedCharactersDict.Add(realTemplate, template);

            foreach (EquipmentPool pool in template.EquipmentPools)
            {
                //Must check for this, since default characters can have references to the same pools
                if (!EquipmentPoolDictionary.ContainsKey(pool.GetPoolEntry()))
                {
                    EquipmentPoolDictionary.Add(pool.GetPoolEntry(), pool);
                }
            }

            TNHTweakerLogger.Log("TNHTweaker -- Character added successfuly : " + realTemplate.DisplayName, TNHTweakerLogger.LogType.Character);
        }
        /// <summary>
        /// Performs a delayed init on the sent list of custom characters, and removes any characters that failed to init
        /// </summary>
        /// <param name="characters"></param>
        /// <param name="isCustom"></param>
        private static void InitCharacters(List <CustomCharacter> characters, bool isCustom)
        {
            for (int i = 0; i < characters.Count; i++)
            {
                CustomCharacter character = characters[i];

                try
                {
                    character.DelayedInit(isCustom);
                }
                catch (Exception e)
                {
                    TNHTweakerLogger.LogError("TNHTweaker -- Failed to load character: " + character.DisplayName + ". Error Output:\n" + e.ToString());
                    characters.RemoveAt(i);
                    LoadedTemplateManager.LoadedCharactersDict.Remove(character.GetCharacter());
                    i -= 1;
                }
            }
        }
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IFileHandle file)
            {
                throw new ArgumentException("Could not load sosig! Make sure you're pointing to a sosig template json file in the manifest");
            }

            try
            {
                SosigTemplate sosig = stage.ImmediateReaders.Get <JToken>()(file).ToObject <SosigTemplate>();
                TNHTweakerLogger.Log("TNHTweaker -- Sosig loaded successfuly : " + sosig.DisplayName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddSosigTemplate(sosig);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for sosig file! Caused Error: " + e.ToString());
            }
        }
Beispiel #25
0
        public static bool RequestScores(TNH_ScoreDisplay __instance)
        {
            if (waitForScore)
            {
                return(false);
            }

            //The first thing we do is get the top scores
            if (__instance.m_doRequestScoresTop)
            {
                TNHTweakerLogger.Log("Requesting Top Scores", TNHTweakerLogger.LogType.TNH);
                __instance.m_doRequestScoresTop = false;
                __instance.m_scoresTop          = new List <RUST.Steamworks.HighScoreManager.HighScore>();

                AnvilManager.Instance.StartCoroutine(GetHighScores(6, __instance));
            }

            //After the top scores are retrieved, request the players score
            if (__instance.m_doRequestScoresPlayer)
            {
                TNHTweakerLogger.Log("Requesting Player Scores", TNHTweakerLogger.LogType.TNH);
                __instance.m_doRequestScoresPlayer = false;
                __instance.m_scoresPlayer          = new List <RUST.Steamworks.HighScoreManager.HighScore>();

                //If the players score is also in the selection of top scores, we just display the top
                if (__instance.m_scoresTop.Any(o => o.name == SteamFriends.GetPersonaName()))
                {
                    __instance.m_scoresPlayer    = new List <RUST.Steamworks.HighScoreManager.HighScore>();
                    __instance.m_hasScoresPlayer = true;

                    __instance.SetGlobalHighScoreDisplay(__instance.m_scoresTop);
                }

                //If the players scores are not at the top, we must also find their scores
                else
                {
                    AnvilManager.Instance.StartCoroutine(GetPlayerScores(1, 1, __instance));
                }
            }

            return(false);
        }
        public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
        {
            if (handle is not IFileHandle file)
            {
                throw new ArgumentException("Could not load vault file! Make sure you're pointing to a vault json file in the manifest");
            }

            try
            {
                SavedGunSerializable savedGun = stage.ImmediateReaders.Get <JToken>()(file).ToObject <SavedGunSerializable>();

                TNHTweakerLogger.Log("TNHTweaker -- Vault file loaded successfuly : " + savedGun.FileName, TNHTweakerLogger.LogType.File);

                LoadedTemplateManager.AddVaultFile(savedGun);
            }
            catch (Exception e)
            {
                TNHTweakerLogger.LogError("Failed to load setup assets for vault file! Caused Error: " + e.ToString());
            }
        }
Beispiel #27
0
        public static bool PreventScoring(TNH_ScoreDisplay __instance, int score)
        {
            TNHTweakerLogger.Log("Preventing vanilla score submition", TNHTweakerLogger.LogType.TNH);

            GM.Omni.OmniFlags.AddScore(__instance.m_curSequenceID, score);

            __instance.m_hasCurrentScore = true;
            __instance.m_currentScore    = score;

            if (EnableScoring.Value)
            {
                AnvilManager.Instance.StartCoroutine(HighScorePatches.SendScore(score));
            }

            //Draw local scores
            __instance.RedrawHighScoreDisplay(__instance.m_curSequenceID);

            GM.Omni.SaveToFile();

            return(false);
        }
        public static void LoadTNHTemplates(TNH_CharacterDatabase CharDatabase)
        {
            TNHTweakerLogger.Log("TNHTweaker -- Performing TNH Initialization", TNHTweakerLogger.LogType.General);

            //Load all of the default templates into our dictionaries
            TNHTweakerLogger.Log("TNHTweaker -- Adding default sosigs to template dictionary", TNHTweakerLogger.LogType.General);
            LoadDefaultSosigs();
            TNHTweakerLogger.Log("TNHTweaker -- Adding default characters to template dictionary", TNHTweakerLogger.LogType.General);
            LoadDefaultCharacters(CharDatabase.Characters);

            LoadedTemplateManager.DefaultIconSprites = TNHTweakerUtils.GetAllIcons(LoadedTemplateManager.DefaultCharacters);

            TNHTweakerLogger.Log("TNHTweaker -- Delayed Init of default characters", TNHTweakerLogger.LogType.General);
            InitCharacters(LoadedTemplateManager.DefaultCharacters, false);

            TNHTweakerLogger.Log("TNHTweaker -- Delayed Init of custom characters", TNHTweakerLogger.LogType.General);
            InitCharacters(LoadedTemplateManager.CustomCharacters, true);

            TNHTweakerLogger.Log("TNHTweaker -- Delayed Init of custom sosigs", TNHTweakerLogger.LogType.General);
            InitSosigs(LoadedTemplateManager.CustomSosigs);
        }
        public static void AddSosigTemplate(SosigEnemyTemplate realTemplate)
        {
            SosigTemplate template = new SosigTemplate(realTemplate);

            //This template is from a sogig that already has a valid SosigEnemyID, so we can just add that to the dictionary casted as an int
            if (!SosigIDDict.ContainsKey(template.SosigEnemyID))
            {
                SosigIDDict.Add(template.SosigEnemyID, (int)realTemplate.SosigEnemyID);
            }
            else
            {
                TNHTweakerLogger.LogError("TNHTweaker -- Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + template.SosigEnemyID);
                return;
            }

            //Since the real template already had a valid SosigEnemyID, we can skip the part where we reassign them
            DefaultSosigs.Add(realTemplate);
            LoadedSosigsDict.Add(realTemplate, template);

            TNHTweakerLogger.Log("TNHTweaker -- Sosig added successfuly : " + template.DisplayName, TNHTweakerLogger.LogType.Character);
        }
Beispiel #30
0
        /// <summary>
        /// Loads the bepinex config file, and applys those settings
        /// </summary>
        private void LoadConfigFile()
        {
            TNHTweakerLogger.Log("TNHTweaker -- Getting config file", TNHTweakerLogger.LogType.File);

            BuildCharacterFiles = Source.Config.Bind("General",
                                                     "BuildCharacterFiles",
                                                     false,
                                                     "If true, files useful for character creation will be generated in TNHTweaker folder");


            allowLog = Source.Config.Bind("Debug",
                                          "EnableLogging",
                                          true,
                                          "Set to true to enable logging");

            printCharacters = Source.Config.Bind("Debug",
                                                 "LogCharacterInfo",
                                                 false,
                                                 "Decide if should print all character info");

            logTNH = Source.Config.Bind("Debug",
                                        "LogTNH",
                                        false,
                                        "If true, general TNH information will be logged");

            logFileReads = Source.Config.Bind("Debug",
                                              "LogFileReads",
                                              false,
                                              "If true, reading from a file will log the reading process");

            UnlimitedTokens = Source.Config.Bind("Debug",
                                                 "EnableUnlimitedTokens",
                                                 false,
                                                 "If true, you will spawn with 999999 tokens for any character in TNH (useful for testing loot pools)");

            TNHTweakerLogger.AllowLogging = allowLog.Value;
            TNHTweakerLogger.LogCharacter = printCharacters.Value;
            TNHTweakerLogger.LogTNH       = logTNH.Value;
            TNHTweakerLogger.LogFile      = logFileReads.Value;
        }