/// <summary> /// Populate lists when we connect. /// </summary> void InitStatics() { if (netMaterialList != null) { MaterialTokenList.MaterialTokens = netMaterialList.material_list; Debug.Log("Materials fetched: " + netMaterialList.material_list.Count); } if (netTiletypeList != null) { TiletypeTokenList.tiletypeTokenList = netTiletypeList.tiletype_list; Debug.Log("Tiletypes fetched: " + netTiletypeList.tiletype_list.Count); } if (netItemList != null) { ItemTokenList.ItemTokens = netItemList.material_list; Debug.Log("Itemtypes fetched: " + netItemList.material_list.Count); } else { RemoteFortressReader.MaterialDefinition blankMaterial = new RemoteFortressReader.MaterialDefinition(); blankMaterial.id = "NONE"; blankMaterial.name = "NONE"; blankMaterial.mat_pair = new RemoteFortressReader.MatPair(); blankMaterial.mat_pair.mat_type = -1; blankMaterial.mat_pair.mat_index = -1; List <RemoteFortressReader.MaterialDefinition> blankItemList = new List <RemoteFortressReader.MaterialDefinition>(); blankItemList.Add(blankMaterial); ItemTokenList.ItemTokens = blankItemList; Debug.Log("Created dummy Itemtype list."); } if (netBuildingList != null) { BuildingTokenList.BuildingTokens = netBuildingList.building_list; Debug.Log("Buildingtypes fetched: " + netBuildingList.building_list.Count); } if (netTiletypeList != null) { MapDataStore.tiletypeTokenList = netTiletypeList.tiletype_list; Debug.Log("Tiletypes fetched: " + netTiletypeList.tiletype_list.Count); } if (netPlantRawList != null) { PlantTokenList.PlantRawList = netPlantRawList.plant_raws; Debug.Log("Plant Raws fetched: " + netPlantRawList.plant_raws.Count); } ContentLoader.Instance = new ContentLoader(); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); ContentLoader.Instance.ParseContentIndexFile(Application.streamingAssetsPath + "/index.txt"); ContentLoader.Instance.FinalizeTextureAtlases(); watch.Stop(); Debug.Log("Took a total of " + watch.ElapsedMilliseconds + "ms to load all XML files."); //Debug.Log("Buildingtypes fetched: " + netBuildingList.building_list.Count); //Debug.Log("Creature Raws fetched: " + netCreatureRawList.creature_raws.Count); }
/// <summary> /// Populate lists when we connect. /// </summary> void InitStatics() { if (netMaterialList != null) { MaterialTokenList.MaterialTokens = netMaterialList.material_list; Debug.Log("Materials fetched: " + netMaterialList.material_list.Count); } if (netTiletypeList != null) { TiletypeTokenList.tiletypeTokenList = netTiletypeList.tiletype_list; Debug.Log("Tiletypes fetched: " + netTiletypeList.tiletype_list.Count); } if (netItemList != null) { ItemTokenList.ItemTokens = netItemList.material_list; Debug.Log("Itemtypes fetched: " + netItemList.material_list.Count); } else { RemoteFortressReader.MaterialDefinition blankMaterial = new RemoteFortressReader.MaterialDefinition(); blankMaterial.id = "NONE"; blankMaterial.name = "NONE"; blankMaterial.mat_pair = new RemoteFortressReader.MatPair(); blankMaterial.mat_pair.mat_type = -1; blankMaterial.mat_pair.mat_index = -1; List <RemoteFortressReader.MaterialDefinition> blankItemList = new List <RemoteFortressReader.MaterialDefinition>(); blankItemList.Add(blankMaterial); ItemTokenList.ItemTokens = blankItemList; Debug.Log("Created dummy Itemtype list."); } if (netBuildingList != null) { BuildingTokenList.BuildingTokens = netBuildingList.building_list; Debug.Log("Buildingtypes fetched: " + netBuildingList.building_list.Count); } if (netTiletypeList != null) { MapDataStore.tiletypeTokenList = netTiletypeList.tiletype_list; Debug.Log("Tiletypes fetched: " + netTiletypeList.tiletype_list.Count); } if (netPlantRawList != null) { PlantTokenList.PlantRawList = netPlantRawList.plant_raws; Debug.Log("Plant Raws fetched: " + netPlantRawList.plant_raws.Count); } if (netCreatureRawList != null) { CreatureTokenList.CreatureRawList = netCreatureRawList.creature_raws; Debug.Log("Creature Raws fetched: " + netCreatureRawList.creature_raws.Count); } //Debug.Log("Buildingtypes fetched: " + netBuildingList.building_list.Count); //Debug.Log("Creature Raws fetched: " + netCreatureRawList.creature_raws.Count); }
static void AddMat(string prefix, string word, string suffix, MaterialDefinition token) { if (_tripleWords == null) _tripleWords = new Dictionary<string, Dictionary<string, Dictionary<string, MaterialDefinition>>>(); if (!_tripleWords.ContainsKey(prefix)) _tripleWords[prefix] = new Dictionary<string, Dictionary<string, MaterialDefinition>>(); if (!_tripleWords[prefix].ContainsKey(suffix)) _tripleWords[prefix][suffix] = new Dictionary<string, MaterialDefinition>(); _tripleWords[prefix][suffix][word] = token; }
void PrintFullMaterialList() { int limit = connectionState.net_material_list.material_list.Count; if (limit >= 100) { limit = 100; } //Don't ever do this. for (int i = connectionState.net_material_list.material_list.Count - limit; i < connectionState.net_material_list.material_list.Count; i++) { //no really, don't. RemoteFortressReader.MaterialDefinition material = connectionState.net_material_list.material_list[i]; Debug.Log("{" + material.mat_pair.mat_index + "," + material.mat_pair.mat_type + "}, " + material.id + ", " + material.name); } }
void OnConnectToDF() { Debug.Log("Connected"); enabled = true; mesher = BlockMesher.GetMesher(meshingThreads); // Initialize materials, if available if (DFConnection.Instance.NetMaterialList != null) { if (materials == null) materials = new Dictionary<MatPairStruct, RemoteFortressReader.MaterialDefinition>(); materials.Clear(); foreach (RemoteFortressReader.MaterialDefinition material in DFConnection.Instance.NetMaterialList.material_list) { materials[material.mat_pair] = material; } SaveMaterialList(materials, "MaterialList.csv"); } // Initialize items, if available if (DFConnection.Instance.NetItemList != null) { if (items == null) items = new Dictionary<MatPairStruct, RemoteFortressReader.MaterialDefinition>(); items.Clear(); foreach (MaterialDefinition material in DFConnection.Instance.NetItemList.material_list) { items[material.mat_pair] = material; } SaveMaterialList(items, "ItemList.csv"); } if (DFConnection.Instance.NetBuildingList != null) { if (buildings == null) buildings = new Dictionary<BuildingStruct, BuildingDefinition>(); buildings.Clear(); foreach (BuildingDefinition building in DFConnection.Instance.NetBuildingList.building_list) { buildings[building.building_type] = building; } SaveBuildingList(); } if (DFConnection.Instance.NetCreatureRawList != null) { if (creatures == null) creatures = new Dictionary<MatPairStruct, MaterialDefinition>(); foreach (CreatureRaw creatureRaw in DFConnection.Instance.NetCreatureRawList.creature_raws) { foreach (var caste in creatureRaw.caste) { MatPairStruct creatureCaste = new MatPairStruct(creatureRaw.index, caste.index); MaterialDefinition creatureDef = new MaterialDefinition(); creatureDef.mat_pair = creatureCaste; creatureDef.id = creatureRaw.creature_id + ":" + caste.caste_id; creatureDef.name = caste.caste_name[0]; creatureDef.state_color = creatureRaw.color; creatures[creatureCaste] = creatureDef; } } SaveMaterialList(creatures, "CreatureList.csv"); } SaveTileTypeList(); UpdateView(); blockListTimer.Start(); cullTimer.Start(); lazyLoadTimer.Start(); InitializeBlocks(); }