Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. using System;
  2. using Monosyne;
  3. using Monosyne.SceneV2.Resource;
  4.  
  5. namespace CaesarsSlots.Common.Utils
  6. {
  7. public static class SceneResourceExtensions
  8. {
  9. public static SceneObjectResource Find(this SceneResource resource, string id)
  10. {
  11. foreach (SceneObjectResource child in resource.Objects.Values)
  12. {
  13. SceneObjectResource res = child.Find(resource, id);
  14. if (res != null)
  15. {
  16. return res;
  17. }
  18. }
  19.  
  20. return null;
  21. }
  22.  
  23.  
  24. public static SceneObjectResource Find(this SceneObjectResource resource, SceneResource sceneResource, string id)
  25. {
  26. if (resource.Properties != null && resource.Properties.ContainsKey("Id"))
  27. {
  28. if ((string)resource.Properties["Id"] == id)
  29. {
  30. return resource;
  31. }
  32. }
  33.  
  34. if (resource.Children != null)
  35. {
  36. for (int i = 0; i < resource.Children.Length; ++i)
  37. {
  38. SceneObjectResource child = (resource.Children[i] is SceneObjectResource)
  39. ? (SceneObjectResource)resource.Children[i]
  40. : (SceneObjectResource)sceneResource.Objects[(String)resource.Children[i]];
  41.  
  42. SceneObjectResource res = child.Find(sceneResource, id);
  43. if (res != null)
  44. {
  45. return res;
  46. }
  47. }
  48. }
  49.  
  50. return null;
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement