public static void SetBehindCharacter(this FacegearInfo xInfo, bool bUp, bool bRight, bool bDown, bool bLeft) { xInfo.abBehindCharacter[0] = bUp; xInfo.abBehindCharacter[1] = bRight; xInfo.abBehindCharacter[2] = bDown; xInfo.abBehindCharacter[3] = bLeft; }
public static void SetOverHat(this FacegearInfo xInfo, bool bUp, bool bRight, bool bDown, bool bLeft) { xInfo.abOverHat[0] = bUp; xInfo.abOverHat[1] = bRight; xInfo.abOverHat[2] = bDown; xInfo.abOverHat[3] = bLeft; }
/// <summary> Patches GetFacegearInfo so that SoG can use modded FacegearInfos. </summary> private static bool GetFacegearInfo_PrefixPatch(ref FacegearInfo __result, ItemCodex.ItemTypes enType) { if (enType.IsModItem()) { __result = ModLibrary.ItemDetails[enType].xEquipmentData as FacegearInfo; return(false); // Skip original method } return(true); // Execute original method }
/// <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); }
public static void SetRenderOffsets(this FacegearInfo xInfo, Vector2 v2Up, Vector2 v2Right, Vector2 v2Down, Vector2 v2Left) { if (v2Up != null) { xInfo.av2RenderOffsets[0] = new Vector2(v2Up.X, v2Up.Y); } if (v2Right != null) { xInfo.av2RenderOffsets[1] = new Vector2(v2Right.X, v2Right.Y); } if (v2Down != null) { xInfo.av2RenderOffsets[2] = new Vector2(v2Down.X, v2Down.Y); } if (v2Left != null) { xInfo.av2RenderOffsets[3] = new Vector2(v2Left.X, v2Left.Y); } }
/// <summary> /// Sets resources used by the FacegearInfo. /// <para>The path to the textures are of format "Sprites/Equipment/Facegear/[resource]/[Up, Right, Down or Left].xnb"</para> /// </summary> public static void SetResource(this FacegearInfo xInfo, string sResource, ContentManager xContent) { string sHatPath = "Sprites/Equipment/Facegear/" + sResource + "/"; try { xInfo.atxTextures[0] = xContent.Load <Texture2D>(sHatPath + "Up"); xInfo.atxTextures[1] = xContent.Load <Texture2D>(sHatPath + "Right"); xInfo.atxTextures[2] = xContent.Load <Texture2D>(sHatPath + "Down"); xInfo.atxTextures[3] = xContent.Load <Texture2D>(sHatPath + "Left"); } catch (Exception e) { Console.WriteLine("Facegear texture load failed. Exception: " + e.Message); xInfo.atxTextures[0] = RenderMaster.txNullTex; xInfo.atxTextures[1] = RenderMaster.txNullTex; xInfo.atxTextures[2] = RenderMaster.txNullTex; xInfo.atxTextures[3] = RenderMaster.txNullTex; } }