@@ -39,6 +39,9 @@ public class ThrowBox : Actor {
39
39
private readonly string _levelName ;
40
40
private readonly bool _tutorial ;
41
41
private readonly TransitionListener _transitionListener ;
42
+ private readonly bool _canPassThroughSpinners ;
43
+ private readonly ParticleType _p_Impact ;
44
+ private readonly char _debrisTypeOverride ;
42
45
43
46
private Vector2 _prevLiftSpeed ;
44
47
private Level _level ;
@@ -55,7 +58,8 @@ public class ThrowBox : Actor {
55
58
private BirdTutorialGui _tutorialPutDown ;
56
59
private bool _isCrucial ;
57
60
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 ' )
59
63
: base ( position ) {
60
64
Position -= DISPLACEMENT ;
61
65
_starterPosition = Position ;
@@ -65,13 +69,21 @@ public ThrowBox(Vector2 position, bool isMetal, bool tutorial = false, bool isSp
65
69
IsSpecial = isSpecial ;
66
70
_isCrucial = isCrucial ;
67
71
_tutorial = tutorial ;
68
- string pathString = isMetal ? "crate_metal0" : "crate0" ;
72
+ _canPassThroughSpinners = canPassThroughSpinners ;
69
73
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 ] ) ) ;
71
82
_image . Position += DISPLACEMENT ;
72
83
73
84
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 ] ) ) ;
75
87
_warningImage . Position += DISPLACEMENT ;
76
88
}
77
89
@@ -98,19 +110,42 @@ public ThrowBox(Vector2 position, bool isMetal, bool tutorial = false, bool isSp
98
110
99
111
Add ( new LightOcclude ( 0.2f ) ) ;
100
112
Add ( new MirrorReflection ( ) ) ;
113
+
114
+ _p_Impact = impactParticlesOverride ?? P_Impact ;
115
+ _debrisTypeOverride = debrisTypeOverride ;
101
116
}
102
117
103
118
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 ) ) {
105
121
_levelName = data . Level . Name ;
106
122
}
107
123
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
+
108
142
private void OnSteamWall ( SteamWall steamWall ) {
109
143
Shatter ( ) ;
110
144
}
111
145
112
146
private void OnHitSpinner ( Entity spinner ) {
113
- Shatter ( ) ;
147
+ if ( ! _canPassThroughSpinners )
148
+ Shatter ( ) ;
114
149
}
115
150
116
151
public override void Added ( Scene scene ) {
@@ -419,7 +454,7 @@ private void ImpactParticles(Vector2 dir) {
419
454
positionRange = Vector2 . UnitX * 6f ;
420
455
}
421
456
422
- ( Scene as Level ) . Particles . Emit ( P_Impact , 12 , position , positionRange , direction ) ;
457
+ ( Scene as Level ) . Particles . Emit ( _p_Impact , 12 , position , positionRange , direction ) ;
423
458
}
424
459
425
460
private void Shatter ( ) {
@@ -434,7 +469,9 @@ private void Shatter() {
434
469
435
470
for ( int i = 0 ; i < Width / 8f ; i ++ ) {
436
471
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 ) {
438
475
Scene . Add ( Engine . Pooler . Create < Debris > ( ) . Init ( Position + new Vector2 ( 4 + ( i * 8 ) , 4 + ( j * 8 ) ) + DISPLACEMENT , '8' , false ) . BlastFrom ( Center ) ) ;
439
476
} else {
440
477
Scene . Add ( Engine . Pooler . Create < Debris > ( ) . Init ( Position + new Vector2 ( 4 + ( i * 8 ) , 4 + ( j * 8 ) ) + DISPLACEMENT , '9' , false ) . BlastFrom ( Center ) ) ;
0 commit comments