Skip to content

Commit

Permalink
Pull building list from DF. Not doing anything with it yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Japa committed Jun 22, 2015
1 parent 124b6ef commit 1c40582
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 9 deletions.
6 changes: 1 addition & 5 deletions Assets/MapGen/ContentChosers/ItemConfiguration.cs
Expand Up @@ -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;
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions Assets/MapGen/DFConnection.cs
Expand Up @@ -58,6 +58,7 @@ public static void RegisterConnectionCallback(System.Action callback)
private RemoteFunction<dfproto.EmptyMessage, RemoteFortressReader.ViewInfo> viewInfoCall;
private RemoteFunction<dfproto.EmptyMessage, RemoteFortressReader.MapInfo> mapInfoCall;
private RemoteFunction<dfproto.EmptyMessage> mapResetCall;
private RemoteFunction<dfproto.EmptyMessage, RemoteFortressReader.BuildingList> buildingListCall;
private color_ostream dfNetworkOut = new color_ostream();
private RemoteClient networkClient;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -236,6 +246,8 @@ void BindMethods()
mapInfoCall.bind(networkClient, "GetMapInfo", "RemoteFortressReader");
mapResetCall = new RemoteFunction<dfproto.EmptyMessage>();
mapResetCall.bind(networkClient, "ResetMapHashes", "RemoteFortressReader");
buildingListCall = new RemoteFunction<dfproto.EmptyMessage, RemoteFortressReader.BuildingList>();
buildingListCall.bind(networkClient, "GetBuildingDefList", "RemoteFortressReader");
}

// Get information that only needs to be read once
Expand All @@ -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
Expand All @@ -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()
Expand Down
25 changes: 25 additions & 0 deletions Assets/MapGen/GameMap.cs
Expand Up @@ -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();

Expand Down Expand Up @@ -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<MaterialDefinition> list, string filename)
{
try
Expand Down
81 changes: 81 additions & 0 deletions Assets/RemoteClientDF/RemoteFortressReader.cs
Expand Up @@ -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<RemoteFortressReader.BuildingDefinition> _building_list = new global::System.Collections.Generic.List<RemoteFortressReader.BuildingDefinition>();
[global::ProtoBuf.ProtoMember(1, Name=@"building_list", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<RemoteFortressReader.BuildingDefinition> 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
{
Expand Down
16 changes: 12 additions & 4 deletions ProjectSettings/QualitySettings.asset
Expand Up @@ -4,7 +4,7 @@
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 5
m_CurrentQuality: 1
m_QualitySettings:
- serializedVersion: 2
name: Fastest
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 1c40582

Please sign in to comment.