From 1c40582a6fb18da28dfc1c92db199027ebf9a22a Mon Sep 17 00:00:00 2001 From: Japa Date: Mon, 22 Jun 2015 18:29:15 +0530 Subject: [PATCH] Pull building list from DF. Not doing anything with it yet. --- .../ContentChosers/ItemConfiguration.cs | 6 +- Assets/MapGen/DFConnection.cs | 15 ++++ Assets/MapGen/GameMap.cs | 25 ++++++ Assets/RemoteClientDF/RemoteFortressReader.cs | 81 +++++++++++++++++++ ProjectSettings/QualitySettings.asset | 16 +++- 5 files changed, 134 insertions(+), 9 deletions(-) diff --git a/Assets/MapGen/ContentChosers/ItemConfiguration.cs b/Assets/MapGen/ContentChosers/ItemConfiguration.cs index 164bb63f4..881c04996 100644 --- a/Assets/MapGen/ContentChosers/ItemConfiguration.cs +++ b/Assets/MapGen/ContentChosers/ItemConfiguration.cs @@ -24,11 +24,7 @@ protected override void ParseElementConditions(XElement elemtype, ContentConfigu XAttribute elemToken = elemItem.Attribute("token"); if (elemToken != null) { - if (elemToken.Value == "NONE") - defaultItem = content; - else - itemMatcher[elemToken.Value] = content; - continue; + itemMatcher[elemToken.Value] = content; } } } diff --git a/Assets/MapGen/DFConnection.cs b/Assets/MapGen/DFConnection.cs index aab3228bd..a6b0706d0 100644 --- a/Assets/MapGen/DFConnection.cs +++ b/Assets/MapGen/DFConnection.cs @@ -58,6 +58,7 @@ public static void RegisterConnectionCallback(System.Action callback) private RemoteFunction viewInfoCall; private RemoteFunction mapInfoCall; private RemoteFunction mapResetCall; + private RemoteFunction buildingListCall; private color_ostream dfNetworkOut = new color_ostream(); private RemoteClient networkClient; @@ -68,6 +69,7 @@ public static void RegisterConnectionCallback(System.Action callback) private RemoteFortressReader.MaterialList _netItemList; private RemoteFortressReader.TiletypeList _netTiletypeList; private RemoteFortressReader.MapInfo _netMapInfo; + private RemoteFortressReader.BuildingList _netBuildingList; // Changing (used like queues): private RemoteFortressReader.ViewInfo _netViewInfo; @@ -114,6 +116,14 @@ public RemoteFortressReader.TiletypeList NetTiletypeList return _netTiletypeList; } } + + public RemoteFortressReader.BuildingList NetBuildingList + { + get + { + return _netBuildingList; + } + } // Coordinates of the region we're pulling data from. // In block space - multiply x and y by 16 to get tile coordinates. public BlockCoord RequestRegionMin @@ -236,6 +246,8 @@ void BindMethods() mapInfoCall.bind(networkClient, "GetMapInfo", "RemoteFortressReader"); mapResetCall = new RemoteFunction(); mapResetCall.bind(networkClient, "ResetMapHashes", "RemoteFortressReader"); + buildingListCall = new RemoteFunction(); + buildingListCall.bind(networkClient, "GetBuildingDefList", "RemoteFortressReader"); } // Get information that only needs to be read once @@ -245,6 +257,7 @@ void FetchUnchangingInfo() itemListCall.execute(null, out _netItemList); tiletypeListCall.execute(null, out _netTiletypeList); mapInfoCall.execute(null, out _netMapInfo); + buildingListCall.execute(null, out _netBuildingList); } // Populate lists when we connect @@ -257,6 +270,8 @@ void InitStatics() MapDataStore.InitMainMap(_netMapInfo.block_size_x * 16, _netMapInfo.block_size_y * 16, _netMapInfo.block_size_z); Debug.Log("Materials fetched: " + _netMaterialList.material_list.Count); Debug.Log("Tiletypes fetched: " + _netTiletypeList.tiletype_list.Count); + Debug.Log("Itemtypes fetched: " + _netItemList.material_list.Count); + Debug.Log("Buildingtypes fetched: " + _netBuildingList.building_list.Count); } void Start() diff --git a/Assets/MapGen/GameMap.cs b/Assets/MapGen/GameMap.cs index 121157d94..3a8040775 100644 --- a/Assets/MapGen/GameMap.cs +++ b/Assets/MapGen/GameMap.cs @@ -186,6 +186,7 @@ void OnConnectToDF() SaveTileTypeList(); SaveMaterialList(DFConnection.Instance.NetMaterialList.material_list, "MaterialList.csv"); SaveMaterialList(DFConnection.Instance.NetItemList.material_list, "ItemList.csv"); + SaveBuildingList(); UpdateView(); @@ -349,6 +350,30 @@ void SaveTileTypeList() } } } + void SaveBuildingList() + { + try + { + File.Delete("BuildingList.csv"); + } + catch (IOException) + { + return; + } + using (StreamWriter writer = new StreamWriter("BuildingList.csv")) + { + foreach (var item in DFConnection.Instance.NetBuildingList.building_list) + { + writer.WriteLine( + item.name + ";" + + item.id + ";" + + item.building_type.building_type + ":" + + item.building_type.building_subtype + ":" + + item.building_type.building_custom + ); + } + } + } void SaveMaterialList(List list, string filename) { try diff --git a/Assets/RemoteClientDF/RemoteFortressReader.cs b/Assets/RemoteClientDF/RemoteFortressReader.cs index 771a20306..aa09f2c4c 100644 --- a/Assets/RemoteClientDF/RemoteFortressReader.cs +++ b/Assets/RemoteClientDF/RemoteFortressReader.cs @@ -332,6 +332,87 @@ public RemoteFortressReader.ColorDefinition state_color { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } } + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BuildingType")] + public partial class BuildingType : global::ProtoBuf.IExtensible + { + public BuildingType() {} + + private int _building_type; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"building_type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] + public int building_type + { + get { return _building_type; } + set { _building_type = value; } + } + private int _building_subtype; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"building_subtype", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] + public int building_subtype + { + get { return _building_subtype; } + set { _building_subtype = value; } + } + private int _building_custom; + [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"building_custom", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)] + public int building_custom + { + get { return _building_custom; } + set { _building_custom = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } + } + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BuildingDefinition")] + public partial class BuildingDefinition : global::ProtoBuf.IExtensible + { + public BuildingDefinition() {} + + private RemoteFortressReader.BuildingType _building_type; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"building_type", DataFormat = global::ProtoBuf.DataFormat.Default)] + public RemoteFortressReader.BuildingType building_type + { + get { return _building_type; } + set { _building_type = value; } + } + private string _id = ""; + [global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string id + { + get { return _id; } + set { _id = value; } + } + private string _name = ""; + [global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)] + [global::System.ComponentModel.DefaultValue("")] + public string name + { + get { return _name; } + set { _name = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } + } + + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BuildingList")] + public partial class BuildingList : global::ProtoBuf.IExtensible + { + public BuildingList() {} + + private readonly global::System.Collections.Generic.List _building_list = new global::System.Collections.Generic.List(); + [global::ProtoBuf.ProtoMember(1, Name=@"building_list", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List building_list + { + get { return _building_list; } + } + + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } + } + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"MaterialList")] public partial class MaterialList : global::ProtoBuf.IExtensible { diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 6eb4a6598..3c39a8ef6 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -4,7 +4,7 @@ QualitySettings: m_ObjectHideFlags: 0 serializedVersion: 5 - m_CurrentQuality: 5 + m_CurrentQuality: 1 m_QualitySettings: - serializedVersion: 2 name: Fastest @@ -17,7 +17,7 @@ QualitySettings: shadowCascade2Split: .333333343 shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} blendWeights: 1 - textureQuality: 1 + textureQuality: 2 anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 @@ -40,7 +40,7 @@ QualitySettings: shadowCascade2Split: .333333343 shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} blendWeights: 2 - textureQuality: 0 + textureQuality: 1 anisotropicTextures: 0 antiAliasing: 0 softParticles: 0 @@ -144,4 +144,12 @@ QualitySettings: maximumLODLevel: 0 particleRaycastBudget: 4096 excludedTargetPlatforms: [] - m_PerPlatformDefaultQuality: {} + m_PerPlatformDefaultQuality: + Android: 0 + BlackBerry: 0 + Standalone: 0 + WP8: 0 + Web: 0 + WebGL: 0 + Windows Store Apps: 0 + iPhone: 0