public UrbTileData GetTileData() { UrbTileData output = new UrbTileData(); if (Links.Length > 0) { List <UrbTileLinkData> WorkingList = new List <UrbTileLinkData>(); foreach (var link in Links) { if (link == null) { continue; } UrbTileLinkData TempLink = new UrbTileLinkData(); TempLink.MapID = UrbSystemIO.GetMapID(link.OwningMap); TempLink.X = link.XAddress; TempLink.Y = link.YAddress; WorkingList.Add(TempLink); } output.Links = WorkingList.ToArray(); } else { output.Links = new UrbTileLinkData[0]; } if (Contents.Count > 0) { output.Contents = new int[Contents.Count]; output.Objects = new UrbObjectData[Contents.Count]; for (int c = 0; c < Contents.Count; c++) { output.Contents[c] = UrbSystemIO.GetAgentID(Contents[c]); output.Objects[c] = UrbEncoder.Read(Contents[c].gameObject); } } else { output.Contents = new int[0]; } output.Blocked = Blocked; output.Environment = Environment.GetEnvironmentData(); return(output); }
public bool LoadTileFromData(UrbTileData input) { LinksDirty = true; if (input.Links.Length > 0) { Links = new UrbTile[input.Links.Length]; for (int i = 0; i < Links.Length; i++) { UrbMap LinkedMap = UrbSystemIO.GetMapFromID(input.Links[i].MapID); if (LinkedMap != null) { UrbTile LinkedTile = LinkedMap.GetTile(input.Links[i].X, input.Links[i].Y); Links[i] = LinkedTile; } } } else { Links = new UrbTile[0]; } ClearTile(); if (input.Contents != null && input.Contents.Length > 0) { for (int c = 0; c < input.Contents.Length; c++) { UrbSystemIO.LoadAgentFromID(input.Contents[c], this, input.Objects[c]); } } Blocked = input.Blocked; Environment.LoadEnvironmentFromData(input.Environment); // This is broken somehow, fix it. /*TerrainTypes = new UrbPathTerrain[input.TerrainTypes.Length]; * * for (int i = 0; i < TerrainTypes.Length; i++) * { * TerrainTypes[i] = input.TerrainTypes[i]; * }*/ return(true); }