@@ -8,21 +8,23 @@ namespace TrollMod17.Cosmetics;
88
99public static class AbilityCosmetics
1010{
11- // Among Us native cosmetics-backed state
1211 private static readonly Dictionary < PlayerControl , float > _savedPhantomAlpha = new ( ) ;
1312 private static readonly HashSet < PlayerControl > _shielded = new ( ) ;
1413 private static readonly HashSet < PlayerControl > _smoked = new ( ) ;
14+ private static readonly Dictionary < PlayerControl , Color > _originalColors = new ( ) ;
15+ private static readonly HashSet < PlayerControl > _tuned = new ( ) ;
16+ private static readonly HashSet < PlayerControl > _glimmered = new ( ) ;
17+ private static readonly Dictionary < PlayerControl , float > _glimmerAlpha = new ( ) ;
1518
1619 public static void ApplyShadowCloak ( PlayerControl p , float alphaFactor )
1720 {
1821 if ( ! p || p . cosmetics == null ) return ;
19- // Save current phantom alpha, then set reduced alpha
2022 try
2123 {
2224 var current = p . cosmetics . GetPhantomRoleAlpha ( ) ;
2325 _savedPhantomAlpha [ p ] = current ;
2426 }
25- catch { /* ignore */ }
27+ catch { }
2628 p . cosmetics . SetPhantomRoleAlpha ( Mathf . Clamp01 ( alphaFactor ) ) ;
2729 }
2830
@@ -36,7 +38,6 @@ public static void RemoveShadowCloak(PlayerControl p)
3638 }
3739 else
3840 {
39- // fallback reset
4041 p . cosmetics . SetPhantomRoleAlpha ( 1f ) ;
4142 }
4243 }
@@ -60,24 +61,43 @@ public static void RemoveShieldTint(PlayerControl p)
6061
6162 public static void ApplySmokeDarkenInRadius ( Vector2 center , float radius )
6263 {
64+ ClearSmokeDarken ( ) ;
65+
6366 foreach ( var pc in PlayerControl . AllPlayerControls )
6467 {
6568 if ( ! pc || pc . cosmetics == null ) continue ;
6669 var d = Vector2 . Distance ( center , pc . GetTruePosition ( ) ) ;
6770 if ( d > radius ) continue ;
68- pc . cosmetics . FadeBlackCosmetics ( 0.6f ) ;
69- _smoked . Add ( pc ) ;
71+
72+ if ( pc . cosmetics . currentBodySprite != null && pc . cosmetics . currentBodySprite . BodySprite != null )
73+ {
74+ var sprite = pc . cosmetics . currentBodySprite . BodySprite ;
75+ _originalColors [ pc ] = sprite . color ;
76+
77+ var darkenedColor = new Color ( 0.1f , 0.1f , 0.1f , sprite . color . a ) ;
78+ sprite . color = darkenedColor ;
79+
80+ _smoked . Add ( pc ) ;
81+ }
7082 }
7183 }
7284
7385 public static void ClearSmokeDarken ( )
7486 {
75- foreach ( var p in _smoked )
87+ foreach ( var pc in _smoked )
7688 {
77- if ( ! p || p . cosmetics == null ) continue ;
78- p . cosmetics . FadeBlackCosmetics ( 0f ) ;
89+ if ( ! pc || pc . cosmetics == null ) continue ;
90+
91+ if ( _originalColors . TryGetValue ( pc , out var originalColor ) &&
92+ pc . cosmetics . currentBodySprite != null &&
93+ pc . cosmetics . currentBodySprite . BodySprite != null )
94+ {
95+ pc . cosmetics . currentBodySprite . BodySprite . color = originalColor ;
96+ }
7997 }
98+
8099 _smoked . Clear ( ) ;
100+ _originalColors . Clear ( ) ;
81101 }
82102
83103 public static void SpawnPulseRing ( Vector2 center , Color color , float duration )
@@ -109,4 +129,62 @@ private static IEnumerator SpawnPulseRingCo(Vector2 center, Color color, float d
109129
110130 if ( go ) UnityEngine . Object . Destroy ( go ) ;
111131 }
132+
133+ public static void ApplyTuneGlow ( Vector2 center , float radius )
134+ {
135+ foreach ( var pc in PlayerControl . AllPlayerControls )
136+ {
137+ if ( ! pc || pc . cosmetics == null ) continue ;
138+ var d = Vector2 . Distance ( center , pc . GetTruePosition ( ) ) ;
139+ if ( d > radius ) continue ;
140+ pc . cosmetics . SetOutline ( true , new Nullable < Color > ( new Color ( 1f , 0.9f , 0.2f , 1f ) ) ) ;
141+ _tuned . Add ( pc ) ;
142+ }
143+ }
144+
145+ public static void ClearTuneGlow ( )
146+ {
147+ foreach ( var pc in _tuned )
148+ {
149+ if ( ! pc || pc . cosmetics == null ) continue ;
150+ pc . cosmetics . SetOutline ( false , new Nullable < Color > ( ) ) ;
151+ }
152+ _tuned . Clear ( ) ;
153+ }
154+
155+ public static void ApplyGlimmerInRadius ( Vector2 center , float radius )
156+ {
157+ foreach ( var pc in PlayerControl . AllPlayerControls )
158+ {
159+ if ( ! pc || pc . cosmetics == null ) continue ;
160+ var d = Vector2 . Distance ( center , pc . GetTruePosition ( ) ) ;
161+ if ( d > radius ) continue ;
162+ if ( ! _glimmerAlpha . ContainsKey ( pc ) )
163+ {
164+ float a = 1f ;
165+ try { a = pc . cosmetics . GetPhantomRoleAlpha ( ) ; } catch { }
166+ _glimmerAlpha [ pc ] = a ;
167+ }
168+ pc . cosmetics . SetPhantomRoleAlpha ( 0.5f ) ;
169+ _glimmered . Add ( pc ) ;
170+ }
171+ }
172+
173+ public static void ClearGlimmer ( )
174+ {
175+ foreach ( var pc in _glimmered )
176+ {
177+ if ( ! pc || pc . cosmetics == null ) continue ;
178+ if ( _glimmerAlpha . TryGetValue ( pc , out var a ) )
179+ {
180+ pc . cosmetics . SetPhantomRoleAlpha ( a ) ;
181+ }
182+ else
183+ {
184+ pc . cosmetics . SetPhantomRoleAlpha ( 1f ) ;
185+ }
186+ }
187+ _glimmered . Clear ( ) ;
188+ _glimmerAlpha . Clear ( ) ;
189+ }
112190}
0 commit comments