Beispiel #1
0
        private WorldEntityInfo GetEntityInfo()
        {
            WorldEntityInfo newEntityInfo;

            if (WorldEntityDatabase.TryGetInfo(CraftData.GetClassIdForTechType(TechType.Seamoth), out WorldEntityInfo entityInfo))
            {
                newEntityInfo = new WorldEntityInfo()
                {
                    cellLevel  = entityInfo.cellLevel,
                    classId    = this.ClassID,
                    localScale = entityInfo.localScale,
                    prefabZUp  = entityInfo.prefabZUp,
                    slotType   = entityInfo.slotType,
                    techType   = this.TechType
                };

                return(newEntityInfo);
            }

            newEntityInfo = new WorldEntityInfo()
            {
                cellLevel  = LargeWorldEntity.CellLevel.Global,
                classId    = this.ClassID,
                localScale = Vector3.one,
                prefabZUp  = false,
                slotType   = EntitySlot.Type.Medium,
                techType   = this.TechType
            };

            return(newEntityInfo);
        }
        public void Patch()
        {
            UnlockSprite = GetItemSprite();

            TechType = TechTypeHandler.Main.AddTechType(TechTypeName, FriendlyName, string.Empty, UnlockSprite, false);

            PrefabHandler.Main.RegisterPrefab(this);

            LootDistributionData.SrcData srcData = new LootDistributionData.SrcData()
            {
                prefabPath   = $"{ClassID}_Prefab",
                distribution = GetBiomeDatas()
            };

            LootDistributionHandler.Main.AddLootDistributionData(ClassID, srcData);

            WorldEntityInfo EntityInfo = new WorldEntityInfo()
            {
                classId    = ClassID,
                techType   = TechType,
                slotType   = SlotType,
                prefabZUp  = PrefabZUp,
                cellLevel  = CellLevel,
                localScale = LocalScale
            };

            WorldEntityDatabaseHandler.Main.AddCustomInfo(ClassID, EntityInfo);
        }
Beispiel #3
0
        /**
         * Hacky implementation that parses the user-exported version of the WorldEntityData
         * resource (seen in UWE code via WorldEntityDatabase).  This file is primarily used
         * to surface the tuple classId, techType, and slotType.... these elements are later
         * used to join on loot distribution data to figure out where entities spawn.  We will
         * eventually want to replace this implementation with something that can automatically
         * mine this data from the subnautica resources.assets file.
         */
        public Dictionary <string, WorldEntityInfo> GetWorldEntitiesByClassId()
        {
            Dictionary <string, WorldEntityInfo> worldEntitiesByClassId = new Dictionary <string, WorldEntityInfo>();
            string file = Path.GetFullPath(@"..\..\..\raw\worlddata.txt");

            using (StreamReader reader = File.OpenText(file))
            {
                string          line;
                int             counter        = 0;
                WorldEntityInfo nextEntityInfo = null;
                while ((line = reader.ReadLine()) != null)
                {
                    string[] items = line.Split(' ');

                    switch (counter)
                    {
                    case 0:
                        nextEntityInfo = new WorldEntityInfo();
                        break;

                    case 1:
                        nextEntityInfo.classId = items[1];
                        worldEntitiesByClassId[nextEntityInfo.classId] = nextEntityInfo;
                        break;

                    case 2:
                        nextEntityInfo.techType = (TechType)Enum.Parse(typeof(TechType), items[1]);
                        break;

                    case 3:
                        nextEntityInfo.slotType = (EntitySlot.Type)Enum.Parse(typeof(EntitySlot.Type), items[1]);
                        break;

                    case 4:
                        nextEntityInfo.prefabZUp = bool.Parse(items[1]);
                        break;

                    case 5:
                        nextEntityInfo.cellLevel = (LargeWorldEntity.CellLevel)Enum.Parse(typeof(LargeWorldEntity.CellLevel), items[1]);
                        break;

                    case 6:
                        string[] dimensions = items[1].Split('-');
                        nextEntityInfo.localScale = new UnityEngine.Vector3(float.Parse(dimensions[0]), float.Parse(dimensions[1]), float.Parse(dimensions[2]));
                        break;
                    }

                    counter++;

                    if (counter == 7)
                    {
                        counter = 0;
                    }
                }
            }

            return(worldEntitiesByClassId);
        }
