예제 #1
0
        public static bool TrackVictory(TNH_Manager __instance)
        {
            TNHTweakerLogger.Log("Victory", TNHTweakerLogger.LogType.TNH);
            TNHTweaker.HoldActions.Last().Add("Victory");

            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);
        }
예제 #3
0
        public static bool TrackNextLevel(TNH_Manager __instance)
        {
            TNHTweakerLogger.Log("Set Level", TNHTweakerLogger.LogType.TNH);
            TNHTweaker.HoldActions.Add(new List <string>());

            return(true);
        }
        //TODO To choose spawn based on IFF, we need to basically generate spawn points on our own in this method!
        public static TNH_Manager.SosigPatrolSquad GeneratePatrol(TNH_Manager instance, Patrol patrol, List <Vector3> SpawnPoints, List <Vector3> ForwardVectors, List <Vector3> PatrolPoints, int patrolIndex)
        {
            TNH_Manager.SosigPatrolSquad squad = new TNH_Manager.SosigPatrolSquad();
            squad.PatrolPoints = new List <Vector3>(PatrolPoints);

            for (int i = 0; i < patrol.PatrolSize && i < SpawnPoints.Count; i++)
            {
                SosigEnemyTemplate template;

                bool allowAllWeapons;

                //If this is a boss, then we can only spawn it once, so add it to the list of spawned bosses
                if (patrol.IsBoss)
                {
                    TNHTweaker.SpawnedBossIndexes.Add(patrolIndex);
                }

                //Select a sosig template from the custom character patrol
                if (i == 0)
                {
                    template        = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.LeaderType]];
                    allowAllWeapons = true;
                }

                else
                {
                    template        = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.EnemyType.GetRandom()]];
                    allowAllWeapons = false;
                }

                CustomCharacter character      = LoadedTemplateManager.LoadedCharactersDict[instance.C];
                SosigTemplate   customTemplate = LoadedTemplateManager.LoadedSosigsDict[template];
                FVRObject       droppedObject  = instance.Prefab_HealthPickupMinor;

                //If squad is set to swarm, the first point they path to should be the players current position
                Sosig sosig;
                if (patrol.SwarmPlayer)
                {
                    squad.PatrolPoints[0] = GM.CurrentPlayerBody.transform.position;
                    sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons);
                    sosig.SetAssaultSpeed(patrol.AssualtSpeed);
                }
                else
                {
                    sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons);
                    sosig.SetAssaultSpeed(patrol.AssualtSpeed);
                }

                //Handle patrols dropping health
                if (i == 0 && UnityEngine.Random.value < patrol.DropChance)
                {
                    sosig.Links[1].RegisterSpawnOnDestroy(droppedObject);
                }

                squad.Squad.Add(sosig);
            }

            return(squad);
        }
        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);
        }
예제 #6
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);
        }
예제 #7
0
        static void Postfix(TNH_Manager __instance)
        {
            var forcedSpawn = __instance.SupplyPoints.Select(x => x.GetComponent <ForcedSpawn>()).FirstOrDefault(x => x != null);

            if (forcedSpawn == null)
            {
                return;
            }
            __instance.SupplyPoints = __instance.SupplyPoints.Where(x => x.gameObject != forcedSpawn.gameObject).ToList();
            __instance.ReflectGet <TNH_PointSequence>("m_curPointSequence").StartSupplyPointIndex = 0;
        }
예제 #8
0
        public static bool ResetStats(TNH_Manager __instance)
        {
            foreach (HoldStats stat in TNHTweaker.HoldStats)
            {
                __instance.Stats[3] += stat.SosigsKilled;
                __instance.Stats[5] += stat.MeleeKills;
                __instance.Stats[4] += stat.Headshots;
                __instance.Stats[8] += stat.TokensSpent;
            }

            return(true);
        }
예제 #9
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);
        }
예제 #10
0
        public static ScoreEntry GetScoreEntry(TNH_Manager instance, int score)
        {
            ScoreEntry entry = new ScoreEntry();

            entry.Name          = SteamFriends.GetPersonaName();
            entry.Score         = score;
            entry.Character     = instance.C.DisplayName;
            entry.Map           = instance.LevelName;
            entry.EquipmentMode = equipment[(int)GM.TNHOptions.EquipmentModeSetting];
            entry.HealthMode    = health[(int)GM.TNHOptions.HealthModeSetting];
            entry.GameLength    = length[(int)GM.TNHOptions.ProgressionTypeSetting];
            entry.HoldActions   = JsonConvert.SerializeObject(TNHTweaker.HoldActions);
            entry.HoldStats     = JsonConvert.SerializeObject(TNHTweaker.HoldStats);

            return(entry);
        }
예제 #11
0
 public static void AddMusicControllerTNH(TNH_Manager manager)
 {
     try
     {
         var gm              = new GameObject();
         var mci             = gm.AddComponent <MusicController>();
         var musicController = Object.Instantiate(mci.GameObject, GM.CurrentPlayerBody.Head.transform.position, GM.CurrentPlayerBody.Head.transform.rotation);
         manager.AddObjectToTrackedList(musicController);
         //Destroy the original gameobject
         Object.Destroy(gm);
     }
     catch (Exception e)
     {
         Logger.Log(e);
         Application.Quit();
     }
 }
