Ejemplo n.º 1
0
        private void LoadLanceOverrides()
        {
            foreach (string file in Directory.GetFiles($"{ModDirectory}/lances", "*.json", SearchOption.AllDirectories))
            {
                string             lanceData         = File.ReadAllText(file);
                MLanceOverrideData lanceOverrideData = JsonConvert.DeserializeObject <MLanceOverrideData>(lanceData);

                if (lanceOverrideData.LanceKey != null)
                {
                    LanceOverrides.Add(lanceOverrideData.LanceKey, new MLanceOverride(lanceOverrideData));

                    Main.Logger.Log($"[DataManager] Loaded lance override '{lanceOverrideData.LanceKey}'");

                    /*
                     * if (Main.Settings.DebugMode) {
                     * Main.Logger.Log($"[DataManager] Lance def id '{lanceOverrideData.LanceDefId}'");
                     * Main.Logger.Log($"[DataManager] Lance Tag Set items '{string.Join(",", lanceOverrideData.LanceTagSet.Items)}' and source file '{lanceOverrideData.LanceTagSet.TagSetSourceFile}'");
                     * Main.Logger.Log($"[DataManager] Lance Excluded Tag Set items '{string.Join(",", lanceOverrideData.LanceExcludedTagSet.Items)}' and source file '{lanceOverrideData.LanceExcludedTagSet.TagSetSourceFile}'");
                     * Main.Logger.Log($"[DataManager] Spawn Effect Tags items '{string.Join(",", lanceOverrideData.LanceTagSet.Items)}' and source file '{lanceOverrideData.LanceTagSet.TagSetSourceFile}'");
                     *
                     * foreach (MUnitSpawnPointOverrideData unitSpawnPointOverrideData in lanceOverrideData.UnitSpawnPointOverride) {
                     *  Main.Logger.Log($"[DataManager] Unit type '{unitSpawnPointOverrideData.UnitType}'");
                     *  Main.Logger.Log($"[DataManager] Unit def id '{unitSpawnPointOverrideData.UnitDefId}'");
                     *  Main.Logger.Log($"[DataManager] Unit Tag Set items '{string.Join(",", unitSpawnPointOverrideData.UnitTagSet.Items)}' and source file '{unitSpawnPointOverrideData.UnitTagSet.TagSetSourceFile}'");
                     *  Main.Logger.Log($"[DataManager] Unit Excluded Tag Set items '{string.Join(",", unitSpawnPointOverrideData.UnitExcludedTagSet.Items)}' and source file '{unitSpawnPointOverrideData.UnitExcludedTagSet.TagSetSourceFile}'");
                     *  Main.Logger.Log($"[DataManager] Spawn Effect Tags items '{string.Join(",", unitSpawnPointOverrideData.SpawnEffectTags.Items)}' and source file '{unitSpawnPointOverrideData.SpawnEffectTags.TagSetSourceFile}'");
                     *  Main.Logger.Log($"[DataManager] Pilot def id '{unitSpawnPointOverrideData.PilotDefId}'");
                     *  Main.Logger.Log($"[DataManager] Pilot Tag Set items '{string.Join(",", unitSpawnPointOverrideData.PilotTagSet.Items)}' and source file '{unitSpawnPointOverrideData.PilotTagSet.TagSetSourceFile}'");
                     *  Main.Logger.Log($"[DataManager] Pilot Excluded Tag Set items '{string.Join(",", unitSpawnPointOverrideData.PilotExcludedTagSet.Items)}' and source file '{unitSpawnPointOverrideData.PilotExcludedTagSet.TagSetSourceFile}'");
                     * }
                     * }
                     */
                }
                else
                {
                    Main.Logger.LogError($"[DataManager] Json format is wrong. Read the documentation on the lance override format.");
                }
            }
        }
Ejemplo n.º 2
0
        public MLanceOverride GetLanceOverride(string key)
        {
            IDataItemStore <string, LanceDef> lanceDefs = UnityGameInstance.BattleTechGame.DataManager.LanceDefs;

            if (LanceOverrides.ContainsKey(key))
            {
                Main.Logger.Log($"[GetLanceOverride] Found a lance override for '{key}'");
                return(LanceOverrides[key].Copy());
            }

            LanceDef lanceDef = null;

            lanceDefs.TryGet(key, out lanceDef);
            if (lanceDef != null)
            {
                MLanceOverride lanceOverride = new MLanceOverride(lanceDef);
                LanceOverrides.Add(lanceOverride.lanceDefId, lanceOverride);
                Main.Logger.Log($"[GetLanceOverride] Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty' of '0' and no 'spawnEffectTags'");
                return(lanceOverride.Copy());
            }
            else
            {
                Main.Logger.Log($"[GetLanceOverride] No loaded LanceDef was found for '{key}'. Attempting to load the LanceDef.");
                lanceDef = BattleTechResourceLoader.LoadDefFromId <LanceDef>(key, BattleTechResourceType.LanceDef);
                DataManager.Instance.RequestResourcesAndProcess(BattleTechResourceType.LanceDef, key);

                if (lanceDef != null)
                {
                    MLanceOverride lanceOverride = new MLanceOverride(lanceDef);
                    LanceOverrides.Add(lanceOverride.lanceDefId, lanceOverride);
                    Main.Logger.Log($"[GetLanceOverride] Load succeeded. Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty' of '0' and no 'spawnEffectTags'");
                    return(lanceOverride.Copy());
                }
            }

            Main.Logger.LogError($"[GetLanceOverride] No MC Lance or LanceDef found with key '{key}'. This is a case sensitive search.'");
            return(null);
        }
Ejemplo n.º 3
0
        public MLanceOverride GetLanceOverride(string key)
        {
            IDataItemStore <string, LanceDef> lanceDefs = UnityGameInstance.BattleTechGame.DataManager.LanceDefs;

            if (LanceOverrides.ContainsKey(key))
            {
                Main.Logger.Log($"[GetLanceOverride] Found a lance override for '{key}'");
                return(LanceOverrides[key]);
            }

            LanceDef lanceDef = null;

            lanceDefs.TryGet(key, out lanceDef);
            if (lanceDef != null)
            {
                MLanceOverride lanceOverride = new MLanceOverride(lanceDef);
                LanceOverrides.Add(lanceOverride.lanceDefId, lanceOverride);
                Main.Logger.Log($"[GetLanceOverride] Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty - 0' and no 'spawnEffectTags'");
                return(lanceOverride);
            }

            return(null);
        }