Beispiel #4
0
        void IWorldEntityDatabaseHandler.AddCustomInfo(string classId, WorldEntityInfo data)
        {
            if (WorldEntityDatabasePatcher.CustomWorldEntityInfos.ContainsKey(classId))
            {
                V2.Logger.Log($"{classId}-{data.techType} already has custom WorldEntityInfo. Replacing with latest.", LogLevel.Debug);
            }

            WorldEntityDatabasePatcher.CustomWorldEntityInfos[classId] = data;
        }
        public static ResourceAssets Parse()
        {
            ResourceAssets resourceAssets = new ResourceAssets();

            using (FileStream resStream = new FileStream(FindPath(), FileMode.Open))
                using (AssetsFileReader resReader = new AssetsFileReader(resStream))
                {
                    AssetsFile      resourcesFile      = new AssetsFile(resReader);
                    AssetsFileTable resourcesFileTable = new AssetsFileTable(resourcesFile);
                    foreach (AssetFileInfoEx afi in resourcesFileTable.pAssetFileInfo)
                    {
                        if (afi.curFileType == TEXT_CLASS_ID)
                        {
                            resourcesFile.reader.Position = afi.absoluteFilePos;
                            string assetName = resourcesFile.reader.ReadCountStringInt32();
                            if (assetName == "EntityDistributions")
                            {
                                resourcesFile.reader.Align();
                                resourceAssets.LootDistributionsJson = resourcesFile.reader.ReadCountStringInt32().Replace("\\n", "");
                            }
                        }
                        else if (afi.curFileType == MONOBEHAVIOUR_CLASS_ID)
                        {
                            resourcesFile.reader.Position  = afi.absoluteFilePos;
                            resourcesFile.reader.Position += 28;
                            string assetName = resourcesFile.reader.ReadCountStringInt32();
                            if (assetName == "WorldEntityData")
                            {
                                resourcesFile.reader.Align();
                                uint            size = resourcesFile.reader.ReadUInt32();
                                WorldEntityInfo wei;
                                for (int i = 0; i < size; i++)
                                {
                                    wei           = new WorldEntityInfo();
                                    wei.classId   = resourcesFile.reader.ReadCountStringInt32();
                                    wei.techType  = (TechType)resourcesFile.reader.ReadInt32();
                                    wei.slotType  = (EntitySlot.Type)resourcesFile.reader.ReadInt32();
                                    wei.prefabZUp = resourcesFile.reader.ReadBoolean();
                                    resourcesFile.reader.Align();
                                    wei.cellLevel  = (LargeWorldEntity.CellLevel)resourcesFile.reader.ReadInt32();
                                    wei.localScale = new UnityEngine.Vector3(resourcesFile.reader.ReadSingle(), resourcesFile.reader.ReadSingle(), resourcesFile.reader.ReadSingle());
                                    resourceAssets.WorldEntitiesByClassId.Add(wei.classId, wei);
                                }
                            }
                        }
                    }
                }

            Validate.IsTrue(resourceAssets.WorldEntitiesByClassId.Count > 0);
            Validate.IsTrue(resourceAssets.LootDistributionsJson != "");

            return(resourceAssets);
        }
Beispiel #6
0
        private static bool Prefix(string classId, ref WorldEntityInfo info, ref bool __result)
        {
            foreach (KeyValuePair <string, WorldEntityInfo> entry in CustomWorldEntityInfos)
            {
                if (entry.Key == classId)
                {
                    __result = true;
                    info     = entry.Value;
                    return(false);
                }
            }

            return(true);
        }
Beispiel #7
0
        private WorldEntityInfo GetWEI()
        {
            WorldEntityInfo worldEntityInfo = new WorldEntityInfo()
            {
                classId    = ClassID,
                techType   = TechType,
                cellLevel  = LargeWorldEntity.CellLevel.Medium,
                localScale = new Vector3(1f, 1f, 1f),
                prefabZUp  = false,
                slotType   = EntitySlot.Type.Small
            };

            return(worldEntityInfo);
        }
