public ArkStructure(ArkWorld world, DotArkGameObject orig, StructureDisplayMetadata displayMetadata) : base(world, orig) { tribeId = GetInt32Property("TargetingTeam"); isInTribe = true; hasInventory = HasProperty("MyInventoryComponent"); this.displayMetadata = displayMetadata; if (HasProperty("CurrentItemCount")) { currentItemCount = GetInt32Property("CurrentItemCount"); } if (HasProperty("MaxItemCount")) { currentItemCount = GetInt32Property("MaxItemCount"); } if (HasProperty("Health")) { currentHealth = GetFloatProperty("Health"); } if (HasProperty("MaxHealth")) { maxHealth = GetFloatProperty("MaxHealth"); } }
/// <summary> /// Convert the map from a low-level object to a high-level object. /// </summary> /// <param name="savePath">The path to the folder housing the game data.</param> /// <param name="mapFileName">The name of the map file. For example, "Extinction" if you would like to load "Extinction.ark".</param> /// <param name="overrideMapData">Override the map data.</param> public ArkWorld(string savePath, string mapFileName, string configPath, ArkMapData overrideMapData = null, bool loadOnlyKnown = false) { //Read the config files configSettings = new ArkConfigSettings(); configSettings.ReadFromFile(File.ReadAllLines(configPath + "Game.ini")); configSettings.ReadFromFile(File.ReadAllLines(configPath + "GameUserSettings.ini")); //Open the .ark file now. string arkFileLocaton = Path.Combine(savePath, mapFileName + ".ark"); var arkFile = ArkSaveEditor.Deserializer.ArkSaveDeserializer.OpenDotArk(arkFileLocaton); //Loop through all .arkprofile files here and add them to the player list. string[] saveFilePaths = Directory.GetFiles(savePath); foreach (string profilePathname in saveFilePaths) { try { if (profilePathname.ToLower().EndsWith(".arkprofile")) { //This is an ARK profile. Open it. players.Add(ArkPlayerProfile.ReadFromFile(profilePathname)); } if (profilePathname.ToLower().EndsWith(".arktribe")) { //This is an ARK tribe. Open it. tribes.Add(new ArkTribeProfile(profilePathname, this)); } } catch (Exception ex) { Console.WriteLine($"Failed to load an Ark tribe or player at {profilePathname.Substring(savePath.Length)}. It will be skipped. This could result in errors!"); Console.WriteLine($"Error debug data: {ex.Message} - {ex.StackTrace}"); } } //Check to see if we have imported data. This will crash if we have not. if (ArkImports.dino_entries == null) { throw new Exception("Missing ArkImports.dino_entries! You should run ArkImports.ImportContent() to import the content."); } if (ArkImports.item_entries == null) { throw new Exception("Missing ArkImports.item_entries! You should run ArkImports.ImportContent() to import the content."); } if (ArkImports.world_settings == null) { throw new Exception("Missing ArkImports.world_settings! You should run ArkImports.ImportContent() to import the content."); } //Set our sources first sources = arkFile.gameObjects; //Do some analysis to find objects for (int i = 0; i < sources.Count; i++) { var g = sources[i]; string classname = g.classname.classname; bool known = false; //Check if this is a dinosaur by matching the classname. if (Enum.TryParse <DinoClasses>(classname, out DinoClasses dinoClass)) { //This is a dinosaur. dinos.Add(new ArkDinosaur(this, this.sources[i])); known = true; } //Check if this is a player if (classname == "PlayerPawnTest_Male_C" || classname == "PlayerPawnTest_Female_C") { //This is a player. playerCharacters.Add(new ArkPlayer(this, this.sources[i])); known = true; } //Check if this is a structure StructureDisplayMetadata metadata = ArkImports.GetStructureDisplayMetadataByClassname(classname); if (metadata != null) { //This is a structure. structures.Add(new ArkStructure(this, this.sources[i], metadata)); known = true; } } //Get the other metadata map = arkFile.meta.binaryDataNames[0]; gameTime = arkFile.gameTime; //If we got the override map data, set it. Else, auto detect if (overrideMapData == null) { //Autodetect if (ArkMapDataTable.arkmaps.ContainsKey(map)) { mapinfo = ArkMapDataTable.arkmaps[map]; } else { throw new Exception($"Ark map, '{map}', could not be found in the ArkMapDataTable. Please provide an override map data in the constructor for the ArkWorld."); } } else { mapinfo = overrideMapData; } }