| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using UnityEngine;
- using GadgetCore.API;
- using System.Collections.Generic;
- namespace ScrapYard
- {
- [Gadget("ScrapYard")]
- public class ScrapYard : Gadget<ScrapYard>
- {
- public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
- public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
- protected override void LoadConfig()
- {
- Config.Load();
- string fileVersion = Config.ReadString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
- if (fileVersion != CONFIG_VERSION)
- {
- Config.Reset();
- Config.WriteString("ConfigVersion", CONFIG_VERSION, comments: "The Config Version (not to be confused with mod version)");
- }
- Config.Save();
- }
- public override string GetModDescription()
- {
- return "A mod that adds a scryp yard planet.";
- }
- protected override void Initialize()
- {
- Logger.Log("Scrap Yard v" + Info.Mod.Version);
- Core.logger = Logger;
- Texture2D texturePlanetIcon = GadgetCoreAPI.LoadTexture2D("planetScrapYard.png");
- Texture2D texturePlanetPrevIcon = GadgetCoreAPI.LoadTexture2D("planetScrapYardPrev.png");
- Texture2D texturePortalSign = GadgetCoreAPI.LoadTexture2D("signScrapYard.png");
- Texture2D textureBG = GadgetCoreAPI.LoadTexture2D("bgScrapYard.png");
- Texture2D textureParalex = GadgetCoreAPI.LoadTexture2D("parallax.png");
- Texture2D textureParalex0 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg0.png");
- Texture2D textureParalex1 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg1.png");
- Texture2D textureParalex2 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg2.png");
- Texture2D textureParalex3 = GadgetCoreAPI.LoadTexture2D("bScrapYardbg3.png");
- Texture2D textureEntrance = GadgetCoreAPI.LoadTexture2D("entranceScrapYard.png");
- Texture2D textureSmallSide = GadgetCoreAPI.LoadTexture2D("sideSmallScrapYard.png");
- Texture2D textureBigSide = GadgetCoreAPI.LoadTexture2D("sideBigScrapYard.png");
- Texture2D textureMid0 = GadgetCoreAPI.LoadTexture2D("midScrapYardChunk0.png");
- Texture2D textureMid1 = GadgetCoreAPI.LoadTexture2D("midScrapYardChunk1.png");
- PlanetInfo scrapYardPlanet = new PlanetInfo(PlanetType.SINGLE, "Scrap Yard", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(1, 100) });
- scrapYardPlanet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
- scrapYardPlanet.SetBackgroundInfo(textureParalex, textureParalex0, textureParalex1, textureParalex2, textureParalex3);
- scrapYardPlanet.SetTerrainInfo(textureEntrance, textureBG, textureMid0, textureMid1, textureBigSide, textureSmallSide);
- scrapYardPlanet.OnGenerateInsideTown += GenerateTown;
- scrapYardPlanet.PortalUses = 300;
- {
- var scrapYardShopBuilding = Object.Instantiate((GameObject)Resources.Load("prop/2501"));
- scrapYardShopBuilding.transform.localScale *= 8;
- Texture2D texture = GadgetCoreAPI.LoadTexture2D("shopStand.png");
- var renderer = scrapYardShopBuilding.GetComponentInChildren<Renderer>();
- renderer.material = new Material(Shader.Find("Unlit/Transparent"))
- {
- mainTexture = texture
- };
- GadgetCoreAPI.AddCustomResource("prop/ScrapYard/scrapYardShopBuilding", scrapYardShopBuilding);
- }
- {
- var scrapYardMerchant = Object.Instantiate((GameObject)Resources.Load("npc/perceval"));
- Texture2D textureBody = GadgetCoreAPI.LoadTexture2D("merchantBody.png");
- Texture2D textureHead = GadgetCoreAPI.LoadTexture2D("merchantHead.png");
- var gameObjectBody = scrapYardMerchant.transform.Find("e").Find("perceval").FindChild("Plane_002");
- var rendererBody = gameObjectBody.gameObject.GetComponentInChildren<Renderer>();
- rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
- {
- mainTexture = textureBody
- };
- rendererBody.transform.position = new Vector3(0, 0, 0.1f);
- var gameObjectHead = scrapYardMerchant.transform.Find("e").Find("perceval").FindChild("Plane");
- var rendererHead = gameObjectHead.gameObject.GetComponentInChildren<Renderer>();
- rendererHead.material = new Material(Shader.Find("Unlit/Transparent"))
- {
- mainTexture = textureHead
- };
- Component.DestroyImmediate(scrapYardMerchant.GetComponent<npcTurnScript>());
- GadgetCoreAPI.AddCustomResource("prop/ScrapYard/scrapYardMerchant", scrapYardMerchant);
- }
- scrapYardPlanet.Register("Scrap Yard");
- }
- private static IEnumerable<GameObject> GenerateTown(Chunk chunk)
- {
- var list = new List<GameObject>();
- list.Add((GameObject)Network.Instantiate(Resources.Load("prop/ScrapYard/scrapYardShopBuilding"), new Vector3(250f, -6f + 0.118f, 0.3f), Quaternion.identity, 0));
- list.Add((GameObject)Network.Instantiate(Resources.Load("prop/ScrapYard/scrapYardMerchant"), new Vector3(255f, -6f - 0.118f * 12, 0.2f), Quaternion.identity, 0));
- return list;
- }
- }
- }
|