Beispiel #8
0
 private bool IsValidSpawnType(string id, bool creatureSpawn)
 {
     if (worldEntitiesByClassId.ContainsKey(id))
     {
         WorldEntityInfo worldEntityInfo = worldEntitiesByClassId[id];
         if (creatureSpawn && worldEntityInfo.slotType == EntitySlot.Type.Creature)
         {
             return(true);
         }
         else if (!creatureSpawn && worldEntityInfo.slotType != EntitySlot.Type.Creature)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #9
0
        public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjectIdentifier, AssetsFileReader reader, ResourceAssets resourceAssets, Dictionary <int, string> relativeFileIdToPath)
        {
            reader.Align();
            uint            size = reader.ReadUInt32();
            WorldEntityInfo wei;

            for (int i = 0; i < size; i++)
            {
                wei           = new WorldEntityInfo();
                wei.classId   = reader.ReadCountStringInt32();
                wei.techType  = (TechType)reader.ReadInt32();
                wei.slotType  = (EntitySlot.Type)reader.ReadInt32();
                wei.prefabZUp = reader.ReadBoolean();

                reader.Align();

                wei.cellLevel  = (LargeWorldEntity.CellLevel)reader.ReadInt32();
                wei.localScale = new UnityEngine.Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                resourceAssets.WorldEntitiesByClassId.Add(wei.classId, wei);
            }
        }
Beispiel #10
0
        private IEnumerator PatchAsync()
        {
            while (!SpriteManager.hasInitialized)
            {
                BZLogger.Debug($"{TechTypeName} : Spritemanager is not ready!");
                yield return(null);
            }

            BZLogger.Debug($"{TechTypeName} : Async patch started.");

            UnlockSprite = GetUnlockSprite();

            SpriteHandler.Main.RegisterSprite(TechType, UnlockSprite);

            PrefabHandler.Main.RegisterPrefab(this);

            LootDistributionData.SrcData srcData = new LootDistributionData.SrcData()
            {
                prefabPath   = VirtualPrefabFilename,
                distribution = GetBiomeDatas()
            };

            LootDistributionHandler.Main.AddLootDistributionData(ClassID, srcData);

            WorldEntityInfo EntityInfo = new WorldEntityInfo()
            {
                classId    = ClassID,
                techType   = TechType,
                slotType   = SlotType,
                prefabZUp  = PrefabZUp,
                cellLevel  = CellLevel,
                localScale = LocalScale
            };

            WorldEntityDatabaseHandler.Main.AddCustomInfo(ClassID, EntityInfo);
        }
Beispiel #11
0
        private static void InventoryAndWaterParkSetup()
        {
            // Setting a name for the Rockgrub
            LanguageHandler.SetTechTypeName(TechType.Rockgrub, "Rockgrub");
            // Setting a Tooltip for the Rockgrub
            LanguageHandler.SetTechTypeTooltip(TechType.Rockgrub, "A small, luminescent scavenger");

            // Setting a Sprite for the Rockgrub
            Sprite rockgrub = ImageUtils.LoadSpriteFromFile(Path.Combine(AssetsFolder, "RockGrub.png"));

            if (rockgrub != null)
            {
                SpriteHandler.RegisterSprite(TechType.Rockgrub, rockgrub);
            }
            // Setting Rockgrub's size in the Inventory
            CraftDataHandler.SetItemSize(TechType.Rockgrub, new Vector2int(1, 1));
            // Setting WPC Parameters for Rockgrub so it can grow and breed normaly
            WaterParkCreature.waterParkCreatureParameters[TechType.Rockgrub] = new WaterParkCreatureParameters(0.03f, 0.7f, 1f, 1f);
            // Setting Fuel value for the Rockgrub
            BioReactorHandler.SetBioReactorCharge(TechType.Rockgrub, 350f);
            // Totally origina.. *cough* taken from MrPurple's CYS code
            #region BiomeData stuff
            Dictionary <TechType, List <BiomeData> > rockgrubBiomeData = new Dictionary <TechType, List <BiomeData> >()
            {
                {
                    TechType.Rockgrub,
                    new List <BiomeData>()
                    {
                        new BiomeData()
                        {
                            biome       = BiomeType.SafeShallows_CaveSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveCeiling,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_CaveRecess,
                            count       = 5,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_CaveSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_GiantTreeInteriorRecess,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.MushroomForest_GiantTreeInteriorSpecial,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.KooshZone_CaveWall,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.SparseReef_DeepWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveCeiling,
                            count       = 3,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_Rock,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_SandPlateau,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_CaveCeiling,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Dunes_CaveWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.Mountains_CaveWall,
                            count       = 4,
                            probability = 1f
                        },
                        new BiomeData()
                        {
                            biome       = BiomeType.GrassyPlateaus_CaveFloor,
                            count       = 4,
                            probability = 1f
                        },
                    }
                }
            };
            foreach (KeyValuePair <TechType, List <BiomeData> > pair in rockgrubBiomeData)
            {
                string classId = CraftData.GetClassIdForTechType(pair.Key) ?? pair.Key.AsString();
                if (PrefabDatabase.TryGetPrefabFilename(classId, out string prefabpath))
                {
                    if (!WorldEntityDatabase.TryGetInfo(classId, out WorldEntityInfo info))
                    {
                        info = new WorldEntityInfo()
                        {
                            cellLevel  = LargeWorldEntity.CellLevel.Medium,
                            classId    = classId,
                            localScale = UnityEngine.Vector3.one,
                            prefabZUp  = false,
                            slotType   = EntitySlot.Type.Medium,
                            techType   = pair.Key
                        };
                    }
                    WorldEntityDatabaseHandler.AddCustomInfo(classId, info);
                }
                SrcData data = new SrcData()
                {
                    prefabPath = prefabpath, distribution = pair.Value
                };
                LootDistributionHandler.AddLootDistributionData(classId, data);
            }
            #endregion
        }
Beispiel #12
0
        private void SpawnEntities()
        {
            Log.Info("Spawning entities...");
            entitiesByAbsoluteCell = new Dictionary <AbsoluteEntityCell, List <Entity> >();
            Random random = new Random();

            foreach (EntitySpawnPoint entitySpawnPoint in entitySpawnPoints)
            {
                DstData dstData;
                if (!lootDistributionData.GetBiomeLoot(entitySpawnPoint.BiomeType, out dstData))
                {
                    continue;
                }

                float rollingProbabilityDensity = 0;

                PrefabData selectedPrefab = null;

                foreach (PrefabData prefab in dstData.prefabs)
                {
                    float probabilityDensity = prefab.probability / entitySpawnPoint.Density;
                    rollingProbabilityDensity += probabilityDensity;
                }
                double randomNumber       = random.NextDouble();
                double rollingProbability = 0;

                if (rollingProbabilityDensity > 0)
                {
                    if (rollingProbabilityDensity > 1f)
                    {
                        randomNumber *= rollingProbabilityDensity;
                    }

                    foreach (PrefabData prefab in dstData.prefabs)
                    {
                        float probabilityDensity = prefab.probability / entitySpawnPoint.Density;
                        rollingProbability += probabilityDensity;
                        if (rollingProbability >= randomNumber)
                        {
                            selectedPrefab = prefab;
                            break;
                        }
                    }
                }

                if (!ReferenceEquals(selectedPrefab, null) && worldEntitiesByClassId.ContainsKey(selectedPrefab.classId))
                {
                    WorldEntityInfo worldEntityInfo = worldEntitiesByClassId[selectedPrefab.classId];

                    for (int i = 0; i < selectedPrefab.count; i++)
                    {
                        Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                                          worldEntityInfo.techType,
                                                          Guid.NewGuid().ToString(),
                                                          (int)worldEntityInfo.cellLevel);

                        AbsoluteEntityCell absoluteCellId = new AbsoluteEntityCell(entitySpawnPoint.BatchId, entitySpawnPoint.CellId);

                        if (!entitiesByAbsoluteCell.ContainsKey(absoluteCellId))
                        {
                            entitiesByAbsoluteCell[absoluteCellId] = new List <Entity>();
                        }

                        entitiesByAbsoluteCell[absoluteCellId].Add(spawnedEntity);
                    }
                }
            }
        }
        /// <summary>
        /// Adds in a custom entry into the Loot Distribution of the game.
        /// You must also add the <see cref="WorldEntityInfo"/> into the <see cref="WorldEntityDatabase"/> using <see cref="WorldEntityDatabaseHandler"/>.
        /// </summary>
        /// <param name="data">The <see cref="LootDistributionData.SrcData"/> that contains data related to the spawning of a prefab, also contains the path to the prefab.</param>
        /// <param name="classId">The classId of the prefab.</param>
        /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
        void ILootDistributionHandler.AddLootDistributionData(string classId, LootDistributionData.SrcData data, WorldEntityInfo info)
        {
            Main.AddLootDistributionData(classId, data);

            WorldEntityDatabaseHandler.AddCustomInfo(classId, info);
        }
 void IWorldEntityDatabaseHandler.AddCustomInfo(string classId, WorldEntityInfo data)
 {
     WorldEntityDatabasePatcher.CustomWorldEntityInfos.Add(classId, data);
 }
        }                                        // Hides constructor

        /// <summary>
        /// Adds in a custom <see cref="WorldEntityInfo"/> to the <see cref="WorldEntityDatabase"/> of the game.
        /// It contains information about the entity, like its <see cref="LargeWorldEntity.CellLevel"/>, its <see cref="EntitySlot.Type"/>, etc.
        /// </summary>
        /// <param name="classId">The classID of the entity whose data you are adding in.</param>
        /// <param name="data">The <see cref="WorldEntityInfo"/> data. Data is stored in the fields of the class, so they must be populated when passed in.</param>
        public static void AddCustomInfo(string classId, WorldEntityInfo data)
        {
            Main.AddCustomInfo(classId, data);
        }
        /// <summary>
        /// Adds in a custom entry into the Loot Distribution of the game.
        /// </summary>
        /// <param name="classId">The classId of the prefab.</param>
        /// <param name="prefabPath">The prefab path of the prefab.</param>
        /// <param name="biomeDistribution">The <see cref="LootDistributionData.BiomeData"/> dictating how the prefab should spawn in the world.</param>
        /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
        void ILootDistributionHandler.AddLootDistributionData(string classId, string prefabPath, IEnumerable <LootDistributionData.BiomeData> biomeDistribution, WorldEntityInfo info)
        {
            Main.AddLootDistributionData(classId, new LootDistributionData.SrcData()
            {
                distribution = new List <LootDistributionData.BiomeData>(biomeDistribution),
                prefabPath   = prefabPath
            });

            WorldEntityDatabaseHandler.AddCustomInfo(classId, info);
        }
