MeteoroidGadget.Init.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using GadgetCore.API;
  2. using GadgetCore.Util;
  3. using RecipeMenuCore.API;
  4. using Subworlds.Scripts;
  5. using System.Collections;
  6. using UnityEngine;
  7. namespace Subworlds
  8. {
  9. [Gadget("SubworldMeteoroid", LoadAfter: new string[] { "RecipeMenuCore", "SubworldCore" }, Dependencies: new string[] { "RecipeMenuCore", "SubworldCore" })]
  10. public partial class MeteroidGadget : Gadget<MeteroidGadget>
  11. {
  12. protected override void LoadConfig()
  13. {
  14. Config.Load();
  15. string fileVersion = Config.ReadString("ConfigVersion", CoreGadget.CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  16. if (fileVersion != CoreGadget.CONFIG_VERSION)
  17. {
  18. Config.Reset();
  19. Config.WriteString("ConfigVersion", CoreGadget.CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  20. }
  21. Config.Save();
  22. }
  23. public override string GetModDescription()
  24. {
  25. return "A mod that adds ships that can be reaided.";
  26. }
  27. protected override void Initialize()
  28. {
  29. Logger.Log("Subworlds v" + Info.Mod.Version);
  30. Core.logger = Logger;
  31. Texture2D texturePlanetIcon = GadgetCoreAPI.LoadTexture2D("Meteoroid/icon.png");
  32. Texture2D texturePlanetPrevIcon = GadgetCoreAPI.LoadTexture2D("Meteoroid/button.png");
  33. Texture2D texturePortalSign = GadgetCoreAPI.LoadTexture2D("Meteoroid/sign.png");
  34. AudioClip audioShip = GadgetCoreAPI.LoadAudioClip("01_space.ogg");
  35. Core.meteroidPlanet = new PlanetInfo(PlanetType.SPECIAL, "Subworld Meteoroid", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(1, 100) }, audioShip);
  36. var planet = Core.meteroidPlanet;
  37. planet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
  38. planet.OnGenerateWorld += MeteroidGenerator.GenarateTown;
  39. planet.OnGenerateTown += MeteroidGenerator.Genarate;
  40. planet.Register("SubworldMeteoroid");
  41. planet.PortalUses = -1;
  42. // Create World Parts
  43. CreateBaseBlock("BaseBlockSmall", GadgetCoreAPI.LoadTexture2D("Meteoroid/meteor3.png"), 0.75f, 0.75f);
  44. CreateBaseBlock("BaseBlockNormal", GadgetCoreAPI.LoadTexture2D("Meteoroid/meteor1.png"), 1, 1);
  45. CreateBaseBlock("BaseBlockLarge", GadgetCoreAPI.LoadTexture2D("Meteoroid/meteor4.png"), 2, 2);
  46. CreateShipPart("MeteorBase", GadgetCoreAPI.LoadTexture2D("Meteoroid/meteorBaseFG.png"), GadgetCoreAPI.LoadTexture2D("Meteoroid/meteorBaseBG.png"), new int[][] {
  47. new int[] { 0, 10, 16, 1}
  48. , new int[] { 2, 7, 1, 3}
  49. , new int[] { 3, 6, 2, 1}
  50. , new int[] { 5, 5, 6, 1}
  51. , new int[] { 11, 6, 2, 1}
  52. , new int[] { 13, 7, 1, 3}
  53. }, new int[][] {
  54. new int[] { 5, 7, 0 }
  55. , new int[] { 10, 7, 0 }
  56. }, 16, 16);
  57. // Create Breakables
  58. CreateBrakableObject("SpaceOre1", GadgetCoreAPI.LoadTexture2D("Meteoroid/spaceOre.png"), itemId: 1);
  59. CreateBrakableObject("SpaceOre2", GadgetCoreAPI.LoadTexture2D("Meteoroid/spaceOreBig.png"), itemId: 1);
  60. }
  61. }
  62. }