SpacePlanet.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using UnityEngine;
  2. using GadgetCore.API;
  3. using GadgetCore.Util;
  4. namespace SpacePlanet
  5. {
  6. [Gadget("SpacePlanet")]
  7. public class SpacePlanet : Gadget<SpacePlanet>
  8. {
  9. public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
  10. public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
  11. protected override void LoadConfig()
  12. {
  13. Config.Load();
  14. string fileVersion = Config.ReadString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  15. if (fileVersion != CONFIG_VERSION)
  16. {
  17. Config.Reset();
  18. Config.WriteString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
  19. }
  20. Config.Save();
  21. }
  22. public override string GetModDescription()
  23. {
  24. return "A mod that adds a space planet.";
  25. }
  26. protected override void Initialize()
  27. {
  28. Logger.Log("SpacePlanet v" + Info.Mod.Version);
  29. Core.logger = Logger;
  30. Texture2D texturePlanetPrevIcon = GadgetCoreAPI.LoadTexture2D("planetSpacePrev.png");
  31. Texture2D texturePlanetIcon = GadgetCoreAPI.LoadTexture2D("planetSpace.png");
  32. Texture2D texturePortalSign = GadgetCoreAPI.LoadTexture2D("signSpace.png");
  33. //Texture2D textureBG= GadgetCoreAPI.LoadTexture2D("bgSpace.png");
  34. //Texture2D textureParalex0 = GadgetCoreAPI.LoadTexture2D("bSpacebg0.png");
  35. //Texture2D textureParalex1 = GadgetCoreAPI.LoadTexture2D("bSpacebg1.png");
  36. //Texture2D textureParalex2 = GadgetCoreAPI.LoadTexture2D("bSpacebg2.png");
  37. //Texture2D textureParalex3 = GadgetCoreAPI.LoadTexture2D("bSpacebg3.png");
  38. //Texture2D textureEntrance = GadgetCoreAPI.LoadTexture2D("entranceSpace.png");
  39. //Texture2D textureSmallSide = GadgetCoreAPI.LoadTexture2D("sideSmallSpace.png");
  40. //Texture2D textureBigSide = GadgetCoreAPI.LoadTexture2D("sideBigSpace.png");
  41. //
  42. //Texture2D textureMid0 = GadgetCoreAPI.LoadTexture2D("midSpaceChunk0.png");
  43. //Texture2D textureMid1 = GadgetCoreAPI.LoadTexture2D("midSpaceChunk1.png");
  44. Texture2D textureSpaceOre = GadgetCoreAPI.LoadTexture2D("spaceOre.png");
  45. Texture2D textureSpaceOreBig = GadgetCoreAPI.LoadTexture2D("spaceOreBig.png");
  46. PlanetInfo spacePlanet = new PlanetInfo(PlanetType.SPECIAL, "Space", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(0, 100) });
  47. spacePlanet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
  48. //spacePlanet.SetBackgroundInfo(textureBG, textureParalex0, textureParalex1, textureParalex2, textureParalex3);
  49. //spacePlanet.SetTerrainInfo(textureEntrance, textureBG, textureMid0, textureMid1, textureBigSide, textureSmallSide);
  50. spacePlanet.OnGenerateWorld += SpaceWorldGenerator.StartGenarateWorld;
  51. spacePlanet.OnGenerateTown += SpaceWorldGenerator.GenarateTown;
  52. spacePlanet.Register("Space");
  53. spacePlanet.PortalUses = 10;
  54. Core.spacePlanetId = spacePlanet.GetID();
  55. //PlanetRegistry.SetVanillaExitPortalWeight(0, spacePlanet.GetID(), 1000);
  56. ObjectInfo objectSpaceOre = new ObjectInfo(ObjectType.ORE, new Item(1, 1, 0, 0, 0, new int[3], new int[3]), 0, textureSpaceOre).Register("spaceore");
  57. Core.objectSpaceOre = objectSpaceOre;
  58. ObjectInfo objectSpaceOreBig = new ObjectInfo(ObjectType.ORE, new Item(1, 1, 0, 0, 0, new int[3], new int[3]), 0, textureSpaceOreBig).Register("spaceorebig");
  59. Core.objectSpaceOreBig = objectSpaceOreBig;
  60. GameObject enemy = GadgetCoreAPI.GetEntityResource("");
  61. new EntityInfo(EntityType.COMMON, enemy, new int[0]).Register("");
  62. ((CraftMenuInfo)MenuRegistry.Singleton["Gadget Core:Crafter Menu"]).AddCraftPerformer(CraftMenuInfo.CreateSimpleCraftPerformer(
  63. Tuple.Create(new int[] { 11, 11, 11 }, new Item(11, 2, 0, 0, 0, new int[3], new int[3]), 2)
  64. ));
  65. }
  66. }
  67. }