Beispiel #17
0
        private void SpawnEntities()
        {
            Log.Info("Spawning entities...");
            entitiesByAbsoluteCell = new Dictionary <AbsoluteEntityCell, List <Entity> >();
            Random random = new Random();

            foreach (EntitySpawnPoint entitySpawnPoint in entitySpawnPoints)
            {
                DstData dstData;
                if (!lootDistributionData.GetBiomeLoot(entitySpawnPoint.BiomeType, out dstData))
                {
                    continue;
                }

                float rollingProbabilityDensity = 0;

                PrefabData selectedPrefab = null;

                foreach (PrefabData prefab in dstData.prefabs)
                {
                    float probabilityDensity = prefab.probability / entitySpawnPoint.Density;
                    rollingProbabilityDensity += probabilityDensity;
                }
                double randomNumber       = random.NextDouble();
                double rollingProbability = 0;

                if (rollingProbabilityDensity > 0)
                {
                    if (rollingProbabilityDensity > 1f)
                    {
                        randomNumber *= rollingProbabilityDensity;
                    }

                    foreach (PrefabData prefab in dstData.prefabs)
                    {
                        float probabilityDensity = prefab.probability / entitySpawnPoint.Density;
                        rollingProbability += probabilityDensity;
                        //This is pretty hacky, it rerolls until its hits a prefab of a correct type
                        //What should happen is that we check wei first, then grab data from there
                        bool isValidSpawn = IsValidSpawnType(prefab.classId, entitySpawnPoint.CanSpawnCreature);
                        if (rollingProbability >= randomNumber && isValidSpawn)
                        {
                            selectedPrefab = prefab;
                            break;
                        }
                    }
                }

                if (!ReferenceEquals(selectedPrefab, null) && worldEntitiesByClassId.ContainsKey(selectedPrefab.classId))
                {
                    WorldEntityInfo worldEntityInfo = worldEntitiesByClassId[selectedPrefab.classId];

                    for (int i = 0; i < selectedPrefab.count; i++)
                    {
                        Entity spawnedEntity = new Entity(entitySpawnPoint.Position,
                                                          entitySpawnPoint.Rotation,
                                                          worldEntityInfo.techType,
                                                          Guid.NewGuid().ToString(),
                                                          (int)worldEntityInfo.cellLevel);

                        AbsoluteEntityCell absoluteCellId = new AbsoluteEntityCell(entitySpawnPoint.BatchId, entitySpawnPoint.CellId);

                        if (!entitiesByAbsoluteCell.ContainsKey(absoluteCellId))
                        {
                            entitiesByAbsoluteCell[absoluteCellId] = new List <Entity>();
                        }

                        entitiesByAbsoluteCell[absoluteCellId].Add(spawnedEntity);
                    }
                }
            }
        }
