Example #1
0
        /// <summary>
        /// Creates an alternative style for the HatInfo's item, which is activated while wearing the enCombo item.
        /// <para>The paths to the texture are of format "Sprites/Equipment/Hats/[resource]/[Up, Right, Down or Left].xnb"</para>
        /// </summary>
        /// <remarks>You can set resource to something like "[hatResource]/[comboResource]/" to keep the textures for default and alternate set in the same hat folder.</remarks>
        public static void AddAltSet(this HatInfo xInfo, ItemCodex.ItemTypes enCombo, string sResource, ContentManager xContent)
        {
            if (!xInfo.denxAlternateVisualSets.ContainsKey(enCombo))
            {
                xInfo.denxAlternateVisualSets[enCombo] = new HatInfo.VisualSet();
            }

            string sHatPath = "Sprites/Equipment/Hats/" + sResource + "/";

            HatInfo.VisualSet xAlt = xInfo.denxAlternateVisualSets[enCombo];

            try
            {
                xAlt.atxTextures[0] = xContent.Load <Texture2D>(sHatPath + "Up");
                xAlt.atxTextures[1] = xContent.Load <Texture2D>(sHatPath + "Right");
                xAlt.atxTextures[2] = xContent.Load <Texture2D>(sHatPath + "Down");
                xAlt.atxTextures[3] = xContent.Load <Texture2D>(sHatPath + "Left");

                xInfo.sResourceName = sResource;
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to load a texture in AddAltSet.");
                Console.WriteLine("Exception: " + e.Message);
                xAlt.atxTextures[0] = RenderMaster.txNullTex;
                xAlt.atxTextures[1] = RenderMaster.txNullTex;
                xAlt.atxTextures[2] = RenderMaster.txNullTex;
                xAlt.atxTextures[3] = RenderMaster.txNullTex;

                xInfo.sResourceName = "";
            }
        }
Example #2
0
 /// <summary> Patches GetHatInfo so that SoG can use modded HatInfos. </summary>
 private static bool GetHatInfo_PrefixPatch(ref HatInfo __result, ItemCodex.ItemTypes enType)
 {
     if (enType.IsModItem())
     {
         __result = ModLibrary.ItemDetails[enType].xEquipmentData as HatInfo;
         return(false); // Skip original method
     }
     return(true);      // Execute original method
 }
Example #3
0
        /// <summary>
        /// Creates a new EquipmentInfo derived object that can be used by the game.
        /// For shields, the paths to the textures are similar to the SoG paths, except "Shields/" substring is removed.
        /// </summary>
        /// <returns> Either a new or existing object of type T. If item has an existing object with an incompatible type, returns null. </returns>
        /// <exception cref="ArgumentException"></exception>
        public static T CreateInfo <T>(this ItemDescription xDesc, string sResource, ContentManager xContent) where T : EquipmentInfo
        {
            if (!xDesc.enType.IsModItem())
            {
                throw new ArgumentException("Provided enType is not a mod item.");
            }

            EquipmentInfo xInfo;

            if (ModLibrary.ItemDetails.ContainsKey(xDesc.enType))
            {
                xInfo = ModLibrary.ItemDetails[xDesc.enType].xEquipmentData;
                if (xInfo != null)
                {
                    if (xInfo.GetType() == typeof(T))
                    {
                        return(xInfo as T);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }

            switch (typeof(T).Name)
            {
            case "EquipmentInfo":
                xInfo = new EquipmentInfo(sResource, xDesc.enType);
                break;

            case "FacegearInfo":
                FacegearInfo xFacegear = (FacegearInfo)(xInfo = new FacegearInfo(xDesc.enType));
                xFacegear.SetResource(sResource, xContent);
                break;

            case "HatInfo":
                HatInfo xHat = (HatInfo)(xInfo = new HatInfo(xDesc.enType));
                xHat.SetResource(sResource, xContent);
                break;

            case "WeaponInfo":
                WeaponInfo xWeapon = (WeaponInfo)(xInfo = new WeaponInfo("", xDesc.enType, WeaponInfo.WeaponCategory.OneHanded));
                xWeapon.SetResource(sResource, xContent);
                xWeapon.SetWeaponType(WeaponInfo.WeaponCategory.OneHanded, false);
                break;

            default:
                throw new ArgumentException("Received a non-vanilla Info type! Preposterous!");
            }

            ModLibrary.ItemDetails[xDesc.enType].xEquipmentData = xInfo;

            return(xInfo as T);
        }
Example #4
0
        /// <summary>
        /// Sets resources used by the HatInfo.
        /// <para>The path to the textures are of format "Sprites/Equipment/Hats/[resource]/[Up, Right, Down or Left].xnb"</para>
        /// </summary>
        public static void SetResource(this HatInfo xInfo, string sResource, ContentManager xContent)
        {
            string sHatPath = "Sprites/Equipment/Hats/" + sResource + "/";

            try
            {
                xInfo.xDefaultSet.atxTextures[0] = xContent.Load <Texture2D>(sHatPath + "Up");
                xInfo.xDefaultSet.atxTextures[1] = xContent.Load <Texture2D>(sHatPath + "Right");
                xInfo.xDefaultSet.atxTextures[2] = xContent.Load <Texture2D>(sHatPath + "Down");
                xInfo.xDefaultSet.atxTextures[3] = xContent.Load <Texture2D>(sHatPath + "Left");

                xInfo.sResourceName = sResource;
            }
            catch (Exception e)
            {
                Console.WriteLine("Facegear texture load failed. Exception: " + e.Message);
                xInfo.xDefaultSet.atxTextures[0] = RenderMaster.txNullTex;
                xInfo.xDefaultSet.atxTextures[1] = RenderMaster.txNullTex;
                xInfo.xDefaultSet.atxTextures[2] = RenderMaster.txNullTex;
                xInfo.xDefaultSet.atxTextures[3] = RenderMaster.txNullTex;

                xInfo.sResourceName = "";
            }
        }