|
|
@@ -0,0 +1,178 @@
|
|
|
+using UnityEngine;
|
|
|
+using GadgetCore.API;
|
|
|
+using GadgetCore.Util;
|
|
|
+using GadgetCore.API.ConfigMenu;
|
|
|
+using MonsterNests.Scripts;
|
|
|
+
|
|
|
+namespace MonsterNests
|
|
|
+{
|
|
|
+ [Gadget("MonsterNests", RequiredOnClients: true)]
|
|
|
+ public class MonsterNests : Gadget<MonsterNests>
|
|
|
+ {
|
|
|
+ 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.Reset();
|
|
|
+ Config.Save();
|
|
|
+ }
|
|
|
+ public override IGadgetConfigMenu GetConfigMenu() { return null; }
|
|
|
+
|
|
|
+ public override string GetModDescription()
|
|
|
+ {
|
|
|
+ return "A mod that adds some rare dangerous harvestables.";
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void Initialize()
|
|
|
+ {
|
|
|
+ Logger.Log("Monster Nests v" + Info.Mod.Version);
|
|
|
+ Core.logger = Logger;
|
|
|
+
|
|
|
+ Texture2D textureBugspotBig = GadgetCoreAPI.LoadTexture2D("objects/bugspotBig.png");
|
|
|
+ Texture2D textureBugTree = GadgetCoreAPI.LoadTexture2D("objects/bugTree.png");
|
|
|
+ Texture2D textureSpikePlant = GadgetCoreAPI.LoadTexture2D("objects/spikePlant.png");
|
|
|
+ Texture2D textureSpikePlantTop = GadgetCoreAPI.LoadTexture2D("objects/spikePlantTop.png");
|
|
|
+ Texture2D textureSpikePlantCM = GadgetCoreAPI.LoadTexture2D("objects/spikePlantCM.png");
|
|
|
+ Texture2D textureSpikePlantCMTop = GadgetCoreAPI.LoadTexture2D("objects/spikePlantCMTop.png");
|
|
|
+ Texture2D textureSpiderEgg = GadgetCoreAPI.LoadTexture2D("objects/spiderEgg.png");
|
|
|
+ Texture2D textureSpiderEggCM = GadgetCoreAPI.LoadTexture2D("objects/spiderEggCM.png");
|
|
|
+ Texture2D textureGoldenShroom = GadgetCoreAPI.LoadTexture2D("objects/goldenShroom.png");
|
|
|
+ Texture2D textureWizShroom = GadgetCoreAPI.LoadTexture2D("objects/wizShroom.png");
|
|
|
+ Texture2D textureAncientCrystal = GadgetCoreAPI.LoadTexture2D("objects/ancientCrystal.png");
|
|
|
+ Texture2D textureAncientCrystalCMTop = GadgetCoreAPI.LoadTexture2D("objects/ancientCrystalCMTop.png");
|
|
|
+ Texture2D textureAncientCrystalTop = GadgetCoreAPI.LoadTexture2D("objects/ancientCrystalTop.png");
|
|
|
+ Texture2D texturePlagueNest = GadgetCoreAPI.LoadTexture2D("objects/plagueNest.png");
|
|
|
+ Texture2D textureFrozenWisp = GadgetCoreAPI.LoadTexture2D("objects/frozenWisp.png");
|
|
|
+ Texture2D textureMolten = GadgetCoreAPI.LoadTexture2D("objects/molten.png");
|
|
|
+
|
|
|
+ Core.objectBugspotBig = new ObjectInfo(ObjectType.BUGSPOT, new Item(31, 1, 0, 0, 0, new int[3], new int[3]), 16, textureBugspotBig).Register("bugspotBig");
|
|
|
+ Core.objectBugTree = new ObjectInfo(ObjectType.TREE, new Item(11, 1, 0, 0, 0, new int[3], new int[3]), 16, textureBugTree).Register("bugTree");
|
|
|
+ Core.objectSpikePlant = new ObjectInfo(ObjectType.PLANT, new Item(11, 1, 0, 0, 0, new int[3], new int[3]), 16, textureSpikePlant).Register("spikePlant");
|
|
|
+ Core.objectSpikePlantCM = new ObjectInfo(ObjectType.PLANT, new Item(11, 1, 0, 0, 0, new int[3], new int[3]), 16, textureSpikePlantCM).Register("spikePlantCM");
|
|
|
+ Core.objectSpiderEgg = new ObjectInfo(ObjectType.ORE, new Item(2, 1, 0, 0, 0, new int[3], new int[3]), 16, textureSpiderEgg).Register("spiderEgg");
|
|
|
+ Core.objectSpiderEggCM = new ObjectInfo(ObjectType.ORE, new Item(2, 1, 0, 0, 0, new int[3], new int[3]), 16, textureSpiderEggCM).Register("spiderEggCM");
|
|
|
+ Core.objectGoldenShroom = new ObjectInfo(ObjectType.PLANT, new Item(12, 1, 0, 0, 0, new int[3], new int[3]), 16, textureGoldenShroom).Register("goldenShroom");
|
|
|
+ Core.objectWizShroom = new ObjectInfo(ObjectType.PLANT, new Item(12, 1, 0, 0, 0, new int[3], new int[3]), 16, textureWizShroom).Register("wizShroom");
|
|
|
+ Core.objectAncientCrystal = new ObjectInfo(ObjectType.ORE, new Item(57, 1, 0, 0, 0, new int[3], new int[3]), 106, textureAncientCrystal).Register("ancientCrystal");
|
|
|
+ Core.objectAncientCrystalCM = new ObjectInfo(ObjectType.ORE, new Item(57, 1, 0, 0, 0, new int[3], new int[3]), 106, textureAncientCrystal).Register("ancientCrystalCM");
|
|
|
+ Core.objectPlagueNest = new ObjectInfo(ObjectType.TREE, new Item(51, 1, 0, 0, 0, new int[3], new int[3]), 106, texturePlagueNest).Register("plagueNest");
|
|
|
+ Core.objectFrozenWisp = new ObjectInfo(ObjectType.ORE, new Item(3, 1, 0, 0, 0, new int[3], new int[3]), 16, textureFrozenWisp).Register("frozenWisp");
|
|
|
+ Core.objectMolten = new ObjectInfo(ObjectType.ORE, new Item(5, 1, 0, 0, 0, new int[3], new int[3]), 16, textureMolten).Register("molten");
|
|
|
+ CreatGoldenShroom("goldenShroom", GadgetCoreAPI.LoadTexture2D("entity/goldenShroomHead.png"), GadgetCoreAPI.LoadTexture2D("entity/goldenShroomTop.png"));
|
|
|
+ CreatGoldenShroomProjectile("goldenShroom", GadgetCoreAPI.LoadTexture2D("projectiles/goldenShroom.png"));
|
|
|
+
|
|
|
+ AlterObjectSpike(Core.objectSpikePlant, textureSpikePlantTop);
|
|
|
+ AlterObjectSpike(Core.objectSpikePlantCM, textureSpikePlantCMTop);
|
|
|
+
|
|
|
+ AlterObjectAncientCrystal(Core.objectAncientCrystal, textureAncientCrystalTop);
|
|
|
+ AlterObjectAncientCrystal(Core.objectAncientCrystalCM, textureAncientCrystalCMTop);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AlterObjectSpike(ObjectInfo info, Texture2D texture)
|
|
|
+ {
|
|
|
+ var obj = (GameObject)Resources.Load(info.ResourcePath);
|
|
|
+ obj.name = "plant";
|
|
|
+ var o = GameObject.Instantiate(obj.transform.GetChild(0).gameObject);
|
|
|
+ o.transform.SetParent(obj.transform);
|
|
|
+ o.transform.localPosition = obj.transform.GetChild(0).localPosition + new Vector3(0, 0.3125f * 1.5f, -1.05f);
|
|
|
+ var haz = o.AddComponent<HazardScript>();
|
|
|
+ haz.damage = 2;
|
|
|
+ var box = o.AddComponent<BoxCollider>();
|
|
|
+ box.size = new Vector3(1.25f, 1.25f, 4);
|
|
|
+ box.isTrigger = true;
|
|
|
+ obj.transform.GetChild(1).localPosition = new Vector3(0, 2.2f, 0);
|
|
|
+ var ani = o.GetComponent<Animation>();
|
|
|
+ ani.playAutomatically = true;
|
|
|
+ AnimationClip clip = new AnimationClip
|
|
|
+ {
|
|
|
+ name = "plantSquish",
|
|
|
+ wrapMode = WrapMode.Loop,
|
|
|
+ legacy = true
|
|
|
+ };
|
|
|
+ clip.SetCurve("", typeof(Transform), "m_LocalScale.x", new AnimationCurve(new Keyframe(0f, 1.9f, 0f, 0f), new Keyframe(0.371f, 2.1f, 0f, 0f), new Keyframe(1f, 1.9f, 0f, 0f)));
|
|
|
+ clip.SetCurve("", typeof(Transform), "m_LocalScale.y", new AnimationCurve(new Keyframe(0f, 2.1f, 0f, 0f), new Keyframe(0.442f, 1.9f, 0f, 0f), new Keyframe(1f, 2.1f, 0f, 0f)));
|
|
|
+ ani.RemoveClip("shake_0");
|
|
|
+ ani.AddClip(clip, "plantSquish");
|
|
|
+ ani.clip = clip;
|
|
|
+ o.GetComponent<Renderer>().material
|
|
|
+ = new Material(o.GetComponent<Renderer>().material) { mainTexture = texture };
|
|
|
+ GadgetCoreAPI.AddCustomResource(info.ResourcePath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AlterObjectAncientCrystal(ObjectInfo info, Texture2D texture)
|
|
|
+ {
|
|
|
+ var obj = (GameObject)Resources.Load(info.ResourcePath);
|
|
|
+ obj.name = "plant";
|
|
|
+ var o = GameObject.Instantiate(obj.transform.GetChild(0).gameObject);
|
|
|
+ o.transform.SetParent(obj.transform);
|
|
|
+ o.transform.localPosition = obj.transform.GetChild(0).localPosition + new Vector3(0, 0.3125f * 2f, 0);
|
|
|
+ obj.transform.GetChild(1).localPosition = new Vector3(0, 2.2f, 0);
|
|
|
+ var ani = o.GetComponent<Animation>();
|
|
|
+ ani.playAutomatically = true;
|
|
|
+ AnimationClip clip = new AnimationClip
|
|
|
+ {
|
|
|
+ name = "plantSquish",
|
|
|
+ wrapMode = WrapMode.Loop,
|
|
|
+ legacy = true
|
|
|
+ };
|
|
|
+ clip.SetCurve("", typeof(Transform), "m_LocalScale.x", new AnimationCurve(new Keyframe(0f, 1.8f, 0f, 0f), new Keyframe(0.171f, 2.1f, 0f, 0f), new Keyframe(0.5f, 1.8f, 0f, 0f)));
|
|
|
+ clip.SetCurve("", typeof(Transform), "m_LocalScale.y", new AnimationCurve(new Keyframe(0f, 2.1f, 0f, 0f), new Keyframe(0.142f, 1.8f, 0f, 0f), new Keyframe(0.5f, 2.1f, 0f, 0f)));
|
|
|
+ ani.RemoveClip("shake_0");
|
|
|
+ ani.AddClip(clip, "plantSquish");
|
|
|
+ ani.clip = clip;
|
|
|
+ o.GetComponent<Renderer>().material
|
|
|
+ = new Material(o.GetComponent<Renderer>().material) { mainTexture = texture };
|
|
|
+ GadgetCoreAPI.AddCustomResource(info.ResourcePath, obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CreatGoldenShroom(string name, Texture2D textureHead, Texture2D textureBody)
|
|
|
+ {
|
|
|
+ GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("e/shroomy1"));
|
|
|
+ Renderer rendererHead = gameObject.transform.GetChild(0).GetChild(0).GetChild(1).GetComponentInChildren<Renderer>();
|
|
|
+ rendererHead.material = new Material(Shader.Find("Unlit/Transparent"))
|
|
|
+ {
|
|
|
+ mainTexture = textureHead
|
|
|
+ };
|
|
|
+ Renderer rendererBody = gameObject.transform.GetChild(0).GetChild(0).GetChild(0).GetComponentInChildren<Renderer>();
|
|
|
+ rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
|
|
|
+ {
|
|
|
+ mainTexture = textureBody
|
|
|
+ };
|
|
|
+
|
|
|
+ Component.DestroyImmediate(gameObject.GetComponent<RolandBall>());
|
|
|
+ gameObject.AddComponent<GoldenShroomScript>();
|
|
|
+
|
|
|
+ GadgetCoreAPI.AddCustomResource("e/MonsterNests/" + name, gameObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CreatGoldenShroomProjectile(string name, Texture2D texture)
|
|
|
+ {
|
|
|
+ GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("proj/ballProj"));
|
|
|
+ Renderer rendererHead = gameObject.transform.GetChild(0).GetComponentInChildren<Renderer>();
|
|
|
+ rendererHead.material = new Material(Shader.Find("Unlit/Transparent"))
|
|
|
+ {
|
|
|
+ mainTexture = texture
|
|
|
+ };
|
|
|
+ Renderer rendererBody = gameObject.transform.GetChild(1).GetComponentInChildren<Renderer>();
|
|
|
+ rendererBody.material = new Material(Shader.Find("Unlit/Transparent"))
|
|
|
+ {
|
|
|
+ mainTexture = texture
|
|
|
+ };
|
|
|
+
|
|
|
+ gameObject.GetComponent<HazardScript>().damage = 8;
|
|
|
+
|
|
|
+ GadgetCoreAPI.AddCustomResource("proj/MonsterNests/" + name, gameObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|