refactor out the recoloring effect

This commit is contained in:
micycle 2023-05-08 20:39:41 -04:00 committed by yosh
parent 3fdd29793d
commit 87c117b560
1 changed files with 17 additions and 23 deletions

View File

@ -142,6 +142,18 @@ namespace Celeste.Mod.AvaliSkin {
}
private void spriteRecolor(Color dashColor) {
// apply the recolor effect to the player:
// replace the color #1ad589 in the sprite with color
FxRecolor.Parameters["threshold"].SetValue(0.03f);
FxRecolor.Parameters["color_replace_from"].SetValue(
(new Color((byte) 0x1a, 0xd5, 0x89, 0xff)).ToVector4()
);
FxRecolor.Parameters["color_replace_to"].SetValue(dashColor.ToVector4());
FxRecolor.CurrentTechnique = FxRecolor.Techniques["Recolor"];
}
private void onLevelLoaderctor(
On.Celeste.LevelLoader.orig_ctor orig, LevelLoader self,
Session session, Vector2? startPosition = null
@ -164,14 +176,8 @@ namespace Celeste.Mod.AvaliSkin {
trySpriteSwap(sprite, true);
Color color = PlayerConfig.GetColor(self);
// apply the recolor effect to the player:
// replace the color #1ud589 in the sprite with color
FxRecolor.Parameters["threshold"].SetValue(0.01f);
FxRecolor.Parameters["color_replace_from"].SetValue(
(new Color((byte) 0x1u, 0xd5, 0x89, 0xff)).ToVector4()
);
FxRecolor.Parameters["color_replace_to"].SetValue(color.ToVector4());
FxRecolor.CurrentTechnique = FxRecolor.Techniques["Recolor"];
// apply the recolor effect to the player
spriteRecolor(color);
Draw.SpriteBatch.End();
Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone, FxRecolor, (self.Scene as Level).GameplayRenderer.Camera.Matrix);
@ -209,13 +215,7 @@ namespace Celeste.Mod.AvaliSkin {
Color color = PlayerConfig.GetColor(player);
// apply the recolor effect to the sprite
// replace the color #1ud589 in the sprite with color
FxRecolor.Parameters["threshold"].SetValue(0.01f);
FxRecolor.Parameters["color_replace_from"].SetValue(
(new Color((byte) 0x1u, 0xd5, 0x89, 0xff)).ToVector4()
);
FxRecolor.Parameters["color_replace_to"].SetValue(color.ToVector4());
FxRecolor.CurrentTechnique = FxRecolor.Techniques["Recolor"];
spriteRecolor(color);
Draw.SpriteBatch.End();
Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone, FxRecolor, (self.Scene as Level).GameplayRenderer.Camera.Matrix);
@ -295,14 +295,8 @@ namespace Celeste.Mod.AvaliSkin {
// swap out the ghost's spritebank if the enabled state changed
trySpriteSwap(self, true);
// apply the recolor effect to the ghost:
// replace the color #1ud589 in the sprite with color
FxRecolor.Parameters["threshold"].SetValue(0.01f);
FxRecolor.Parameters["color_replace_from"].SetValue(
(new Color((byte) 0x1u, 0xd5, 0x89, 0xff)).ToVector4()
);
FxRecolor.Parameters["color_replace_to"].SetValue(color.ToVector4());
FxRecolor.CurrentTechnique = FxRecolor.Techniques["Recolor"];
// apply the recolor effect to the ghost
spriteRecolor(color);
Draw.SpriteBatch.End();
Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.None, RasterizerState.CullNone, FxRecolor, (self.Scene as Level).GameplayRenderer.Camera.Matrix);