ShipDecorations.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using UnityEngine;
  2. using GadgetCore.API;
  3. using UnityEngine.SceneManagement;
  4. using System.Reflection;
  5. using GadgetCore.API.ConfigMenu;
  6. using System;
  7. using ScrapYard.API;
  8. namespace ShipDecorations
  9. {
  10. [Gadget("ShipDecorations", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" }, LoadPriority: 100)]
  11. public class ShipDecorations : Gadget<ShipDecorations>
  12. {
  13. public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
  14. public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
  15. public override IGadgetConfigMenu GetConfigMenu() { return null; }
  16. protected override void LoadConfig() { Config.Reset(); Config.Save(); }
  17. public override string GetModDescription()
  18. {
  19. return "A mod that adds some more ship decorations.";
  20. }
  21. protected override void Initialize()
  22. {
  23. Logger.Log("Ship Decorations v" + Info.Mod.Version);
  24. Core.logger = Logger;
  25. QualitySettings.antiAliasing = 0;
  26. var lightsPlatform = new ShopPlatform("Decorations").Register();
  27. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cBed.png", "iBed.png", "Bed"), 1000));
  28. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cPlant0Plant.png", "iPlant0Plant.png", "Bush Plant"), 1000));
  29. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cTree5Plant.png", "iTree5Plant.png", "Tree Plant"), 1000));
  30. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableDecoItem("cTreantHeadPlant.png", "iTreantHeadPlant.png", "Treant Plant"), 2, 1, ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy")));
  31. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableSlideDoorItem("cDoor.png", "cDoorOpen.png", "iDoor.png", "Door"), 1000));
  32. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cWindowScrapWall.png", "iWindowScrapWall.png", "Scrap Wall Window"), 10));
  33. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cTitaniumWall.png", "iTitaniumWall.png", "Titaniu Wall"), 10));
  34. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cTitaniumWindow.png", "iTitaniumWindow.png", "Titaniu Window"), 10));
  35. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cHiveWall.png", "iHiveWall.png", "Hive Wall"), 10));
  36. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cHiveWindow.png", "iHiveWindow.png", "Hive Window"), 10));
  37. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cStealWall.png", "iStealWall.png", "Steal Wall"), 10));
  38. ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateWallItem("cStealWindow.png", "iStealWindow.png", "Steal Window"), 10));
  39. ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateBlockItem("cStealBlock.png", "iStealBlock.png", "Steal Block"), 10));
  40. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableStairsItemL("cStairs.png", "iStairs.png", "Stairs [L]", "StairsL"), 10));
  41. lightsPlatform.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreatePlacableStairsItemR("cStairsR.png", "iStairsR.png", "Stairs [R]", "StairsR"), 10));
  42. { // Part Engine Blue
  43. var asset = GadgetCoreAPI.LoadAssetBundle("engine");
  44. var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineBlue.prefab"));
  45. engine.name = "engineBlue";
  46. engine.transform.localScale = new Vector3(2, 2, 2);
  47. GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineBlue", engine);
  48. }
  49. { // Part Engine Yellow
  50. var asset = GadgetCoreAPI.LoadAssetBundle("engine");
  51. var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineYellow.prefab"));
  52. engine.name = "engineYellow";
  53. engine.transform.localScale = new Vector3(2, 2, 2);
  54. GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineYellow", engine);
  55. }
  56. { // Part Engine Red
  57. var asset = GadgetCoreAPI.LoadAssetBundle("engine");
  58. var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineRed.prefab"));
  59. engine.name = "engineRed";
  60. engine.transform.localScale = new Vector3(2, 2, 2);
  61. GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineRed", engine);
  62. }
  63. { // Part Engine Green
  64. var asset = GadgetCoreAPI.LoadAssetBundle("engine");
  65. var engine = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/engineGreen.prefab"));
  66. engine.name = "engineGreen";
  67. engine.transform.localScale = new Vector3(2, 2, 2);
  68. GadgetCoreAPI.AddCustomResource("prop/ScrapYard/component/engineGreen", engine);
  69. }
  70. foreach (var e in ShopPlatform.DefaultBlocks.GetShopPlatformEntries())
  71. {
  72. if (e.ItemID == 2400)
  73. {
  74. ShopPlatform.DefaultBlocks.RemoveShopPlatformEntry(e);
  75. }
  76. }
  77. ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cBlueEngineBlock.png", "iBlueEngineBlock.png", "engineBlue", "Plasma Engine", "An engine for a ship.", "BlueEngineBlock"), 10));
  78. ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cYellowEngineBlock.png", "iYellowEngineBlock.png", "engineYellow", "Differential Engine", "An engine for a ship.", "YellowEngineBlock"), 10));
  79. //ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateOverrideEngineItem("cRedEngineBlock.png", "iRedEngineBlock.png", "engineRed", "Combustion Engine", "An engine for a ship.", "RedEngineBlock"), 10));
  80. ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(ItemUtil.CreateEngineItem("cGreenEngineBlock.png", "iGreenEngineBlock.png", "engineGreen", "Burst Engine", "An engine for a ship.", "GreenEngineBlock"), 10));
  81. SceneManager.sceneLoaded += OnSceneLoaded;
  82. }
  83. internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
  84. {
  85. if (scene.buildIndex == 1)
  86. {
  87. try
  88. {
  89. var aa = GameObject.Find("Main Camera").GetComponent<AntialiasingAsPostEffect>();
  90. //aa.enabled = true;
  91. Component.DestroyImmediate(aa);
  92. //var bloom = GameObject.Find("Main Camera").GetComponent<Bloom>();
  93. //Component.DestroyImmediate(bloom);
  94. var vig = GameObject.Find("Main Camera").GetComponent<Vignetting>();
  95. Component.DestroyImmediate(vig);
  96. var noise = GameObject.Find("Main Camera").GetComponent<NoiseEffect>();
  97. Component.DestroyImmediate(noise);
  98. var flare = GameObject.Find("Main Camera").GetComponent<Flare>();
  99. Component.DestroyImmediate(flare);
  100. //var camera = GameObject.Find("Main Camera").GetComponent<Camera>();
  101. //camera.transform.rotation = Quaternion.EulerAngles(0.2f,0.2f,0);
  102. //camera.useOcclusionCulling = false;
  103. //camera.orthographic = false;
  104. //camera.rect = new Rect(0, 0, 1, 1);
  105. //camera.fieldOfView = 33;
  106. //GameObject.Find("Main Camera").transform.localPosition = new Vector3(0, 0, -50);
  107. //for(int i = 0; i < GameObject.Find("Main Camera").transform.GetChildCount(); i++)
  108. //{
  109. // GameObject.Find("Main Camera").transform.GetChild(i).transform.localPosition = new Vector3(0, 0, -60);
  110. //}
  111. }
  112. catch (Exception e) { Core.logger.LogConsole(e.Message); }
  113. }
  114. }
  115. }
  116. }