Advertisement
midspace

SE DefinitionLoader

Oct 1st, 2016
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. namespace midspace.DefinitionLoader
  2. {
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using Sandbox.Common.ObjectBuilders;
  7. using Sandbox.Definitions;
  8. using Sandbox.ModAPI;
  9. using VRage.Game;
  10. using VRage.Game.Components;
  11.  
  12. [MySessionComponentDescriptor(MyUpdateOrder.NoUpdate)]
  13. public class SessionComponentLogic : MySessionComponentBase
  14. {
  15. public override void LoadData()
  16. {
  17. // Need to create the Utilities, as it isn't yet created by the game at this point.
  18. if (MyAPIGateway.Utilities == null)
  19. MyAPIGateway.Utilities = new MyAPIUtilities();
  20.  
  21. //string textureFile = @"Textures\Custom\clean_target_overlay.dds"; // stock
  22. //string textureFile = Path.Combine(MyAPIGateway.Utilities.GamePaths.ModsPath, @"midspace Clean Crosshair Camera\Textures\Custom\clean_target_overlay.dds"); // local mod.
  23. string textureFile = Path.Combine(MyAPIGateway.Utilities.GamePaths.ModsPath, @"772650039.sbm\Textures\Custom\clean_target_overlay.dds"); // deployed mod.
  24.  
  25. //VRage.Utils.MyLog.Default.WriteLine(string.Format("##Mod## CAMERA OVERLAY. Message: {0}", (MyAPIGateway.Utilities.GamePaths.ModsPath));
  26.  
  27. List<MyDefinitionBase> blocks = MyDefinitionManager.Static.GetAllDefinitions().Where(d => d is MyCubeBlockDefinition &&
  28. ((MyCubeBlockDefinition)d).Id.TypeId == typeof(MyObjectBuilder_CameraBlock)).ToList();
  29. foreach (var block in blocks)
  30. {
  31. MyCameraBlockDefinition cameraBlock = (MyCameraBlockDefinition)block;
  32. cameraBlock.OverlayTexture = textureFile;
  33. }
  34.  
  35. blocks = MyDefinitionManager.Static.GetAllDefinitions().Where(d => d is MyCubeBlockDefinition &&
  36. (((MyCubeBlockDefinition)d).Id.TypeId == typeof(MyObjectBuilder_LargeGatlingTurret) ||
  37. ((MyCubeBlockDefinition)d).Id.TypeId == typeof(MyObjectBuilder_LargeMissileTurret))).ToList();
  38. foreach (var block in blocks)
  39. {
  40. MyLargeTurretBaseDefinition turretBlock = (MyLargeTurretBaseDefinition)block;
  41. turretBlock.OverlayTexture = textureFile;
  42. }
  43.  
  44. base.LoadData();
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement