ShipsGadget.Init.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using GadgetCore.API;
  2. using UnityEngine;
  3. namespace Subworlds
  4. {
  5. [Gadget("SubworldShip", LoadAfter: new string[] { "RecipeMenuCore", "SubworldCore" }, Dependencies: new string[] { "RecipeMenuCore", "SubworldCore" })]
  6. public partial class SubworldsGadget : Gadget<SubworldsGadget>
  7. {
  8. protected override void LoadConfig()
  9. {
  10. Config.Load();
  11. string fileVersion = Config.ReadString("ConfigVersion", CoreGadget.CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  12. if (fileVersion != CoreGadget.CONFIG_VERSION)
  13. {
  14. Config.Reset();
  15. Config.WriteString("ConfigVersion", CoreGadget.CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  16. }
  17. Config.Save();
  18. }
  19. public override string GetModDescription()
  20. {
  21. return "A mod that adds ships that can be reaided.";
  22. }
  23. protected override void Initialize()
  24. {
  25. Logger.Log("Subworlds v" + Info.Mod.Version);
  26. Core.logger = Logger;
  27. Texture2D texturePlanetIcon = GadgetCoreAPI.LoadTexture2D("Ship/icon.png");
  28. Texture2D texturePlanetPrevIcon = GadgetCoreAPI.LoadTexture2D("Ship/button.png");
  29. Texture2D texturePortalSign = GadgetCoreAPI.LoadTexture2D("Ship/sign.png");
  30. AudioClip audioShip = GadgetCoreAPI.LoadAudioClip("01_space.ogg");
  31. Core.shipPlanet = new PlanetInfo(PlanetType.SPECIAL, "Subworld Ship", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(1, 100) }, audioShip);
  32. var planet = Core.shipPlanet;
  33. planet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
  34. planet.OnGenerateWorld += ShipGenerator.GenarateTown;
  35. planet.OnGenerateTown += ShipGenerator.Genarate;
  36. planet.Register("SubworldShip");
  37. planet.PortalUses = -1;
  38. // Create World Parts
  39. CreateShipPart("ShipAEntrance", GadgetCoreAPI.LoadTexture2D("Ship/shipAEntranceFG.png"), GadgetCoreAPI.LoadTexture2D("Ship/shipAEntranceBG.png"), new int[][] {
  40. new int[] { 11, 5, 5, 1}
  41. , new int[] { 11, 5, 1, 6}
  42. , new int[] { 11, 10, 5, 1}
  43. }, new int[][] { }, 16, 16);
  44. CreateShipPart("ShipAMain", GadgetCoreAPI.LoadTexture2D("Ship/shipAMainFG.png"), GadgetCoreAPI.LoadTexture2D("Ship/shipAMainBG.png"), new int[][] {
  45. new int[] { 0, 0, 32, 1}
  46. , new int[] { 0, 15, 32, 1}
  47. , new int[] { 0, 0, 1, 6}
  48. , new int[] { 31, 0, 1, 6}
  49. , new int[] { 0, 10, 1, 6}
  50. , new int[] { 31, 10, 1, 6}
  51. , new int[] { 3, 5, 4, 1}
  52. , new int[] { 9, 5, 4, 1}
  53. , new int[] { 19, 5, 4, 1}
  54. , new int[] { 25, 5, 4, 1}
  55. , new int[] { 3, 10, 4, 1}
  56. , new int[] { 9, 10, 4, 1}
  57. , new int[] { 19, 10, 4, 1}
  58. , new int[] { 25, 10, 4, 1}
  59. }, new int[][] {
  60. new int[] { 3, 7, 0 }
  61. , new int[] { 6, 7, 1 }
  62. , new int[] { 25, 7, 1 }
  63. , new int[] { 28, 7, 0 }
  64. });
  65. CreateShipPart("ShipAExit", GadgetCoreAPI.LoadTexture2D("Ship/shipAExitFG.png"), GadgetCoreAPI.LoadTexture2D("Ship/shipAExitBG.png"), new int[][] {
  66. new int[] { 0, 5, 10, 1}
  67. , new int[] { 0, 10, 13, 1}
  68. , new int[] { 10, 6, 2, 1}
  69. , new int[] { 12, 7, 1, 4}
  70. }, new int[][] {
  71. new int[] { 5, 7, 0 }
  72. }, 16, 16);
  73. CreateShipPart("ShuttleMain", GadgetCoreAPI.LoadTexture2D("Ship/shuttleMainFG.png"), GadgetCoreAPI.LoadTexture2D("Ship/shuttleMainBG.png"), new int[][] {
  74. new int[] { 3, 5, 10, 1}
  75. , new int[] { 3, 10, 11, 1}
  76. , new int[] { 3, 5, 1, 5}
  77. , new int[] { 13, 6, 1, 1}
  78. , new int[] { 14, 7, 1, 3}
  79. }, new int[][] {
  80. new int[] { 5, 7, 0 }
  81. }, 16, 16);
  82. // Create Decorations
  83. CreateObject("BrokenTeleporter", GadgetCoreAPI.LoadTexture2D("Ship/brokenTeleporter.png"), true);
  84. CreateBrakableObject("BrokenPirate1", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate1.png"), true);
  85. CreateBrakableObject("BrokenPirate2", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate2.png"), true);
  86. CreateBrakableObject("BrokenPirate3", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate3.png"), true);
  87. CreateBrakableObject("BrokenPirate4", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate4.png"), true);
  88. CreateBrakableObject("BrokenPirate5", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate5.png"), true);
  89. CreateBrakableObject("BrokenPirate6", GadgetCoreAPI.LoadTexture2D("Ship/brokenPirate6.png"), true);
  90. CreateBrakableObject("BrokenCrates1", GadgetCoreAPI.LoadTexture2D("Ship/brokenCrates1.png"));
  91. CreateBrakableObject("BrokenCrates2", GadgetCoreAPI.LoadTexture2D("Ship/brokenCrates2.png"));
  92. CreateBrakableObject("BrokenCrates3", GadgetCoreAPI.LoadTexture2D("Ship/brokenCrates3.png"));
  93. CreateBrakableObject("BrokenCrates4", GadgetCoreAPI.LoadTexture2D("Ship/brokenCrates4.png"));
  94. CreateBrakableObject("BrokenItemMod", GadgetCoreAPI.LoadTexture2D("Ship/brokenItemMod.png"));
  95. CreateBrakableObject("BrokenChest", GadgetCoreAPI.LoadTexture2D("Ship/brokenChest.png"));
  96. // Create Enemies
  97. CreateSliverEnemy("BrokenSliver", GadgetCoreAPI.LoadTexture2D("Ship/brokenSliverHead.png"), GadgetCoreAPI.LoadTexture2D("Ship/brokenSliverBody.png"), GadgetCoreAPI.LoadTexture2D("Ship/brokenSliverTail.png"));
  98. CreateDroidEnemy("BrokenDroid", GadgetCoreAPI.LoadTexture2D("Ship/droid.png"));
  99. // Create Hazards
  100. CreateLaserHazard("LaserHazard", GadgetCoreAPI.LoadTexture2D("Ship/brokenLaser.png"));
  101. CreateOldChest("OldChest", GadgetCoreAPI.LoadTexture2D("Ship/oldChest.png"));
  102. }
  103. }
  104. }