Beispiel #18
0
        private bool GetDataFiles(out string lootDistributions, out Dictionary <string, WorldEntityInfo> worldEntityData)
        {
            lootDistributions = "";
            worldEntityData   = new Dictionary <string, WorldEntityInfo>();
            string            resourcesPath     = "";
            Optional <string> steamPath         = SteamFinder.FindSteamGamePath(264710, "Subnautica");
            string            gameResourcesPath = "";

            if (!steamPath.IsEmpty())
            {
                gameResourcesPath = Path.Combine(steamPath.Get(), "Subnautica_Data/resources.assets");
            }
            if (File.Exists(gameResourcesPath))
            {
                resourcesPath = gameResourcesPath;
            }
            else if (File.Exists("../resources.assets"))
            {
                resourcesPath = Path.GetFullPath("../resources.assets");
            }
            else if (File.Exists("resources.assets"))
            {
                resourcesPath = Path.GetFullPath("resources.assets");
            }
            else
            {
                throw new FileNotFoundException("Make sure resources.assets is in current or parent directory and readable.");
            }

            using (FileStream resStream = new FileStream(resourcesPath, FileMode.Open))
                using (AssetsFileReader resReader = new AssetsFileReader(resStream))
                {
                    AssetsFile      resourcesFile      = new AssetsFile(resReader);
                    AssetsFileTable resourcesFileTable = new AssetsFileTable(resourcesFile);
                    foreach (AssetFileInfoEx afi in resourcesFileTable.pAssetFileInfo)
                    {
                        if (afi.curFileType == TEXT_CLASS_ID)
                        {
                            resourcesFile.reader.Position = afi.absoluteFilePos;
                            string assetName = resourcesFile.reader.ReadCountStringInt32();
                            if (assetName == "EntityDistributions")
                            {
                                resourcesFile.reader.Align();
                                lootDistributions = resourcesFile.reader.ReadCountStringInt32().Replace("\\n", "");
                            }
                        }
                        else if (afi.curFileType == MONOBEHAVIOUR_CLASS_ID)
                        {
                            resourcesFile.reader.Position  = afi.absoluteFilePos;
                            resourcesFile.reader.Position += 28;
                            string assetName = resourcesFile.reader.ReadCountStringInt32();
                            if (assetName == "WorldEntityData")
                            {
                                resourcesFile.reader.Align();
                                uint            size = resourcesFile.reader.ReadUInt32();
                                WorldEntityInfo wei;
                                for (int i = 0; i < size; i++)
                                {
                                    wei           = new WorldEntityInfo();
                                    wei.classId   = resourcesFile.reader.ReadCountStringInt32();
                                    wei.techType  = (TechType)resourcesFile.reader.ReadInt32();
                                    wei.slotType  = (EntitySlot.Type)resourcesFile.reader.ReadInt32();
                                    wei.prefabZUp = resourcesFile.reader.ReadBoolean();
                                    resourcesFile.reader.Align();
                                    wei.cellLevel  = (LargeWorldEntity.CellLevel)resourcesFile.reader.ReadInt32();
                                    wei.localScale = new UnityEngine.Vector3(resourcesFile.reader.ReadSingle(), resourcesFile.reader.ReadSingle(), resourcesFile.reader.ReadSingle());
                                    worldEntityData.Add(wei.classId, wei);
                                }
                            }
                        }
                    }
                }
            return(true);
        }
        /// <summary>
        /// Adds in a custom entry into the Loot Distribution of the game.
        /// </summary>
        /// <param name="prefab">The custom prefab which you want to spawn naturally in the game.</param>
        /// <param name="biomeDistribution">The <see cref="LootDistributionData.BiomeData"/> dictating how the prefab should spawn in the world.</param>
        /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
        void ILootDistributionHandler.AddLootDistributionData(ModPrefab prefab, IEnumerable <LootDistributionData.BiomeData> biomeDistribution, WorldEntityInfo info)
        {
            Main.AddLootDistributionData(prefab.ClassID, prefab.PrefabFileName, biomeDistribution);

            WorldEntityDatabaseHandler.AddCustomInfo(prefab.ClassID, info);
        }
 /// <summary>
 /// Adds in a custom entry into the Loot Distribution of the game.
 /// You must also add the <see cref="WorldEntityInfo"/> into the <see cref="WorldEntityDatabase"/> using <see cref="WorldEntityDatabaseHandler"/>.
 /// </summary>
 /// <param name="data">The <see cref="LootDistributionData.SrcData"/> that contains data related to the spawning of a prefab, also contains the path to the prefab.</param>
 /// <param name="classId">The classId of the prefab.</param>
 /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
 public static void AddLootDistributionData(string classId, LootDistributionData.SrcData data, WorldEntityInfo info)
 {
     Main.AddLootDistributionData(classId, data, info);
 }
 /// <summary>
 /// Adds in a custom entry into the Loot Distribution of the game.
 /// You must also add the <see cref="WorldEntityInfo"/> into the <see cref="WorldEntityDatabase"/> using <see cref="WorldEntityDatabaseHandler"/>.
 /// </summary>
 /// <param name="classId">The classId of the prefab.</param>
 /// <param name="prefabPath">The prefab path of the prefab.</param>
 /// <param name="biomeDistribution">The <see cref="LootDistributionData.BiomeData"/> dictating how the prefab should spawn in the world.</param>
 /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
 public static void AddLootDistributionData(string classId, string prefabPath, IEnumerable <LootDistributionData.BiomeData> biomeDistribution, WorldEntityInfo info)
 {
     Main.AddLootDistributionData(classId, prefabPath, biomeDistribution, info);
 }
 /// <summary>
 /// Adds in a custom entry into the Loot Distribution of the game.
 /// You must also add the <see cref="WorldEntityInfo"/> into the <see cref="WorldEntityDatabase"/> using <see cref="WorldEntityDatabaseHandler"/>.
 /// </summary>
 /// <param name="prefab">The custom prefab which you want to spawn naturally in the game.</param>
 /// <param name="biomeDistribution">The <see cref="LootDistributionData.BiomeData"/> dictating how the prefab should spawn in the world.</param>
 /// <param name="info">The WorldEntityInfo of the prefab. For more information on how to set this up, see <see cref="WorldEntityDatabaseHandler"/>.</param>
 public static void AddLootDistributionData(ModPrefab prefab, IEnumerable <LootDistributionData.BiomeData> biomeDistribution, WorldEntityInfo info)
 {
     Main.AddLootDistributionData(prefab, biomeDistribution, info);
 }