예제 #12
0
        /// <summary>
        /// Base function for setting up the TNH Manager object to handle a custom level.
        /// </summary>
        public override void Resolve()
        {
            _tnhManager = ObjectReferences.ManagerDonor;

            // Hold points need to be set.
            _tnhManager.HoldPoints = LevelRoot.GetComponentsInChildren <TNH_HoldPoint>(true).ToList();

            // Supply points need to be set.
            _tnhManager.SupplyPoints = LevelRoot.GetComponentsInChildren <TNH_SupplyPoint>(true).ToList();

            // Possible Sequences need to be generated at random.
            if (LevelRoot.ExtraData == null || LevelRoot.ExtraData[0].Value == "")
            {
                _tnhManager.PossibleSequnces = GenerateRandomPointSequences(1);
            }

            // Safe Pos Matrix needs to be set. Diagonal for now.
            TNH_SafePositionMatrix maxMatrix = GenerateTestMatrix();

            _tnhManager.SafePosMatrix = maxMatrix;
        }
예제 #13
0
        public static bool TrackHoldCompletion(TNH_Manager __instance)
        {
            TNHTweakerLogger.Log("Hold Completion", TNHTweakerLogger.LogType.TNH);

            TNHTweaker.HoldStats.Add(new HoldStats()
            {
                SosigsKilled = __instance.Stats[3],
                MeleeKills   = __instance.Stats[5],
                Headshots    = __instance.Stats[4],
                TokensSpent  = __instance.Stats[8],
                GunsRecycled = TNHTweaker.GunsRecycled,
                AmmoSpent    = TNHTweaker.ShotsFired
            });

            __instance.Stats[3]     = 0;
            __instance.Stats[5]     = 0;
            __instance.Stats[4]     = 0;
            __instance.Stats[8]     = 0;
            TNHTweaker.GunsRecycled = 0;
            TNHTweaker.ShotsFired   = 0;

            return(true);
        }
예제 #14
0
        public static void BeginGameInjectNewTakeAndHold(TNH_Manager manager)
        {
            try
            {
                CurrentManagerWrapper.CurrentManager = manager;
                //This is needed for BASS
                Assembly.Load("System.Windows.Forms");

                //Add the needed components
                var audioMod = manager.gameObject.AddComponent <AudioModComponent>();
                manager.gameObject.AddComponent <AudioCrossFade>();

                audioMod.Manager = manager;

                audioMod.Init();
                audioMod.SilenceDefaultMusic();
            }
            catch (Exception e)
            {
                Logger.Log(e);
                Application.Quit();
            }
        }
        public static bool GenerateValidPatrolReplacement(TNH_PatrolChallenge P, int curStandardIndex, int excludeHoldIndex, bool isStart, TNH_Manager __instance, TNH_Progression.Level ___m_curLevel, List <TNH_Manager.SosigPatrolSquad> ___m_patrolSquads, ref float ___m_timeTilPatrolCanSpawn)
        {
            TNHTweakerLogger.Log("TNHTWEAKER -- Generating a patrol -- There are currently " + ___m_patrolSquads.Count + " patrols active", TNHTweakerLogger.LogType.TNH);

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

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

            //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;
                return(false);
            }

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

            Patrol patrol = currLevel.Patrols[patrolIndex];

            List <int> validLocations = new List <int>();
            float      minDist        = __instance.TAHReticle.Range * 1.2f;

            //Get a safe starting point for the patrol to spawn
            TNH_SafePositionMatrix.PositionEntry startingEntry;
            if (isStart)
            {
                startingEntry = __instance.SafePosMatrix.Entries_SupplyPoints[curStandardIndex];
            }
            else
            {
                startingEntry = __instance.SafePosMatrix.Entries_HoldPoints[curStandardIndex];
            }


            for (int i = 0; i < startingEntry.SafePositions_HoldPoints.Count; i++)
            {
                if (i != excludeHoldIndex && startingEntry.SafePositions_HoldPoints[i])
                {
                    float playerDist = Vector3.Distance(GM.CurrentPlayerBody.transform.position, __instance.HoldPoints[i].transform.position);
                    if (playerDist > minDist)
                    {
                        validLocations.Add(i);
                    }
                }
            }


            if (validLocations.Count < 1)
            {
                return(false);
            }
            validLocations.Shuffle();

            TNH_Manager.SosigPatrolSquad squad = GeneratePatrol(validLocations[0], __instance, patrol, patrolIndex);
            ___m_patrolSquads.Add(squad);

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

            return(false);
        }
        /// <summary>
        /// Spawns a patrol at the desire patrol point
        /// </summary>
        public static TNH_Manager.SosigPatrolSquad GeneratePatrol(int HoldPointStart, TNH_Manager instance, Patrol patrol, int patrolIndex)
        {
            List <Vector3> SpawnPoints    = new List <Vector3>();
            List <Vector3> PatrolPoints   = new List <Vector3>();
            List <Vector3> ForwardVectors = new List <Vector3>();

            foreach (TNH_HoldPoint holdPoint in instance.HoldPoints)
            {
                PatrolPoints.Add(holdPoint.SpawnPoints_Sosigs_Defense.GetRandom <Transform>().position);
            }

            foreach (Transform spawnPoint in instance.HoldPoints[HoldPointStart].SpawnPoints_Sosigs_Defense)
            {
                SpawnPoints.Add(spawnPoint.position);
                ForwardVectors.Add(spawnPoint.forward);
            }

            //Insert spawn point as first patrol point
            Vector3 startingPoint = PatrolPoints[HoldPointStart];

            PatrolPoints.RemoveAt(HoldPointStart);
            PatrolPoints.Insert(0, startingPoint);

            return(GeneratePatrol(instance, patrol, SpawnPoints, ForwardVectors, PatrolPoints, patrolIndex));
        }
예제 #17
0
        public static bool TrackShotFired(TNH_Manager __instance)
        {
            TNHTweaker.ShotsFired += 1;

            return(true);
        }