@@ -39,6 +39,9 @@ public class ThrowBox : Actor {
3939 private readonly string _levelName ;
4040 private readonly bool _tutorial ;
4141 private readonly TransitionListener _transitionListener ;
42+ private readonly bool _canPassThroughSpinners ;
43+ private readonly ParticleType _p_Impact ;
44+ private readonly char _debrisTypeOverride ;
4245
4346 private Vector2 _prevLiftSpeed ;
4447 private Level _level ;
@@ -55,7 +58,8 @@ public class ThrowBox : Actor {
5558 private BirdTutorialGui _tutorialPutDown ;
5659 private bool _isCrucial ;
5760
58- public ThrowBox ( Vector2 position , bool isMetal , bool tutorial = false , bool isSpecial = false , bool isCrucial = false )
61+ public ThrowBox ( Vector2 position , bool isMetal , bool tutorial = false , bool isSpecial = false , bool isCrucial = false , bool canPassThroughSpinners = false ,
62+ string crateTextureOverride = null , string crucialTextureOverride = null , ParticleType impactParticlesOverride = null , char debrisTypeOverride = '\0 ' )
5963 : base ( position ) {
6064 Position -= DISPLACEMENT ;
6165 _starterPosition = Position ;
@@ -65,13 +69,21 @@ public ThrowBox(Vector2 position, bool isMetal, bool tutorial = false, bool isSp
6569 IsSpecial = isSpecial ;
6670 _isCrucial = isCrucial ;
6771 _tutorial = tutorial ;
68- string pathString = isMetal ? "crate_metal0" : "crate0" ;
72+ _canPassThroughSpinners = canPassThroughSpinners ;
6973
70- Add ( _image = new Image ( GFX . Game [ $ "objects/FactoryHelper/crate/{ pathString } "] ) ) ;
74+ string crateTexture ;
75+ if ( string . IsNullOrEmpty ( crateTextureOverride ) ) {
76+ string pathString = isMetal ? "crate_metal0" : "crate0" ;
77+ crateTexture = $ "objects/FactoryHelper/crate/{ pathString } ";
78+ } else {
79+ crateTexture = crateTextureOverride ;
80+ }
81+ Add ( _image = new Image ( GFX . Game [ crateTexture ] ) ) ;
7182 _image . Position += DISPLACEMENT ;
7283
7384 if ( _isCrucial ) {
74- Add ( _warningImage = new Image ( GFX . Game [ "objects/FactoryHelper/crate/crucial" ] ) ) ;
85+ string crucialTexture = string . IsNullOrEmpty ( crucialTextureOverride ) ? "objects/FactoryHelper/crate/crucial" : crucialTextureOverride ;
86+ Add ( _warningImage = new Image ( GFX . Game [ crucialTexture ] ) ) ;
7587 _warningImage . Position += DISPLACEMENT ;
7688 }
7789
@@ -98,19 +110,42 @@ public ThrowBox(Vector2 position, bool isMetal, bool tutorial = false, bool isSp
98110
99111 Add ( new LightOcclude ( 0.2f ) ) ;
100112 Add ( new MirrorReflection ( ) ) ;
113+
114+ _p_Impact = impactParticlesOverride ?? P_Impact ;
115+ _debrisTypeOverride = debrisTypeOverride ;
101116 }
102117
103118 public ThrowBox ( EntityData data , Vector2 offset )
104- : this ( data . Position + offset , data . Bool ( "isMetal" , false ) , data . Bool ( "tutorial" , false ) , data . Bool ( "isSpecial" , false ) , data . Bool ( "isCrucial" , false ) ) {
119+ : this ( data . Position + offset , data . Bool ( "isMetal" , false ) , data . Bool ( "tutorial" , false ) , data . Bool ( "isSpecial" , false ) , data . Bool ( "isCrucial" , false ) , data . Bool ( "canPassThroughSpinners" , false ) ,
120+ GetCrateTextureOverride ( data ) , GetCrucialTextureOverride ( data ) , GetImpactParticlesOverride ( data ) , GetDebrisTypeOverride ( data ) ) {
105121 _levelName = data . Level . Name ;
106122 }
107123
124+ private static string GetCrateTextureOverride ( EntityData data ) {
125+ return data . Bool ( "overrideTextures" , false ) ? data . Attr ( "crateTexturePath" ) : null ;
126+ }
127+
128+ private static string GetCrucialTextureOverride ( EntityData data ) {
129+ return data . Bool ( "overrideTextures" , false ) ? data . Attr ( "crucialTexturePath" ) : null ;
130+ }
131+
132+ private static ParticleType GetImpactParticlesOverride ( EntityData data ) {
133+ return data . Bool ( "overrideParticles" , false ) ? new ParticleType ( P_Impact ) {
134+ Color = data . HexColor ( "impactParticlesColor" )
135+ } : null ;
136+ }
137+
138+ private static char GetDebrisTypeOverride ( EntityData data ) {
139+ return data . Bool ( "overrideDebris" , false ) ? data . Char ( "debrisFromTiletype" ) : '\0 ' ;
140+ }
141+
108142 private void OnSteamWall ( SteamWall steamWall ) {
109143 Shatter ( ) ;
110144 }
111145
112146 private void OnHitSpinner ( Entity spinner ) {
113- Shatter ( ) ;
147+ if ( ! _canPassThroughSpinners )
148+ Shatter ( ) ;
114149 }
115150
116151 public override void Added ( Scene scene ) {
@@ -419,7 +454,7 @@ private void ImpactParticles(Vector2 dir) {
419454 positionRange = Vector2 . UnitX * 6f ;
420455 }
421456
422- ( Scene as Level ) . Particles . Emit ( P_Impact , 12 , position , positionRange , direction ) ;
457+ ( Scene as Level ) . Particles . Emit ( _p_Impact , 12 , position , positionRange , direction ) ;
423458 }
424459
425460 private void Shatter ( ) {
@@ -434,7 +469,9 @@ private void Shatter() {
434469
435470 for ( int i = 0 ; i < Width / 8f ; i ++ ) {
436471 for ( int j = 0 ; j < Height / 8f ; j ++ ) {
437- if ( _isMetal ) {
472+ if ( _debrisTypeOverride != '\0 ' ) {
473+ Scene . Add ( Engine . Pooler . Create < Debris > ( ) . Init ( Position + new Vector2 ( 4 + ( i * 8 ) , 4 + ( j * 8 ) ) + DISPLACEMENT , _debrisTypeOverride , false ) . BlastFrom ( Center ) ) ;
474+ } else if ( _isMetal ) {
438475 Scene . Add ( Engine . Pooler . Create < Debris > ( ) . Init ( Position + new Vector2 ( 4 + ( i * 8 ) , 4 + ( j * 8 ) ) + DISPLACEMENT , '8' , false ) . BlastFrom ( Center ) ) ;
439476 } else {
440477 Scene . Add ( Engine . Pooler . Create < Debris > ( ) . Init ( Position + new Vector2 ( 4 + ( i * 8 ) , 4 + ( j * 8 ) ) + DISPLACEMENT , '9' , false ) . BlastFrom ( Center ) ) ;
0 commit comments