Esempio n. 1
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     if (Entity != null)
     {
         GadgetCoreAPI.AddCustomResource(ResourcePath = "e/" + Entity.name, Entity);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     if (FlagMat == null)
     {
         FlagMat = new Material(Shader.Find("Unlit/Transparent Cutout"))
         {
             mainTexture = FlagTex
         };
         FlagMat.SetFloat("_Cutoff", 0.5f);
     }
     else
     {
         FlagTex = FlagMat.mainTexture;
     }
     GadgetCoreAPI.AddCustomResource("flag/flag" + GetID(), FlagMat);
     if (InvIconMat == null)
     {
         InvIconMat = new Material(Shader.Find("Unlit/Transparent Cutout"))
         {
             mainTexture = InvIconTex
         };
         InvIconMat.SetFloat("_Cutoff", 0.5f);
     }
     else
     {
         InvIconTex = InvIconMat.mainTexture;
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 public override void PostRegister()
 {
     if (Entity != null)
     {
         GadgetCoreAPI.AddCustomResource("e/" + Entity.name, Entity);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     base.PostRegister();
     if (VariantMats == null)
     {
         VariantMats = new Material[VariantTexes.Length];
         for (int i = 0; i < VariantMats.Length; i++)
         {
             VariantMats[i] = new Material(Shader.Find("Unlit/Transparent"))
             {
                 mainTexture = VariantTexes[i]
             };
             GadgetCoreAPI.AddCustomResource("r/r" + ID + "v" + i, VariantMats[i]);
         }
     }
     else
     {
         VariantTexes = new Texture[VariantMats.Length];
         for (int i = 0; i < VariantTexes.Length; i++)
         {
             VariantTexes[i] = VariantMats[i].mainTexture;
             GadgetCoreAPI.AddCustomResource("r/r" + ID + "v" + i, VariantMats[i]);
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     if (Mat == null && Tex != null)
     {
         Mat = new Material(Shader.Find("Unlit/Transparent Cutout"))
         {
             mainTexture = Tex
         };
     }
     else if (Mat != null)
     {
         Tex = Mat.mainTexture as Texture2D;
     }
     if (Type == TileType.SOLID || Type == TileType.WALL)
     {
         if (Tex != null)
         {
             Sprite = GadgetCoreAPI.AddTextureToSheet(Tex);
         }
     }
     if (Mat != null)
     {
         GadgetCoreAPI.AddCustomResource("construct/c" + ID, Mat);
     }
     if (Prop != null)
     {
         if (Type == TileType.INTERACTIVE)
         {
             Prop.layer = 12;
             GadgetCoreAPI.AddCustomResource("npc/npc" + ID, Prop);
             if (Mat != null)
             {
                 if (Item != null && Item.ID > 0)
                 {
                     GadgetCoreAPI.AddCustomResource("mat/por/portrait" + ID, Mat);
                 }
                 else
                 {
                     Material portraitMat = new Material(Mat.shader);
                     portraitMat.CopyPropertiesFromMaterial(Mat);
                     portraitMat.mainTextureScale = new Vector2(0.5f, 1);
                     GadgetCoreAPI.AddCustomResource("mat/por/portrait" + ID, portraitMat);
                 }
             }
         }
         else
         {
             GadgetCoreAPI.AddCustomResource("prop/" + ID, Prop);
         }
     }
     if (Item != null && Item.ID > 0)
     {
         Item.SetTile(this);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     if (Mat == null)
     {
         Mat = new Material(Shader.Find("Unlit/Transparent"))
         {
             mainTexture = Tex
         };
     }
     else
     {
         Tex = Mat.mainTexture;
     }
     GadgetCoreAPI.AddCustomResource("cc/cc" + ID, Mat);
 }
        /// <summary>
        /// Spawns this entity's drops locally.
        /// </summary>
        protected virtual void DropLocal()
        {
            GadgetCoreAPI.SpawnExp(transform.position, EXP);

            foreach (Tuple <int, int, int> currencyDrop in currencyDrops)
            {
                int quantity = currencyDrop.Item2 + UnityEngine.Random.Range(0, currencyDrop.Item3 + 1);
                if (quantity > 0)
                {
                    GadgetCoreAPI.SpawnItemLocal(transform.position, new Item(currencyDrop.Item1, quantity, 0, 0, 0, new int[3], new int[3]));
                }
            }

            if (vanillaStyleDrops != null)
            {
                int num  = UnityEngine.Random.Range(0, 100);
                int num2 = UnityEngine.Random.Range(0, 90);
                num2 += (int)(PlayerGearModsTracker.GetGearMods(FindObjectsOfType <PlayerScript>().MinBy(x => (x.transform.position - transform.position).sqrMagnitude))[21] * 1.5);
                int num3 = 1;
                if (num2 > 110)
                {
                    num3 = 5;
                }
                else if (num2 > 100)
                {
                    num3 = 4;
                }
                else if (num2 > 90)
                {
                    num3 = 3;
                }
                else if (num2 > 80)
                {
                    num3 = 2;
                }

                Item vanillaDrop = new Item(num < 20 ? vanillaStyleDrops[2] : num < 45 ? vanillaStyleDrops[1] : num < 75 ? vanillaStyleDrops[0] : vanillaStyleDrops[3], num3, 0, 0, 0, new int[3], new int[3]);

                if (vanillaDrop.id > 0)
                {
                    GadgetCoreAPI.SpawnItemLocal(transform.position, vanillaDrop);
                }
            }

            LootTables.DropLoot(LootTableID, transform.position);
        }
Esempio n. 8
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 public override void PostRegister()
 {
     if (Mat == null && Tex != null)
     {
         Mat = new Material(Shader.Find("Unlit/Transparent Cutout"))
         {
             mainTexture = Tex
         };
     }
     else if (Mat != null)
     {
         Tex = Mat.mainTexture as Texture2D;
     }
     if (Type == TileType.SOLID || Type == TileType.WALL)
     {
         if (Tex != null)
         {
             Sprite = GadgetCoreAPI.AddTextureToSheet(Tex);
         }
     }
     if (Mat != null)
     {
         GadgetCoreAPI.AddCustomResource("construct/c" + ID, Mat);
     }
     if (Prop != null)
     {
         if (Type == TileType.INTERACTIVE)
         {
             Prop.layer = 12;
             GadgetCoreAPI.AddCustomResource("npc/npc" + ID, Prop);
         }
         else
         {
             GadgetCoreAPI.AddCustomResource("prop/" + ID, Prop);
         }
     }
     if (Item != null && Item.ID > 0)
     {
         Item.SetTile(this);
     }
 }
Esempio n. 9
0
 public bool TryDrop(Vector3 pos)
 {
     if (CheckValidToDrop == null || CheckValidToDrop(pos))
     {
         if (dropChance <= 0)
         {
             return(false);
         }
         if (UnityEngine.Random.value <= dropChance)
         {
             if (isChip || (ItemRegistry.GetTypeByID(itemToDrop.id) & ItemType.NONSTACKING) == ItemType.NONSTACKING)
             {
                 if (itemToDrop != null)
                 {
                     itemToDrop.q = 1;
                 }
                 for (int i = 0; i < Mathf.RoundToInt(UnityEngine.Random.value * (maxDropQuantity - minDropQuantity)) + minDropQuantity; i++)
                 {
                     if ((CustomDropBehavior == null || CustomDropBehavior(itemToDrop, pos)) && itemToDrop != null)
                     {
                         GadgetCoreAPI.SpawnItemLocal(pos, itemToDrop, isChip);
                     }
                 }
             }
             else
             {
                 if (itemToDrop != null)
                 {
                     itemToDrop.q = Mathf.RoundToInt(UnityEngine.Random.value * (maxDropQuantity - minDropQuantity)) + minDropQuantity;
                 }
                 if ((CustomDropBehavior == null || CustomDropBehavior(itemToDrop, pos)) && itemToDrop != null)
                 {
                     GadgetCoreAPI.SpawnItemLocal(pos, itemToDrop, isChip);
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Esempio n. 10
0
 /// <summary>
 /// Constructs a new VanillaItemInfo based upon the given ID. Do not try to call this yourself - use <see cref="Wrap"/>
 /// </summary>
 /// <param name="ID">The vanilla ID to be wrapped.</param>
 /// <param name="WrapForTile">If true, the Tile property should not be set by this constructor, as it will be set later as part of a TileInfo's constructor.</param>
 protected VanillaItemInfo(int ID, bool WrapForTile) : base(ItemRegistry.GetDefaultTypeByID(ID), GadgetCoreAPI.GetItemName(ID), GadgetCoreAPI.GetItemDesc(ID), GadgetCoreAPI.GetItemMaterial(ID), -1, GadgetCoreAPI.GetTrueGearBaseStats(ID), GadgetCoreAPI.GetWeaponMaterial(ID), ID >= 1000 && ID < 2000 ? GadgetCoreAPI.GetDroidHeadMaterial(ID) : GadgetCoreAPI.GetHeadMaterial(ID), ID >= 1000 && ID < 2000 ? GadgetCoreAPI.GetDroidBodyMaterial(ID) : GadgetCoreAPI.GetBodyMaterial(ID), GadgetCoreAPI.GetArmMaterial(ID))
 {
     this.ID = ID;
     if ((Type & ItemType.EQUIP_MASK) == (ItemType.WEAPON & ItemType.EQUIP_MASK))
     {
         SetWeaponInfo(ItemRegistry.GetDefaultWeaponScalingByID(ID), GadgetCoreAPI.GetAttackSound(ID), ItemRegistry.GetDefaultCritChanceBonus(ID), ItemRegistry.GetDefaultCritPowerBonus(ID), ID);
         OnAttack += (script) => { Attacking = true; IEnumerator ie = script.Attack(); Attacking = false; return(ie); };
     }
     else if ((Type & ItemType.USABLE) == ItemType.USABLE)
     {
         OnUse += (slot) => { Using = true; InstanceTracker.GameScript.StartCoroutine(InstanceTracker.GameScript.UseItemFinal(slot)); return(false); };
     }
     if (!WrapForTile)
     {
         if (TileRegistry.Singleton.HasEntry(ID))
         {
             SetTile(TileRegistry.Singleton.GetEntry(ID));
         }
         else
         {
             SetTile(VanillaTileInfo.Wrap(ID, false));
         }
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Constructs a new VanillaItemInfo based upon the given ID. Do not try to call this yourself - use <see cref="Wrap"/>
 /// </summary>
 /// <param name="ID">The vanilla ID to be wrapped.</param>
 /// <param name="registerItem">Whether the VanillaItemInfo that matches this Tile ID should be wrapped into the ItemRegistry.</param>
 protected VanillaTileInfo(int ID, bool registerItem = false) : base(TileRegistry.GetDefaultTypeByID(ID), GadgetCoreAPI.GetTileMaterial(ID), TileRegistry.GetDefaultTypeByID(ID) == TileType.INTERACTIVE ? GadgetCoreAPI.GetPlaceableNPCResource(ID) : GadgetCoreAPI.GetPropResource(ID), VanillaItemInfo.WrapForTile(ID, registerItem))
 {
     this.ID = ID;
 }
Esempio n. 12
0
        /// <summary>
        /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
        /// </summary>
        protected internal override void PostRegister()
        {
            if (Mat == null)
            {
                Mat = new Material(Shader.Find("Unlit/Transparent Cutout"))
                {
                    mainTexture = Tex
                };
                Mat.SetFloat("_Cutoff", 0.5f);
            }
            else
            {
                Tex = Mat.mainTexture;
            }
            if (FlyHeadTex != null || FlyHeadMat != null)
            {
                if (FlyHeadMat == null)
                {
                    FlyHeadMat = new Material(Shader.Find("Unlit/Transparent Cutout"))
                    {
                        mainTexture = FlyHeadTex
                    };
                    FlyHeadMat.SetFloat("_Cutoff", 0.5f);
                }
                else
                {
                    FlyHeadTex = FlyHeadMat.mainTexture;
                }
            }
            if (FlyWingTex != null || FlyWingMat != null)
            {
                if (FlyWingMat == null)
                {
                    FlyWingMat = new Material(Shader.Find("Unlit/Transparent Cutout"))
                    {
                        mainTexture = FlyWingTex
                    };
                    FlyWingMat.SetFloat("_Cutoff", 0.5f);
                }
                else
                {
                    FlyWingTex = FlyWingMat.mainTexture;
                }
            }

            string name;

            switch (Type)
            {
            case ObjectType.ORE:
                name = "ore";
                break;

            case ObjectType.TREE:
                name = "tree";
                break;

            case ObjectType.PLANT:
                name = "plant";
                break;

            case ObjectType.BUGSPOT:
                name = "bugspot";
                break;

            default:
                name = "object";
                break;
            }

            Object      = UnityEngine.Object.Instantiate((GameObject)Resources.Load("obj/" + (name != "object" && FlyHeadMat == null && FlyWingMat == null ? name : "bugspot") + "0"));
            Object.name = name;

            ObjectScript script = Object.GetComponent <ObjectScript>();

            script.id = GetID();
            script.b.GetComponent <MeshRenderer>().material = Mat;
            script.GetComponent <BoxCollider>().center     += (Vector3)ColliderOffset;

            if (script.b.transform.childCount > 0)
            {
                Transform fly = script.b.transform.GetChild(0).GetChild(0);
                if (fly.name == "fly")
                {
                    foreach (Transform child in fly)
                    {
                        if (child.name == "Plane")
                        {
                            if (FlyHeadMat != null)
                            {
                                child.GetComponent <MeshRenderer>().material = FlyHeadMat;
                            }
                        }
                        else if (child.name.StartsWith("Plane"))
                        {
                            if (FlyHeadMat != null)
                            {
                                child.GetComponent <MeshRenderer>().material = FlyWingMat;
                            }
                        }
                    }
                }
            }

            GadgetCoreAPI.AddCustomResource(ResourcePath = "obj/" + name + ID, Object);
        }
Esempio n. 13
0
 /// <summary>
 /// Generates a standard SlotValidator/CraftValidator/CraftPerformer trio using a simple set of input IDs and an output Item
 /// </summary>
 /// <param name="recipes">A list of recipes consisting of the ingredient IDs, the item output, and the amount of possible random extra output.</param>
 public static Tuple <SlotValidator, CraftValidator, CraftPerformer> CreateSimpleCraftPerformer(params Tuple <int[], Item, int>[] recipes)
 {
     return(Tuple.Create <SlotValidator, CraftValidator, CraftPerformer>((Item newItem, Item[] items, int slot) =>
     {
         return recipes.Any(x => x.Item1.Length > slot && newItem.id == x.Item1[slot]);
     }, (Item[] items) =>
     {
         return recipes.Any(x =>
         {
             for (int i = 0; i < x.Item1.Length; i++)
             {
                 if (x.Item1[i] > 0 && (items.Length <= i || items[i] == null || items[i].q < 1 || items[i].id != x.Item1[i]))
                 {
                     return false;
                 }
             }
             return items[items.Length - 1] == null || items[items.Length - 1].q == 0 || (GadgetCoreAPI.CanItemsStack(items[items.Length - 1], x.Item2) && items[items.Length - 1].q + x.Item2.q + x.Item3 <= 9999);
         });
     }, (Item[] items) =>
     {
         foreach (Tuple <int[], Item, int> recipe in recipes)
         {
             bool recipeValid = true;
             for (int i = 0; i < recipe.Item1.Length; i++)
             {
                 if (recipe.Item1[i] > 0 && (items.Length <= i || items[i] == null || items[i].q < 1 || items[i].id != recipe.Item1[i]))
                 {
                     recipeValid = false;
                     break;
                 }
             }
             if (recipeValid)
             {
                 for (int i = 0; i < recipe.Item1.Length; i++)
                 {
                     if (recipe.Item1[i] > 0)
                     {
                         items[i].q--;
                     }
                 }
                 if (items[items.Length - 1].id == recipe.Item2.id && items[items.Length - 1].q > 0)
                 {
                     items[items.Length - 1].q += recipe.Item2.q;
                 }
                 else
                 {
                     items[items.Length - 1] = GadgetCoreAPI.CopyItem(recipe.Item2);
                 }
                 if (recipe.Item3 > 0)
                 {
                     items[items.Length - 1].q += UnityEngine.Random.Range(0, recipe.Item3 + 1);
                 }
                 if (recipe.Item3 < 0)
                 {
                     items[items.Length - 1].q -= UnityEngine.Random.Range(0, -recipe.Item3 + 1);
                 }
                 break;
             }
         }
     }));
 }
Esempio n. 14
0
        /// <summary>
        /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
        /// </summary>
        protected internal override void PostRegister()
        {
            base.PostRegister();

            if (MenuMat == null)
            {
                MenuMat = new Material(Shader.Find("Unlit/Transparent"))
                {
                    mainTexture = MenuTex
                };
            }
            else
            {
                MenuTex = MenuMat.mainTexture;
            }
            GadgetCoreAPI.AddCustomResource("mat/craftMenu" + ID, MenuMat);
            if (ProgressBarMat == null)
            {
                ProgressBarMat = new Material(Shader.Find("Unlit/Transparent"))
                {
                    mainTexture = ProgressBarTex
                };
            }
            else
            {
                ProgressBarTex = ProgressBarMat.mainTexture;
            }
            GadgetCoreAPI.AddCustomResource("mat/craftBar" + ID, ProgressBarMat);
            if (ButtonInactiveMat == null)
            {
                ButtonInactiveMat = new Material(Shader.Find("Unlit/Transparent"))
                {
                    mainTexture = ButtonInactiveTex
                };
            }
            else
            {
                ButtonInactiveTex = ButtonInactiveMat.mainTexture;
            }
            GadgetCoreAPI.AddCustomResource("mat/craftButtonInactive" + ID, ButtonInactiveMat);
            if (ButtonActiveMat == null)
            {
                ButtonActiveMat = new Material(Shader.Find("Unlit/Transparent"))
                {
                    mainTexture = ButtonActiveTex
                };
            }
            else
            {
                ButtonActiveTex = ButtonActiveMat.mainTexture;
            }
            GadgetCoreAPI.AddCustomResource("mat/craftButtonActive" + ID, ButtonActiveMat);
            if (ButtonSelectMat == null)
            {
                ButtonSelectMat = new Material(Shader.Find("Unlit/Transparent"))
                {
                    mainTexture = ButtonSelectTex
                };
            }
            else
            {
                ButtonSelectTex = ButtonSelectMat.mainTexture;
            }
            GadgetCoreAPI.AddCustomResource("mat/craftButtonSelect" + ID, ButtonSelectMat);
        }
Esempio n. 15
0
 /// <summary>
 /// Returns the player name of the given <see cref="NetworkPlayer"/>
 /// </summary>
 public static string GetNameByNetworkPlayer(NetworkPlayer player)
 {
     return(NamesByNetworkPlayer.TryGetValue(player, out string name) ? name : player == Network.player ? GadgetCoreAPI.GetPlayerName() : null);
 }
Esempio n. 16
0
 /// <summary>
 /// Returns the <see cref="NetworkPlayer"/> with the given player name
 /// </summary>
 public static NetworkPlayer?GetNetworkPlayerByName(string name)
 {
     return(NetworkPlayersByName.TryGetValue(name, out NetworkPlayer player) ? (NetworkPlayer?)player : name == GadgetCoreAPI.GetPlayerName() ? (NetworkPlayer?)Network.player : null);
 }
Esempio n. 17
0
        /// <summary>
        /// Prompts this resource node to drop one hit's worth of items.
        /// </summary>
        public virtual void DropItem(Vector3 pos)
        {
            GameObject drop = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("i3"), pos, Quaternion.identity);

            int[] st = GadgetCoreAPI.ConstructIntArrayFromItem(ItemDrop);
            st[1] += UnityEngine.Random.Range(0, RandomDropBonus + 1);
            if (GameScript.challengeLevel > 0)
            {
                if (UnityEngine.Random.Range(0, 200) < GameScript.challengeLevel * 2)
                {
                    Camera.main.SendMessage("AUDSPEC2", SendMessageOptions.DontRequireReceiver);
                    int[] array = new int[11];
                    array[0] = UnityEngine.Random.Range(201, 221);
                    array[1] = 1;
                    int[]      value      = array;
                    GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("i3"), pos, Quaternion.identity);
                    gameObject.SendMessage("InitL", value);
                }
                if (UnityEngine.Random.Range(0, 200) < GameScript.challengeLevel)
                {
                    Camera.main.SendMessage("AUDSPEC3", SendMessageOptions.DontRequireReceiver);
                    int[] array2 = new int[11];
                    array2[0] = UnityEngine.Random.Range(86, 89);
                    array2[1] = 1;
                    int[]      value2      = array2;
                    GameObject gameObject2 = (GameObject)UnityEngine.Object.Instantiate(Resources.Load("i3"), pos, Quaternion.identity);
                    gameObject2.SendMessage("InitL", value2);
                }
            }
            int randomBonus = UnityEngine.Random.Range(0, 90);

            if (Type == ObjectType.ORE)
            {
                randomBonus += (int)(GameScript.MODS[19] * 1.5f);
            }
            else if (Type == ObjectType.TREE || Type == ObjectType.PLANT)
            {
                randomBonus += (int)(GameScript.MODS[20] * 1.5f);
            }
            else if (Type == ObjectType.BUGSPOT)
            {
                randomBonus += (int)(GameScript.MODS[22] * 1.5f);
            }
            if (randomBonus > 110)
            {
                st[1] += 4;
            }
            else if (randomBonus > 100)
            {
                st[1] += 3;
            }
            else if (randomBonus > 90)
            {
                st[1] += 2;
            }
            else if (randomBonus > 80)
            {
                st[1] += 1;
            }
            drop.SendMessage("InitL", st);
        }
Esempio n. 18
0
        /// <summary>
        /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
        /// </summary>
        protected internal override void PostRegister()
        {
            if (GetEntryType() != PlanetType.SPECIAL || EntranceMat != null || EntranceTex != null)
            {
                if (EntranceMat == null)
                {
                    EntranceMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = EntranceTex
                    };
                }
                else
                {
                    EntranceTex = EntranceMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("z/entrance" + ID, EntranceMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || ZoneMat != null || ZoneTex != null)
            {
                if (ZoneMat == null)
                {
                    ZoneMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = ZoneTex
                    };
                }
                else
                {
                    ZoneTex = ZoneMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("z/z" + ID, ZoneMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || MidChunk0Mat != null || MidChunk0Tex != null)
            {
                if (MidChunk0Mat == null)
                {
                    MidChunk0Mat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = MidChunk0Tex
                    };
                }
                else
                {
                    MidChunk0Tex = MidChunk0Mat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("z/midChunk0b" + ID, MidChunk0Mat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || MidChunk1Mat != null || MidChunk1Tex != null)
            {
                if (MidChunk1Mat == null)
                {
                    MidChunk1Mat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = MidChunk1Tex
                    };
                }
                else
                {
                    MidChunk1Tex = MidChunk1Mat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("z/midChunk1b" + ID, MidChunk1Mat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || SideHMat != null || SideHTex != null)
            {
                if (SideHMat == null)
                {
                    SideHMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = SideHTex
                    };
                }
                else
                {
                    SideHTex = SideHMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("side/sideH" + ID, SideHMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || SideVMat != null || SideVTex != null)
            {
                if (SideVMat == null)
                {
                    SideVMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = SideVTex
                    };
                }
                else
                {
                    SideVTex = SideVMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("side/sideV" + ID, SideVMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || PortalSignMat != null || PortalSignTex != null)
            {
                if (PortalSignMat == null)
                {
                    PortalSignMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = PortalSignTex
                    };
                }
                else
                {
                    PortalSignTex = PortalSignMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("sign/sign" + ID, PortalSignMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || SelectorButtonMat != null || SelectorButtonTex != null)
            {
                if (SelectorButtonMat == null)
                {
                    SelectorButtonMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = SelectorButtonTex
                    };
                }
                else
                {
                    SelectorButtonTex = SelectorButtonMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("mat/planetIcon" + ID, SelectorButtonMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || SelectorIconMat != null || SelectorIconTex != null)
            {
                if (SelectorIconMat == null)
                {
                    SelectorIconMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = SelectorIconTex
                    };
                }
                else
                {
                    SelectorIconTex = SelectorIconMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("mat/planet" + ID, SelectorIconMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || BackgroundParallaxMat != null || BackgroundParallaxTex != null)
            {
                if (BackgroundParallaxMat == null)
                {
                    BackgroundParallaxMat = new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = BackgroundParallaxTex
                    };
                }
                else
                {
                    BackgroundParallaxTex = BackgroundParallaxMat.mainTexture;
                }
                GadgetCoreAPI.AddCustomResource("par/parallax" + ID, BackgroundParallaxMat);
            }
            if (GetEntryType() != PlanetType.SPECIAL || BackgroundImageMats != null || BackgroundImageTexes != null)
            {
                if (BackgroundImageMats == null)
                {
                    BackgroundImageMats = BackgroundImageTexes?.Select(x => new Material(Shader.Find("Unlit/Transparent"))
                    {
                        mainTexture = x
                    }).ToArray();
                }
                else
                {
                    BackgroundImageTexes = BackgroundImageMats.Select(x => x.mainTexture).ToArray();
                }
                for (int i = 0; i < BackgroundImageMats.Length; i++)
                {
                    GadgetCoreAPI.AddCustomResource("bg/b" + ID + "bg" + i, BackgroundImageMats[i]);
                }
            }

            if (BackgroundMusic != null)
            {
                GadgetCoreAPI.AddCustomResource("Au/biome" + ID, BackgroundMusic);
            }

            for (int i = 0; i < WeightedExitPortalIDs.Count; i++)
            {
                if (WeightedExitPortalIDs[i].Item1 == -1)
                {
                    WeightedExitPortalIDs[i] = Tuple.Create(ID, WeightedExitPortalIDs[i].Item2);
                }
            }
        }
Esempio n. 19
0
 /// <summary>
 /// Called after this Registry Entry has been registered to its Registry. You should never call this yourself.
 /// </summary>
 protected internal override void PostRegister()
 {
     base.PostRegister();
     GadgetCoreAPI.AddCustomResource("aug/aug" + ID, Mat);
 }
Esempio n. 20
0
 /// <summary>
 /// Constructs a new VanillaItemInfo based upon the given ID. Do not try to call this yourself - use <see cref="Wrap"/>
 /// </summary>
 /// <param name="ID">The vanilla ID to be wrapped.</param>
 protected VanillaTileInfo(int ID) : base(TileRegistry.GetDefaultTypeByID(ID), GadgetCoreAPI.GetTileMaterial(ID), TileRegistry.GetDefaultTypeByID(ID) == TileType.INTERACTIVE ? GadgetCoreAPI.GetPlaceableNPCResource(ID) : GadgetCoreAPI.GetPropResource(ID), ItemRegistry.GetSingleton().HasEntry(ID) ? ItemRegistry.GetSingleton().GetEntry(ID) : VanillaItemInfo.WrapForTile(ID, false))
 {
     this.ID = ID;
 }
 /// <summary>
 /// In theory, returns the gear mods that the given player has, in the same format as GameScript.MODS. In practice, it currently just returns GameScript.MODS.
 /// This exists so that Gadget Core can later add this functionality without it being a breaking change.
 /// As such, whenever you need to query what gear mods the player has, you should use this.
 /// </summary>
 public static int[] GetGearMods(this NetworkPlayer player)
 {
     return(GetGearMods(GadgetCoreAPI.GetPlayerByName(GadgetNetwork.GetNameByNetworkPlayer(player))));
 }