public static void OnLoad()
        {
            Log("Version {0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);

            AutoMapper.Initialize();
            ModHealthManager.Initialize();
            GearSpawner.Initialize();
            BlueprintReader.Initialize();
        }
Example #2
0
        public static void OnLoad()
        {
            Debug.Log("[ModComponentMapper]: Version " + Assembly.GetExecutingAssembly().GetName().Version);

            AutoMapper.Initialize();
            ModHealthManager.Initialize();
            GearSpawner.Initialize();
            BlueprintReader.Initialize();
        }
Example #3
0
        internal static void InitializeAndMapAssets()
        {
            PageManager.Initialize();

            Logger.LogDebug("Running in Debug Mode");

            ZipFileLoader.Initialize();

            AutoMapper.Initialize();
            ModHealthManager.Initialize();
            AssetBundleManager.LoadPendingAssetBundles();
            GearSpawner.Initialize();
            BlueprintReader.ReadDefinitions();
        }
Example #4
0
        internal static void ProcessLines(string[] lines, string path)
        {
            Logger.Log("Processing spawn file '" + path + "'.");
            string scene     = null;
            string loottable = null;
            string tag       = "none";

            foreach (string eachLine in lines)
            {
                var trimmedLine = GetTrimmedLine(eachLine);
                if (trimmedLine.Length == 0 || trimmedLine.StartsWith("#"))
                {
                    continue;
                }

                var match = SCENE_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    scene     = match.Groups[1].Value;
                    loottable = null;
                    continue;
                }

                match = TAG_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    tag = match.Groups[1].Value;
                    Logger.Log("Tag found while reading spawn file. '{0}'", tag);
                    continue;
                }

                match = SPAWN_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    if (string.IsNullOrEmpty(scene))
                    {
                        PageManager.SetItemPackNotWorking(path, $"No scene name defined before line '{eachLine}' from '{path}'. Did you forget a 'scene = <SceneName>'?");
                        return;
                    }

                    GearSpawnInfo info = new GearSpawnInfo();
                    info.PrefabName = match.Groups[1].Value;

                    info.SpawnChance = ParseFloat(match.Groups[4].Value, 100, eachLine, path);

                    info.Position = ParseVector(match.Groups[2].Value, eachLine, path);
                    info.Rotation = Quaternion.Euler(ParseVector(match.Groups[3].Value, eachLine, path));

                    info.tag = tag + "";

                    GearSpawner.AddGearSpawnInfo(scene, info);
                    continue;
                }

                match = LOOTTABLE_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    loottable = match.Groups[1].Value;
                    scene     = null;
                    continue;
                }

                match = LOOTTABLE_ENTRY_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    if (string.IsNullOrEmpty(loottable))
                    {
                        PageManager.SetItemPackNotWorking(path, $"No loottable name defined before line '{eachLine}' from '{path}'. Did you forget a 'loottable = <LootTableName>'?");
                        return;
                    }

                    LootTableEntry entry = new LootTableEntry();
                    entry.PrefabName = match.Groups[1].Value;
                    entry.Weight     = ParseInt(match.Groups[2].Value, 0, eachLine, path);
                    GearSpawner.AddLootTableEntry(loottable, entry);
                    continue;
                }

                //Only runs if nothing matches
                PageManager.SetItemPackNotWorking(path, $"Unrecognized line '{eachLine}' in '{path}'.");
                return;
            }
        }
        private static void ProcessFile(string path)
        {
            string scene     = null;
            string loottable = null;

            string[] lines = File.ReadAllLines(path);
            foreach (string eachLine in lines)
            {
                var trimmedLine = GetTrimmedLine(eachLine);
                if (trimmedLine.Length == 0 || trimmedLine.StartsWith("#"))
                {
                    continue;
                }

                var match = SCENE_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    scene     = match.Groups[1].Value;
                    loottable = null;
                    continue;
                }

                match = SPAWN_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    if (string.IsNullOrEmpty(scene))
                    {
                        throw new System.ArgumentException("No scene name defined before line '" + eachLine + "' from '" + path + "'. Did you forget a 'scene = <SceneName>'?");
                    }

                    GearSpawnInfo info = new GearSpawnInfo();
                    info.PrefabName  = match.Groups[1].Value;
                    info.SpawnChance = ParseFloat(match.Groups[4].Value, 100, eachLine, path);
                    info.Position    = ParseVector(match.Groups[2].Value, eachLine, path);
                    info.Rotation    = Quaternion.Euler(ParseVector(match.Groups[3].Value, eachLine, path));

                    GearSpawner.AddGearSpawnInfo(scene, info);
                    continue;
                }

                match = LOOTTABLE_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    loottable = match.Groups[1].Value;
                    scene     = null;
                    continue;
                }

                match = LOOTTABLE_ENTRY_REGEX.Match(trimmedLine);
                if (match.Success)
                {
                    if (string.IsNullOrEmpty(loottable))
                    {
                        throw new System.ArgumentException("No loottable name defined before line '" + eachLine + "' from '" + path + "'. Did you forget a 'loottable = <LootTableName>'?");
                    }

                    LootTableEntry entry = new LootTableEntry();
                    entry.PrefabName = match.Groups[1].Value;
                    entry.Weight     = ParseInt(match.Groups[2].Value, 0, eachLine, path);
                    GearSpawner.AddLootTableEntry(loottable, entry);
                    continue;
                }

                throw new System.ArgumentException("Unrecognized line '" + eachLine + "' in '" + path + "'.");
            }
        }