Beispiel #1
0
 public static bool DoDraw(SpriteBatch __instance, Texture2D texture, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth)
 {
     if (texture is Texture2DWrapper wrapper)
     {
         sourceRectangle = Texture2DWrapper.MultiplyRect(sourceRectangle, wrapper.Scale);
         __instance.Draw(wrapper.Wrapped, destinationRectangle, sourceRectangle, color, rotation, origin * wrapper.Scale, effects, layerDepth);
         return(false);
     }
     return(true);
 }
 public static bool PatchImage(IAssetDataForImage __instance, Texture2D source, Rectangle?sourceArea, Rectangle?targetArea, PatchMode patchMode)
 {
     if (__instance.Data is Texture2DWrapper wrapper)
     {
         if (sourceArea.HasValue)
         {
             source = Texture2DWrapper.Crop(source, sourceArea.Value);
         }
         source = Texture2DWrapper.ScaleUp(source, wrapper.Scale);
         if (targetArea.HasValue)
         {
             targetArea = Texture2DWrapper.MultiplyRect(targetArea.Value, wrapper.Scale);
         }
         PropertyInfo Data = __instance.GetType().GetProperty("Data");
         Data.SetValue(__instance, wrapper.Wrapped);
         __instance.PatchImage(source, null, targetArea, patchMode);
         Data.SetValue(__instance, wrapper);
         return(false);
     }
     return(true);
 }